Automatically rescan after restoring wallet.dat
Information about the best known chain is added to wallet.dat. If this information does not match the data in blkindex.dat, a rescan is automatically performed, starting from the the last known block. When upgrading from a wallet which does not have this information, no rescan is done automatically.
This commit is contained in:
committed by
Gavin Andresen
parent
657cfe721b
commit
6a76c60e6c
9
main.cpp
9
main.cpp
@@ -1611,6 +1611,15 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew)
|
||||
}
|
||||
}
|
||||
|
||||
// Update best block in wallet (so we can detect restored wallets)
|
||||
if (!IsInitialBlockDownload())
|
||||
{
|
||||
CWalletDB walletdb;
|
||||
const CBlockLocator locator(pindexNew);
|
||||
if (!walletdb.WriteBestBlock(locator))
|
||||
return error("SetBestChain() : WriteWalletBest failed");
|
||||
}
|
||||
|
||||
// New best block
|
||||
hashBestChain = hash;
|
||||
pindexBest = pindexNew;
|
||||
|
||||
Reference in New Issue
Block a user