From f9df2a0642278c7b92b6f7a739de19d34083a6f5 Mon Sep 17 00:00:00 2001 From: levoncrypto Date: Mon, 12 Aug 2024 11:58:33 +0400 Subject: [PATCH] Wallet rescan fixes --- src/wallet/wallet.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 5bb8c09b92..891a76f884 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2416,11 +2416,16 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, bool f pindex = chainActive[chainParams.GetConsensus().nMnemonicBlock]; } } else { - if (nTimeFirstKey < mnemonicStartBlock->GetBlockTime()) - pindex = chainActive.Genesis(); - else { - pindex = chainActive[chainParams.GetConsensus().nMnemonicBlock]; + bool fRescan = GetBoolArg("-rescan", false); + if (fRescan) { + if (nTimeFirstKey < mnemonicStartBlock->GetBlockTime()) + pindex = chainActive.Genesis(); + else + pindex = mnemonicStartBlock; } + else + while (pindex && nTimeFirstKey && (pindex->GetBlockTime() < (nTimeFirstKey - 7200))) + pindex = chainActive.Next(pindex); } LogPrintf("Rescanning last %i blocks (from block %i)...\n", chainActive.Height(), pindex->nHeight);