diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-09-01 10:58:08 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-09-01 10:58:08 -0400 |
commit | ed02c95d505ce48451b600ff40720841a000fd50 (patch) | |
tree | 939a9fa44b5c26550841f05320477970b3cc35c9 /src | |
parent | 123e5bd9982376b5feba8c32c67ff0286697a867 (diff) |
obtain cs_wallet mutex to protect vchDefaultKey
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index e861416e50..8bbb80cf25 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1280,20 +1280,23 @@ bool CWallet::GetKeyFromPool(vector<unsigned char>& result, bool fAllowReuse) { int64 nIndex = 0; CKeyPool keypool; - ReserveKeyFromKeyPool(nIndex, keypool); - if (nIndex == -1) + CRITICAL_BLOCK(cs_wallet) { - if (fAllowReuse && !vchDefaultKey.empty()) + ReserveKeyFromKeyPool(nIndex, keypool); + if (nIndex == -1) { - result = vchDefaultKey; + if (fAllowReuse && !vchDefaultKey.empty()) + { + result = vchDefaultKey; + return true; + } + if (IsLocked()) return false; + result = GenerateNewKey(); return true; } - if (IsLocked()) return false; - result = GenerateNewKey(); - return true; + KeepKey(nIndex); + result = keypool.vchPubKey; } - KeepKey(nIndex); - result = keypool.vchPubKey; return true; } |