Skip to content

Commit 35f962f

Browse files
committed
Clear mapKeys before encrypting
Does not change behavior. Needed to make AddCryptedKeyInner() work with SetCrypted() being gone.
1 parent 14b5efd commit 35f962f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/wallet/scriptpubkeyman.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,9 @@ bool LegacyScriptPubKeyMan::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
245245
return false;
246246

247247
fUseCrypto = true;
248-
for (const KeyMap::value_type& mKey : mapKeys)
248+
KeyMap keys_to_encrypt;
249+
keys_to_encrypt.swap(mapKeys); // Clear mapKeys so AddCryptedKeyInner will succeed.
250+
for (const KeyMap::value_type& mKey : keys_to_encrypt)
249251
{
250252
const CKey &key = mKey.second;
251253
CPubKey vchPubKey = key.GetPubKey();
@@ -256,7 +258,6 @@ bool LegacyScriptPubKeyMan::EncryptKeys(CKeyingMaterial& vMasterKeyIn)
256258
if (!AddCryptedKey(vchPubKey, vchCryptedSecret))
257259
return false;
258260
}
259-
mapKeys.clear();
260261
return true;
261262
}
262263

0 commit comments

Comments
 (0)