Skip to content

Commit

Permalink
Fix maybe-uninitialized warning in IsSpentKey
Browse files Browse the repository at this point in the history
  • Loading branch information
achow101 committed Aug 21, 2024
1 parent bc87ad9 commit 17707db
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1039,21 +1039,20 @@ bool CWallet::IsSpentKey(const CScript& scriptPubKey) const
return true;
}

LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan();
if (!spk_man) return false;

for (const auto& keyid : GetAffectedKeys(scriptPubKey, *spk_man)) {
WitnessV0KeyHash wpkh_dest(keyid);
if (IsAddressPreviouslySpent(wpkh_dest)) {
return true;
}
ScriptHash sh_wpkh_dest(GetScriptForDestination(wpkh_dest));
if (IsAddressPreviouslySpent(sh_wpkh_dest)) {
return true;
}
PKHash pkh_dest(keyid);
if (IsAddressPreviouslySpent(pkh_dest)) {
return true;
if (LegacyScriptPubKeyMan* spk_man = GetLegacyScriptPubKeyMan()) {
for (const auto& keyid : GetAffectedKeys(scriptPubKey, *spk_man)) {
WitnessV0KeyHash wpkh_dest(keyid);
if (IsAddressPreviouslySpent(wpkh_dest)) {
return true;
}
ScriptHash sh_wpkh_dest(GetScriptForDestination(wpkh_dest));
if (IsAddressPreviouslySpent(sh_wpkh_dest)) {
return true;
}
PKHash pkh_dest(keyid);
if (IsAddressPreviouslySpent(pkh_dest)) {
return true;
}
}
}
return false;
Expand Down

0 comments on commit 17707db

Please sign in to comment.