]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
Wizard: reduce new wallet sync time
authortobtoht <thotbot@protonmail.com>
Fri, 25 Feb 2022 20:22:03 +0000 (21:22 +0100)
committertobtoht <thotbot@protonmail.com>
Fri, 25 Feb 2022 20:22:03 +0000 (21:22 +0100)
src/utils/Seed.cpp
src/wizard/PageWalletRestoreSeed.cpp
src/wizard/PageWalletSeed.cpp
src/wizard/PageWalletSeed.h
src/wizard/WalletWizard.cpp
src/wizard/WalletWizard.h

index 1e4eb05a4a09f414055bac73bfd9ca68b31304b3..236c4190e0a89fc078c925d1557eea1663f06409 100644 (file)
@@ -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
index 3c8eaa29131d605f911d0d989d4d1fddf088743c..27fc35146e3108461de95963055cffafe1e8f851 100644 (file)
@@ -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;
index 0008cee56e1259ea78c0dfc6bc3889ef090de2e2..c718e20e12046e8db52222ecff090036b17fe0fe 100644 (file)
@@ -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;
 }
index ffe4fbf0c1dce4d1f503b11f7ba1daade733aeed..835c050f5b450a2b448b4b79e2f71488356cfa2f 100644 (file)
@@ -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
index cfae8c1c73927d9231db46e4b54b8e6773ddd5b0..32f90e7480bf02fcf6539d7ff43caa49af52a1c9 100644 (file)
@@ -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);
 }
index 81c682d1c2afdb7587e0675c252c21b3a4db214f..7a15364c9e95729605f22558ea3a45fe95cc5217 100644 (file)
@@ -31,7 +31,7 @@ enum DeviceType {
 struct WizardFields {
     QString walletName;
     QString walletDir;
-    QString seed;
+    Seed seed;
     QString seedOffsetPassphrase;
     QString seedLanguage = constants::seedLanguage;
     QString password;