aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2015-08-11 21:03:31 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2015-09-22 18:51:07 +0200
commit391dff16fe9ace90fc0f3308a5c63c453370e713 (patch)
tree3337a40ad6bca7c57560c45d091bb9ebfd6523cf /src/wallet/walletdb.cpp
parente59d2a80f9167031521d882394a08b02fa9d0343 (diff)
downloadbitcoin-391dff16fe9ace90fc0f3308a5c63c453370e713.tar.xz
Do not store Merkle branches in the wallet.
Assume that when a wallet transaction has a valid block hash and transaction position in it, the transaction is actually there. We're already trusting wallet data in a much more fundamental way anyway. To prevent backward compatibility issues, a new record is used for storing the block locator in the wallet. Old wallets will see a wallet file synchronized up to the genesis block, and rescan automatically.
Diffstat (limited to 'src/wallet/walletdb.cpp')
-rw-r--r--src/wallet/walletdb.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
index c1eb184581..0624e442d1 100644
--- a/src/wallet/walletdb.cpp
+++ b/src/wallet/walletdb.cpp
@@ -131,12 +131,14 @@ bool CWalletDB::EraseWatchOnly(const CScript &dest)
bool CWalletDB::WriteBestBlock(const CBlockLocator& locator)
{
nWalletDBUpdated++;
- return Write(std::string("bestblock"), locator);
+ Write(std::string("bestblock"), CBlockLocator()); // Write empty block locator so versions that require a merkle branch automatically rescan
+ return Write(std::string("bestblock_nomerkle"), locator);
}
bool CWalletDB::ReadBestBlock(CBlockLocator& locator)
{
- return Read(std::string("bestblock"), locator);
+ if (Read(std::string("bestblock"), locator) && !locator.vHave.empty()) return true;
+ return Read(std::string("bestblock_nomerkle"), locator);
}
bool CWalletDB::WriteOrderPosNext(int64_t nOrderPosNext)