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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user