mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 04:22:55 +01:00
fix: CheckWalletOwnsScript/CheckWalletOwnsKey to use wallet instead of SPK
This commit is contained in:
parent
b2ede8bfee
commit
a33dcb3283
@ -1264,33 +1264,15 @@ static void protx_list_help(const JSONRPCRequest& request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
static bool CheckWalletOwnsKey(const CWallet* const pwallet, const CKeyID& keyID) {
|
|
||||||
if (!pwallet) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
const LegacyScriptPubKeyMan* const spk_man = pwallet->GetLegacyScriptPubKeyMan();
|
|
||||||
if (!spk_man) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return spk_man->HaveKey(keyID);
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool CheckWalletOwnsScript(const CWallet* const pwallet, const CScript& script) {
|
static bool CheckWalletOwnsScript(const CWallet* const pwallet, const CScript& script) {
|
||||||
if (!pwallet) {
|
if (!pwallet) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const LegacyScriptPubKeyMan* const spk_man = pwallet->GetLegacyScriptPubKeyMan();
|
return WITH_LOCK(pwallet->cs_wallet, return pwallet->IsMine(script)) == isminetype::ISMINE_SPENDABLE;
|
||||||
if (!spk_man) {
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
CTxDestination dest;
|
static bool CheckWalletOwnsKey(const CWallet* const pwallet, const CKeyID& keyID) {
|
||||||
if (ExtractDestination(script, dest)) {
|
return CheckWalletOwnsScript(pwallet, GetScriptForDestination(PKHash(keyID)));
|
||||||
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))}))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user