From 97b6f365a14dbd395a897fc9d64af1d60f1226d3 Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 3 Sep 2016 09:51:17 -0700 Subject: [PATCH] Fix bug where wallet was not persisting witnesses to disk. Author: str4d --- src/wallet/wallet.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 969399a2..52812e50 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -654,7 +654,11 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, nWitnessCacheSize += 1; } if (fFileBacked) { - CWalletDB(strWalletFile).WriteWitnessCacheSize(nWitnessCacheSize); + CWalletDB walletdb(strWalletFile); + for (std::pair& wtxItem : mapWallet) { + walletdb.WriteTx(wtxItem.first, wtxItem.second); + } + walletdb.WriteWitnessCacheSize(nWitnessCacheSize); } } } @@ -675,7 +679,11 @@ void CWallet::DecrementNoteWitnesses() // TODO: If nWitnessCache is zero, we need to regenerate the caches (#1302) assert(nWitnessCacheSize > 0); if (fFileBacked) { - CWalletDB(strWalletFile).WriteWitnessCacheSize(nWitnessCacheSize); + CWalletDB walletdb(strWalletFile); + for (std::pair& wtxItem : mapWallet) { + walletdb.WriteTx(wtxItem.first, wtxItem.second); + } + walletdb.WriteWitnessCacheSize(nWitnessCacheSize); } } }