From 2aceeb01a9b0b0c6bfa0d56211453e87bc33d6e4 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Wed, 1 May 2013 19:09:04 +0200 Subject: [PATCH] Bugfix: if no bestblock record is present, do a -rescan It is possible to have a wallet.dat file without any bestblock record at all (if created offline, for example), which - when loaded into a client with a up-to-date chain - does no rescan and shows no transactions. Also make sure to write the current best block after a rescan, so it isn't necessary twice. --- src/init.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/init.cpp b/src/init.cpp index 3845cfad8..3c1040a79 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -988,6 +988,8 @@ bool AppInit2(boost::thread_group& threadGroup) CBlockLocator locator; if (walletdb.ReadBestBlock(locator)) pindexRescan = locator.GetBlockIndex(); + else + pindexRescan = pindexGenesisBlock; } if (pindexBest && pindexBest != pindexRescan) { @@ -996,6 +998,8 @@ bool AppInit2(boost::thread_group& threadGroup) nStart = GetTimeMillis(); pwalletMain->ScanForWalletTransactions(pindexRescan, true); printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart); + pwalletMain->SetBestChain(CBlockLocator(pindexBest)); + nWalletDBUpdated++; } // ********************************************************* Step 9: import blocks