aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-11-10 21:12:46 -0500
committerGavin Andresen <gavinandresen@gmail.com>2011-11-15 09:30:16 -0500
commitd764d9161e548c7fbf835b70eb9d5c75caa28ff5 (patch)
treed94d3cf42bee7df401ac44a9c6c0181981a416b0 /src/wallet.cpp
parent9e9869d0fe9c5cb38273a557e28b1922356d0e11 (diff)
Obsolete keypool and make sure database removes log files on shutdown.
Diffstat (limited to 'src/wallet.cpp')
-rw-r--r--src/wallet.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 3ed880f600..e3ca7d297d 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -187,10 +187,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;
}
@@ -1145,11 +1147,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)