]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
fixup! Qt 5.12 compat (refactor)
authorgg <chown_tee@proton.me>
Fri, 16 Jan 2026 00:09:06 +0000 (19:09 -0500)
committergg <chown_tee@proton.me>
Fri, 16 Jan 2026 02:16:55 +0000 (21:16 -0500)
src/dialog/HistoryExportDialog.cpp
src/dialog/LegacySeedRecovery.cpp
src/dialog/SeedDiceDialog.cpp
src/dialog/SyncRangeDialog.cpp

index 5a63e7f9209e32830f09dad9ac7e8fa311ab04cc..51fbd213deed49489ab1438487572c1c4c8e5f70 100644 (file)
@@ -153,19 +153,19 @@ void HistoryExportDialog::exportHistory()
         QString fiatAmount = (usd_price > 0) ? QString::number(fiat_price, 'f', 2) : "?";
 
         QString line = QString(R"(%1,%2,"%3",%4,"%5",%6,%7,%8,"%9","%10","%11","%12","%13")")
-        .arg(QString::number(tx.blockHeight),
-             QString::number(tx.timestamp.toSecsSinceEpoch()),
-             date,
-             QString::number(tx.subaddrAccount),
-             direction,
-             balanceDelta,
-             tx.displayAmount(),
-             tx.displayFee(),
-             tx.hash,
-             tx.description,
-             paymentId,
-             fiatAmount,
-             "USD");
+            .arg(QString::number(tx.blockHeight))   // %1
+            .arg(QString::number(tx.timestamp.toSecsSinceEpoch()))
+            .arg(date)
+            .arg(QString::number(tx.subaddrAccount))
+            .arg(direction)                           // %5
+            .arg(balanceDelta)
+            .arg(tx.displayAmount())
+            .arg(tx.displayFee())
+            .arg(tx.hash)
+            .arg(tx.description)                     // %10
+            .arg(paymentId)
+            .arg(fiatAmount)
+            .arg("USD");
         csvData.append({tx.blockHeight, line});
     }
 
index 5e720473ca76625ff3c8e92f0055853be4fa2742..06c1208060a9a451117e5d336fa478f287b54b4e 100644 (file)
@@ -133,7 +133,12 @@ void LegacySeedRecovery::checkSeed() {
     ui->progressBar->setMaximum(39024);
     ui->progressBar->setValue(0);
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
     QStringList words = ui->seed->toPlainText().replace("\n", " ").replace("\r", "").trimmed().split(" ", Qt::SkipEmptyParts);
+#else
+    QStringList words = ui->seed->toPlainText().replace("\n", " ").replace("\r", "").trimmed().split(" ", QString::SkipEmptyParts);
+#endif
+
     if (words.length() < 24) {
         Utils::showError(this, "Invalid seed", "Less than 24 words were entered", {"Remember to use a single space between each word."});
         return;
@@ -202,7 +207,7 @@ void LegacySeedRecovery::checkSeed() {
 
             for (int i = 0; i < 24; i++) {
                 QStringList seed = words;
-                seed.swapItemsAt(i, i+1);
+                std::swap(seed[i], seed[i+1]);
 
                 QString m = seed.join(" ");
                 bool done = this->testSeed(m, spkey);
@@ -211,7 +216,7 @@ void LegacySeedRecovery::checkSeed() {
                 }
 
                 // Swap back
-                seed.swapItemsAt(i, i+1);
+                std::swap(seed[i], seed[i+1]);
             }
 
             if (m_cancelled) {
index 398723ac247e84865cc80f3796c902e2460f7a79..60357474894f9c551a71c45f7f56e4dbcfda32de 100644 (file)
 #include <sodium/randombytes.h>
 #include "polyseed/polyseed.h"
 
+#include <QtGlobal>
+
+// Use QPasswordDigestor only on newer Qt versions (5.15+)
+// Fallback to OpenSSL for Ubuntu 20.04 (Qt 5.12)
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
 #include <QPasswordDigestor>
+#else
+#include <openssl/evp.h> // TODO: add tests for this block
+#endif
 
 #include "utils/Seed.h"
 
@@ -103,8 +111,20 @@ SeedDiceDialog::SeedDiceDialog(QWidget *parent)
         int sides = ui->radio_coinflip->isChecked() ? 2 : ui->spin_sides->value();
         QByteArray salt = "POLYSEED-" + QString::number(sides).toUtf8(); // domain separate by number of sides
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
+        // Modern Qt (Ubuntu 22.04+)
         // Polyseed requests 19 bytes of random data and discards two bits (for a total of 150 bits)
         m_key = QPasswordDigestor::deriveKeyPbkdf2(QCryptographicHash::Sha256, data, salt, 2048, 19);
+#else
+        // Legacy Qt 5.12 (Ubuntu 20.04) - Fallback to OpenSSL
+        m_key.resize(19);
+        PKCS5_PBKDF2_HMAC(data.data(), data.length(),
+                          reinterpret_cast<const unsigned char*>(salt.data()), salt.length(),
+                          2048,           // Iterations
+                          EVP_sha256(),   // Match QCryptographicHash::Sha256
+                          19,             // Output Key Size
+                          reinterpret_cast<unsigned char*>(m_key.data()));
+#endif
 
         sodium_memzero(data.data(), data.size());
         sodium_memzero(&random, POLYSEED_RANDBYTES);
index 73966fa4316f48ebea02986b2ae65585283f1a05..5d66a58fda3f432f506334c01abd7961516fd9ba 100644 (file)
@@ -130,8 +130,16 @@ void SyncRangeDialog::updateInfo() {
     QDate start = m_fromDateEdit->date();
     QDate end = m_toDateEdit->date();
 
+#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
+    // Modern Qt (Ubuntu 22.04+)
     uint64_t startHeight = lookup->dateToHeight(start.startOfDay().toSecsSinceEpoch());
     uint64_t endHeight = lookup->dateToHeight(end.endOfDay().toSecsSinceEpoch());
+#else
+    // Legacy Qt 5.12 (Ubuntu 20.04)
+    // Manually construct the DateTime for 00:00:00 and 23:59:59
+    uint64_t startHeight = lookup->dateToHeight(QDateTime(start, QTime(0, 0, 0)).toSecsSinceEpoch());
+    uint64_t endHeight = lookup->dateToHeight(QDateTime(end, QTime(23, 59, 59)).toSecsSinceEpoch());
+#endif
 
     if (endHeight < startHeight) endHeight = startHeight;
     m_estimatedBlocks = endHeight - startHeight;