diff options
| author | Jeff Garzik <[email protected]> | 2014-02-14 12:21:38 -0500 |
|---|---|---|
| committer | Jeff Garzik <[email protected]> | 2014-02-14 12:21:38 -0500 |
| commit | e051e65c219cc72a2bba768f3d5e043ad055b48e (patch) | |
| tree | 48112962ac208f307e93f3f13bec67ee4431bf07 /src/wallet.cpp | |
| parent | Merge pull request #3667 from gavinandresen/rpctest_osxcompat (diff) | |
| parent | Add -zapwallettxes cli/config option, used for wallet recovery (diff) | |
| download | discoin-e051e65c219cc72a2bba768f3d5e043ad055b48e.tar.xz discoin-e051e65c219cc72a2bba768f3d5e043ad055b48e.zip | |
Merge pull request #3659 from jgarzik/zapall
Add -zapwallettx function, a diagnostic tool to assist in wallet repair
Diffstat (limited to 'src/wallet.cpp')
| -rw-r--r-- | src/wallet.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index e3c460ff3..1ba70c116 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 |