Skip to content

Commit b945a31

Browse files
committed
wallet: erase spkmans rather than setting to nullptr
In many places in ScriptPubKeyMan managing code, we assume that the ScriptPubKeyMan being retrieved actually exists and is not a nullptr. Thus removing a ScriptPubKeyMan requires erasing the object from the map rather than setting it to a nullptr.
1 parent 5a95c51 commit b945a31

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,7 +3184,7 @@ void CWallet::LoadActiveScriptPubKeyMan(uint256 id, OutputType type, bool intern
31843184
spk_mans[type] = spk_man;
31853185

31863186
if (spk_mans_other[type] == spk_man) {
3187-
spk_mans_other[type] = nullptr;
3187+
spk_mans_other.erase(type);
31883188
}
31893189

31903190
NotifyCanGetAddressesChanged();
@@ -3201,7 +3201,7 @@ void CWallet::DeactivateScriptPubKeyMan(uint256 id, OutputType type, bool intern
32013201
}
32023202

32033203
auto& spk_mans = internal ? m_internal_spk_managers : m_external_spk_managers;
3204-
spk_mans[type] = nullptr;
3204+
spk_mans.erase(type);
32053205
}
32063206

32073207
NotifyCanGetAddressesChanged();

0 commit comments

Comments
 (0)