Fix maybe-uninitialized warning in IsSpentKey

This commit is contained in:
Ava Chow 2024-08-21 14:06:49 -04:00
parent bc87ad9854
commit 17707db939

View file

@ -1039,9 +1039,7 @@ bool CWallet::IsSpentKey(const CScript& scriptPubKey) const
return true; return true;
} }
LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan(); if (LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan()) {
if (!spk_man) return false;
for (const auto& keyid : GetAffectedKeys(scriptPubKey, *spk_man)) { for (const auto& keyid : GetAffectedKeys(scriptPubKey, *spk_man)) {
WitnessV0KeyHash wpkh_dest(keyid); WitnessV0KeyHash wpkh_dest(keyid);
if (IsAddressPreviouslySpent(wpkh_dest)) { if (IsAddressPreviouslySpent(wpkh_dest)) {
@ -1056,6 +1054,7 @@ bool CWallet::IsSpentKey(const CScript& scriptPubKey) const
return true; return true;
} }
} }
}
return false; return false;
} }