diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-11-10 21:12:46 -0500 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2011-11-15 10:11:53 -0500 |
commit | 2744ea8c1fbc2e1ef6b1824a21fd2a75e2b6dbc4 (patch) | |
tree | 215ae7f0e925c829d90e777d9aa452dfbc15f57f /src/wallet.cpp | |
parent | 00eae584a26295dbf7b1aebf99c1b8a4c9a86c37 (diff) | |
download | bitcoin-2744ea8c1fbc2e1ef6b1824a21fd2a75e2b6dbc4.tar.xz |
Obsolete keypool and make sure database removes log files on shutdown.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r-- | src/wallet.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index 924700d027..c004d18360 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -188,10 +188,12 @@ bool CWallet::EncryptWallet(const string& strWalletPassphrase) } Lock(); - } - if (Resilver(strWalletFile)) - CWalletDB(strWalletFile, "r+").WriteSetting("fIsResilvered", true); + // Need to completely rewrite the wallet file; if we don't, bdb might keep + // bits of the unencrypted private key in slack space in the database file. + setKeyPool.clear(); + CDB::Rewrite(strWalletFile, "\x04pool"); + } return true; } @@ -1125,11 +1127,16 @@ int CWallet::LoadWallet(bool& fFirstRunRet) return false; fFirstRunRet = false; int nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this); - if (nLoadWalletRet == DB_NEED_RESILVER) + if (nLoadWalletRet == DB_NEED_REWRITE) { - if (Resilver(strWalletFile)) - CWalletDB(strWalletFile, "r+").WriteSetting("fIsResilvered", true); - nLoadWalletRet = DB_LOAD_OK; + if (CDB::Rewrite(strWalletFile, "\x04pool")) + { + 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. + } + nLoadWalletRet = DB_NEED_REWRITE; } if (nLoadWalletRet != DB_LOAD_OK) |