aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-08-21 14:06:49 -0400
committerAva Chow <github@achow101.com>2024-08-21 14:06:49 -0400
commit17707db939cb09a16c002d226152e71fce9289f2 (patch)
tree0b80958fcf714dfcea1d87137bd82dd7d3b6f4a4
parentbc87ad98543299e1990ee1994d0653df3ac70093 (diff)
Fix maybe-uninitialized warning in IsSpentKey
-rw-r--r--src/wallet/wallet.cpp29
1 files changed, 14 insertions, 15 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 5584b43520..8df39b9f75 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -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;