From: gg Date: Fri, 16 Jan 2026 00:09:06 +0000 (-0500) Subject: fixup! Qt 5.12 compat (refactor) X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=6cafd456a061a138e6d5aedda9096eea850aedfc;p=gamesguru%2Ffeather.git fixup! Qt 5.12 compat (refactor) --- diff --git a/src/dialog/HistoryExportDialog.cpp b/src/dialog/HistoryExportDialog.cpp index 5a63e7f9..51fbd213 100644 --- a/src/dialog/HistoryExportDialog.cpp +++ b/src/dialog/HistoryExportDialog.cpp @@ -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}); } diff --git a/src/dialog/LegacySeedRecovery.cpp b/src/dialog/LegacySeedRecovery.cpp index 5e720473..06c12080 100644 --- a/src/dialog/LegacySeedRecovery.cpp +++ b/src/dialog/LegacySeedRecovery.cpp @@ -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) { diff --git a/src/dialog/SeedDiceDialog.cpp b/src/dialog/SeedDiceDialog.cpp index 398723ac..60357474 100644 --- a/src/dialog/SeedDiceDialog.cpp +++ b/src/dialog/SeedDiceDialog.cpp @@ -11,7 +11,15 @@ #include #include "polyseed/polyseed.h" +#include + +// 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 +#else +#include // 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(salt.data()), salt.length(), + 2048, // Iterations + EVP_sha256(), // Match QCryptographicHash::Sha256 + 19, // Output Key Size + reinterpret_cast(m_key.data())); +#endif sodium_memzero(data.data(), data.size()); sodium_memzero(&random, POLYSEED_RANDBYTES); diff --git a/src/dialog/SyncRangeDialog.cpp b/src/dialog/SyncRangeDialog.cpp index 73966fa4..5d66a58f 100644 --- a/src/dialog/SyncRangeDialog.cpp +++ b/src/dialog/SyncRangeDialog.cpp @@ -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;