Skip to content

Commit a33dcb3

Browse files
committed
fix: CheckWalletOwnsScript/CheckWalletOwnsKey to use wallet instead of SPK
1 parent b2ede8b commit a33dcb3

File tree

1 file changed

+4
-22
lines changed

1 file changed

+4
-22
lines changed

src/rpc/evo.cpp

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1264,33 +1264,15 @@ static void protx_list_help(const JSONRPCRequest& request)
12641264
}
12651265

12661266
#ifdef ENABLE_WALLET
1267-
static bool CheckWalletOwnsKey(const CWallet* const pwallet, const CKeyID& keyID) {
1268-
if (!pwallet) {
1269-
return false;
1270-
}
1271-
const LegacyScriptPubKeyMan* const spk_man = pwallet->GetLegacyScriptPubKeyMan();
1272-
if (!spk_man) {
1273-
return false;
1274-
}
1275-
return spk_man->HaveKey(keyID);
1276-
}
1277-
12781267
static bool CheckWalletOwnsScript(const CWallet* const pwallet, const CScript& script) {
12791268
if (!pwallet) {
12801269
return false;
12811270
}
1282-
const LegacyScriptPubKeyMan* const spk_man = pwallet->GetLegacyScriptPubKeyMan();
1283-
if (!spk_man) {
1284-
return false;
1285-
}
1271+
return WITH_LOCK(pwallet->cs_wallet, return pwallet->IsMine(script)) == isminetype::ISMINE_SPENDABLE;
1272+
}
12861273

1287-
CTxDestination dest;
1288-
if (ExtractDestination(script, dest)) {
1289-
if ((std::get_if<PKHash>(&dest) && spk_man->HaveKey(ToKeyID(*std::get_if<PKHash>(&dest)))) || (std::get_if<ScriptHash>(&dest) && spk_man->HaveCScript(CScriptID{ScriptHash(*std::get_if<ScriptHash>(&dest))}))) {
1290-
return true;
1291-
}
1292-
}
1293-
return false;
1274+
static bool CheckWalletOwnsKey(const CWallet* const pwallet, const CKeyID& keyID) {
1275+
return CheckWalletOwnsScript(pwallet, GetScriptForDestination(PKHash(keyID)));
12941276
}
12951277
#endif
12961278

0 commit comments

Comments
 (0)