From f3ef0bd675577aeb16a290c98e7e9743440a4198 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Fri, 25 Feb 2022 21:22:03 +0100 Subject: [PATCH] Wizard: reduce new wallet sync time --- src/utils/Seed.cpp | 1 + src/wizard/PageWalletRestoreSeed.cpp | 2 +- src/wizard/PageWalletSeed.cpp | 20 ++++++++++---------- src/wizard/PageWalletSeed.h | 2 +- src/wizard/WalletWizard.cpp | 8 +++----- src/wizard/WalletWizard.h | 2 +- 6 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/utils/Seed.cpp b/src/utils/Seed.cpp index 1e4eb05a..236c4190 100644 --- a/src/utils/Seed.cpp +++ b/src/utils/Seed.cpp @@ -101,6 +101,7 @@ void Seed::setRestoreHeight(int height) { void Seed::setRestoreHeight() { // Ignore the embedded restore date, new wallets should sync from the current block height. this->restoreHeight = appData()->restoreHeights[networkType]->dateToHeight(this->time); + int a = 0; } Seed::Seed() = default; \ No newline at end of file diff --git a/src/wizard/PageWalletRestoreSeed.cpp b/src/wizard/PageWalletRestoreSeed.cpp index 3c8eaa29..27fc3514 100644 --- a/src/wizard/PageWalletRestoreSeed.cpp +++ b/src/wizard/PageWalletRestoreSeed.cpp @@ -139,7 +139,7 @@ bool PageWalletRestoreSeed::validatePage() { QMessageBox::information(this, "Corrected erasure", QString("xxxx -> %1").arg(_seed.correction)); } - m_fields->seed = seedSplit.join(" "); + m_fields->seed = _seed; m_fields->seedOffsetPassphrase = ui->line_seedOffset->text(); return true; diff --git a/src/wizard/PageWalletSeed.cpp b/src/wizard/PageWalletSeed.cpp index 0008cee5..c718e20e 100644 --- a/src/wizard/PageWalletSeed.cpp +++ b/src/wizard/PageWalletSeed.cpp @@ -31,7 +31,7 @@ PageWalletSeed::PageWalletSeed(WizardFields *fields, QWidget *parent) this->seedRoulette(0); }); connect(ui->btnCopy, &QPushButton::clicked, [this]{ - Utils::copyToClipboard(m_mnemonic); + Utils::copyToClipboard(m_seed.mnemonic.join(" ")); }); } @@ -53,17 +53,17 @@ void PageWalletSeed::seedRoulette(int count) { } void PageWalletSeed::generateSeed() { - Seed seed; + QString mnemonic; do { - seed = Seed(Seed::Type::TEVADOR); - m_mnemonic = seed.mnemonic.join(" "); - m_restoreHeight = seed.restoreHeight; - } while (m_mnemonic.split(" ").length() != 14); // https://github.com/tevador/monero-seed/issues/2 + m_seed = Seed(Seed::Type::TEVADOR); + mnemonic = m_seed.mnemonic.join(" "); + m_restoreHeight = m_seed.restoreHeight; + } while (mnemonic.split(" ").length() != 14); // https://github.com/tevador/monero-seed/issues/2 - this->displaySeed(m_mnemonic); + this->displaySeed(mnemonic); - if (!seed.errorString.isEmpty()) { + if (!m_seed.errorString.isEmpty()) { ui->frame_invalidSeed->show(); ui->frame_seedDisplay->hide(); m_seedError = true; @@ -94,7 +94,7 @@ int PageWalletSeed::nextId() const { } bool PageWalletSeed::validatePage() { - if (m_mnemonic.isEmpty()) return false; + if (m_seed.mnemonic.isEmpty()) return false; if (!m_restoreHeight) return false; QMessageBox seedWarning(this); @@ -111,7 +111,7 @@ bool PageWalletSeed::validatePage() { return false; } - m_fields->seed = m_mnemonic; + m_fields->seed = m_seed; return true; } diff --git a/src/wizard/PageWalletSeed.h b/src/wizard/PageWalletSeed.h index ffe4fbf0..835c050f 100644 --- a/src/wizard/PageWalletSeed.h +++ b/src/wizard/PageWalletSeed.h @@ -40,12 +40,12 @@ private: WizardFields *m_fields; - QString m_mnemonic; int m_restoreHeight; bool m_seedError = false; bool m_roulette = false; int m_rouletteSpin = 15; + Seed m_seed; }; #endif //FEATHER_CREATEWALLETSEED_H diff --git a/src/wizard/WalletWizard.cpp b/src/wizard/WalletWizard.cpp index cfae8c1c..32f90e74 100644 --- a/src/wizard/WalletWizard.cpp +++ b/src/wizard/WalletWizard.cpp @@ -117,17 +117,15 @@ void WalletWizard::onCreateWallet() { return; } - auto seed = Seed(m_wizardFields.seedType, m_wizardFields.seed.split(" "), constants::networkType); - // If we're connected to the websocket, use the reported height for new wallets to skip initial synchronization. if (m_wizardFields.mode == WizardMode::CreateWallet && currentBlockHeight > 0) { qInfo() << "New wallet, setting restore height to latest blockheight: " << currentBlockHeight; - seed.restoreHeight = currentBlockHeight; + m_wizardFields.seed.restoreHeight = currentBlockHeight; } if (m_wizardFields.mode == WizardMode::RestoreFromSeed && m_wizardFields.seedType == Seed::Type::MONERO) { - seed.setRestoreHeight(m_wizardFields.restoreHeight); + m_wizardFields.seed.setRestoreHeight(m_wizardFields.restoreHeight); } - emit createWallet(seed, walletPath, m_wizardFields.password, m_wizardFields.seedLanguage, m_wizardFields.seedOffsetPassphrase); + emit createWallet(m_wizardFields.seed, walletPath, m_wizardFields.password, m_wizardFields.seedLanguage, m_wizardFields.seedOffsetPassphrase); } diff --git a/src/wizard/WalletWizard.h b/src/wizard/WalletWizard.h index 81c682d1..7a15364c 100644 --- a/src/wizard/WalletWizard.h +++ b/src/wizard/WalletWizard.h @@ -31,7 +31,7 @@ enum DeviceType { struct WizardFields { QString walletName; QString walletDir; - QString seed; + Seed seed; QString seedOffsetPassphrase; QString seedLanguage = constants::seedLanguage; QString password; -- 2.52.0