Wizard: reduce new wallet sync time

This commit is contained in:
tobtoht 2022-02-25 21:22:03 +01:00
parent f816f44f4c
commit f3ef0bd675
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
6 changed files with 17 additions and 18 deletions

View 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;

View 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;

View 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;
}

View 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

View 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);
}

View 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;