diff --git a/src/qt/recover.cpp b/src/qt/recover.cpp index 3e5c20da58..5d75dd25b7 100644 --- a/src/qt/recover.cpp +++ b/src/qt/recover.cpp @@ -33,6 +33,8 @@ Recover::Recover(QWidget *parent) : thread->start(); connect(ui->enableDateSelection, &QCheckBox::toggled, this, &Recover::updateDateInputState); + ui->dateInput->setDisplayFormat("dd-MM-yyyy"); + ui->dateInput->setMinimumDate(QDate(2020, 3, 23)); } Recover::~Recover() @@ -62,14 +64,14 @@ void Recover::setCreateNew() void Recover::updateDateInputState(bool checked) { ui->dateInput->setEnabled(checked); - if (checked) { - ui->dateInput->setMinimumDate(QDate(2020, 3, 23)); - } + ui->dateInput->setMinimumDate(QDate(2020, 3, 23)); } void Recover::on_createNew_clicked() { setCreateNew(); + ui->dateInput->setDisplayFormat("dd-MM-yyyy"); + ui->dateInput->setDate(QDate(2020, 3, 23)); } void Recover::on_recoverExisting_clicked() @@ -79,6 +81,8 @@ void Recover::on_recoverExisting_clicked() ui->dateInput->setEnabled(true); ui->dateInput->setEnabled(ui->enableDateSelection->isChecked()); ui->enableDateSelection->setEnabled(true); + ui->dateInput->setDisplayFormat("dd-MM-yyyy"); + ui->dateInput->setDate(ui->dateInput->minimumDate()); } void Recover::on_usePassphrase_clicked() @@ -122,6 +126,9 @@ bool Recover::askRecover(bool& newWallet) newWallet = false; std::string mnemonic = recover.ui->mnemonicWords->text().toStdString(); if (recover.ui->enableDateSelection->isChecked()) { + QDate date = recover.ui->dateInput->date(); + QDate newDate = date.addDays(-1); + recover.ui->dateInput->setDate(newDate); SoftSetArg("-wcdate", recover.ui->dateInput->text().toStdString()); } else { SoftSetArg("-wcdate", ""); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 6cb3962300..a8cc744a66 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2408,11 +2408,12 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, bool f // no need to read and scan block, if block was created before // our wallet birthday (as adjusted for block time variability) // if you are recovering wallet with mnemonics start rescan from block when mnemonics implemented in Firo + int targetHeight = 0; if (fRecoverMnemonic) { std::string wcdate = GetArg("-wcdate", ""); CBlockIndex* mnemonicStartBlock = chainActive[chainParams.GetConsensus().nMnemonicBlock]; + targetHeight = GetBlockHeightByDate(mnemonicStartBlock, wcdate); if (!wcdate.empty()) { - int targetHeight = GetBlockHeightByDate(mnemonicStartBlock, wcdate); if (targetHeight <= 0) { targetHeight = chainParams.GetConsensus().nMnemonicBlock; } @@ -2423,7 +2424,7 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, bool f } else while (pindex && nTimeFirstKey && (pindex->GetBlockTime() < (nTimeFirstKey - 7200))) pindex = chainActive.Next(pindex); - + LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height(), targetHeight); ShowProgress(_("Rescanning..."), 0); // show rescan progress in GUI as dialog or on splashscreen, if -rescan on startup double dProgressStart = GuessVerificationProgress(chainParams.TxData(), pindex); double dProgressTip = GuessVerificationProgress(chainParams.TxData(), chainActive.Tip()); @@ -7314,7 +7315,6 @@ CWallet* CWallet::CreateWalletFromFile(const std::string walletFile) } uiInterface.InitMessage(_("Rescanning...")); - LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height() - pindexRescan->nHeight, pindexRescan->nHeight); nStart = GetTimeMillis(); walletInstance->ScanForWalletTransactions(pindexRescan, true, fRecoverMnemonic); LogPrintf(" rescan %15dms\n", GetTimeMillis() - nStart);