aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/scriptpubkeyman.cpp
diff options
context:
space:
mode:
authorAndrew Chow <achow101-github@achow101.com>2019-12-05 18:04:06 -0500
committerAndrew Chow <achow101-github@achow101.com>2019-12-06 15:05:48 -0500
commit35f962fcf0d5107ae6a3a9348e249a9b18ff7106 (patch)
tree07a5aa9b2a252fd5febc14115682e3f7b1eccb0a /src/wallet/scriptpubkeyman.cpp
parent14b5efd66ff0afbf3bf9158a724534a9090fc7fc (diff)
downloadbitcoin-35f962fcf0d5107ae6a3a9348e249a9b18ff7106.tar.xz
Clear mapKeys before encrypting
Does not change behavior. Needed to make AddCryptedKeyInner() work with SetCrypted() being gone.
Diffstat (limited to 'src/wallet/scriptpubkeyman.cpp')
-rw-r--r--src/wallet/scriptpubkeyman.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/wallet/scriptpubkeyman.cpp b/src/wallet/scriptpubkeyman.cpp
index 8a3f36c2e2..acf3ed2e2b 100644
--- a/src/wallet/scriptpubkeyman.cpp
+++ b/src/wallet/scriptpubkeyman.cpp
@@ -245,7 +245,9 @@ bool LegacyScriptPubKeyMan::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
return false;
fUseCrypto = true;
- for (const KeyMap::value_type& mKey : mapKeys)
+ KeyMap keys_to_encrypt;
+ keys_to_encrypt.swap(mapKeys); // Clear mapKeys so AddCryptedKeyInner will succeed.
+ for (const KeyMap::value_type& mKey : keys_to_encrypt)
{
const CKey &key = mKey.second;
CPubKey vchPubKey = key.GetPubKey();
@@ -256,7 +258,6 @@ bool LegacyScriptPubKeyMan::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
if (!AddCryptedKey(vchPubKey, vchCryptedSecret))
return false;
}
- mapKeys.clear();
return true;
}