diff options
| author | Russell Yanofsky <[email protected]> | 2017-05-16 11:34:28 -0400 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2017-05-23 17:09:42 +0200 |
| commit | 321419bc06fdc19e3713b2bcfc10c3c9bbbb8b62 (patch) | |
| tree | 18144663278653e9d1038b0f37d97ef1b76eed30 /src/wallet/rpcdump.cpp | |
| parent | Populate services in GetLocalAddress (diff) | |
| download | discoin-321419bc06fdc19e3713b2bcfc10c3c9bbbb8b62.tar.xz discoin-321419bc06fdc19e3713b2bcfc10c3c9bbbb8b62.zip | |
Fix importwallet edge case rescan bug
Start importwallet rescans at the first block with timestamp greater or equal
to the wallet birthday instead of the last block with timestamp less or equal.
This fixes an edge case bug where importwallet could fail to start the rescan
early enough if there are blocks with decreasing timestamps or multiple blocks
with the same timestamp.
Github-Pull: #10410
Rebased-From: 2a8e35a11d4bd4828631654fc7b8b8fe8f0a2460
Diffstat (limited to 'src/wallet/rpcdump.cpp')
| -rw-r--r-- | src/wallet/rpcdump.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index cfb53af49..cd6ec207f 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -497,14 +497,11 @@ UniValue importwallet(const JSONRPCRequest& request) } file.close(); pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI - - CBlockIndex *pindex = chainActive.Tip(); - while (pindex && pindex->pprev && pindex->GetBlockTime() > nTimeBegin - 7200) - pindex = pindex->pprev; - pwalletMain->UpdateTimeFirstKey(nTimeBegin); - LogPrintf("Rescanning last %i blocks\n", chainActive.Height() - pindex->nHeight + 1); + CBlockIndex *pindex = chainActive.FindEarliestAtLeast(nTimeBegin - 7200); + + LogPrintf("Rescanning last %i blocks\n", pindex ? chainActive.Height() - pindex->nHeight + 1 : 0); pwalletMain->ScanForWalletTransactions(pindex); pwalletMain->MarkDirty(); |