aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@bitpay.com>2014-02-14 11:33:07 -0500
committerJeff Garzik <jgarzik@bitpay.com>2014-02-14 11:33:07 -0500
commit518f3bdae3415fdb60cef984b69b36f2633c1fe1 (patch)
tree98022a0e8b5a3c2b5ab50fbb6089a8d2e29c0967 /src/wallet.cpp
parent6056c87d25994bbceb23d6ae50df1276a51d51bd (diff)
downloadbitcoin-518f3bdae3415fdb60cef984b69b36f2633c1fe1.tar.xz
Add -zapwallettxes cli/config option, used for wallet recovery
This diagnostic tool removes all "tx" records from the wallet db, then forces a full rescan, to rebuild "tx" records accurately.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index e3c460ff33..1ba70c1160 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -1497,6 +1497,30 @@ DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
}
+DBErrors CWallet::ZapWalletTx()
+{
+ if (!fFileBacked)
+ return DB_LOAD_OK;
+ DBErrors nZapWalletTxRet = CWalletDB(strWalletFile,"cr+").ZapWalletTx(this);
+ if (nZapWalletTxRet == DB_NEED_REWRITE)
+ {
+ if (CDB::Rewrite(strWalletFile, "\x04pool"))
+ {
+ LOCK(cs_wallet);
+ setKeyPool.clear();
+ // Note: can't top-up keypool here, because wallet is locked.
+ // User will be prompted to unlock wallet the next operation
+ // the requires a new key.
+ }
+ }
+
+ if (nZapWalletTxRet != DB_LOAD_OK)
+ return nZapWalletTxRet;
+
+ return DB_LOAD_OK;
+}
+
+
bool CWallet::SetAddressBook(const CTxDestination& address, const string& strName, const string& strPurpose)
{
AssertLockHeld(cs_wallet); // mapAddressBook