From a09abf06b46effd8c712d734f16712e18a873fff Mon Sep 17 00:00:00 2001 From: levoncrypto <95240473+levoncrypto@users.noreply.github.com> Date: Thu, 14 Nov 2024 13:48:36 +0400 Subject: [PATCH] Fix block index issue with wallet scan (#1495) --- src/wallet/wallet.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4273885fac..787a739f0d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2382,7 +2382,11 @@ CBlockIndex* CWallet::GetBlockByDate(CBlockIndex* pindexStart, const std::string while (pindex) { if (pindex->GetBlockTime() > targetTimestamp) { - return chainActive[pindex->nHeight - 200]; + if (pindex->nHeight >= 200) { + return chainActive[pindex->nHeight - 200]; + } else { + return chainActive[0]; + } } pindex = chainActive.Next(pindex); } @@ -2411,7 +2415,6 @@ CBlockIndex* CWallet::ScanForWalletTransactions(CBlockIndex *pindexStart, bool f // If you are recovering wallet with mnemonics, start rescan from the block when mnemonics were implemented in Firo. // If the user provides a date, start scanning from the block that corresponds to that date. // If no date is provided, start scanning from the mnemonic start block. - std::string wcdate = GetArg("-wcdate", ""); CBlockIndex* mnemonicStartBlock = chainActive[chainParams.GetConsensus().nMnemonicBlock]; if (mnemonicStartBlock == NULL)