aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-05-02 12:43:07 -0400
committerGavin Andresen <gavinandresen@gmail.com>2013-05-02 12:43:07 -0400
commit2f15e86a68aba56a8ea8e01e58b2fb7b71846b51 (patch)
tree62a394f718d3f7a910579b43bfd33dda1f706cd3
parenteef2091fe9ee39ecd8e874c91d3ab0ff023c5356 (diff)
Do not write to wallet during LoadWallet
When debugging another issue, I found a hang-during-startup race condition due to LoadWallet calling SetMinVersion (via LoadCryptedKey). Writing to the file that you're in the process of reading is a bad idea.
-rw-r--r--src/wallet.cpp5
-rw-r--r--src/wallet.h2
2 files changed, 6 insertions, 1 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index c7eb4f74e8..9658dab678 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -71,6 +71,11 @@ bool CWallet::AddCryptedKey(const CPubKey &vchPubKey, const vector<unsigned char
return false;
}
+bool CWallet::LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret)
+{
+ return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret);
+}
+
bool CWallet::AddCScript(const CScript& redeemScript)
{
if (!CCryptoKeyStore::AddCScript(redeemScript))
diff --git a/src/wallet.h b/src/wallet.h
index 2e007557b0..348f36a0e4 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -145,7 +145,7 @@ public:
// Adds an encrypted key to the store, and saves it to disk.
bool AddCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
// Adds an encrypted key to the store, without saving it to disk (used by LoadWallet)
- bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret) { SetMinVersion(FEATURE_WALLETCRYPT); return CCryptoKeyStore::AddCryptedKey(vchPubKey, vchCryptedSecret); }
+ bool LoadCryptedKey(const CPubKey &vchPubKey, const std::vector<unsigned char> &vchCryptedSecret);
bool AddCScript(const CScript& redeemScript);
bool LoadCScript(const CScript& redeemScript) { return CCryptoKeyStore::AddCScript(redeemScript); }