Do not expose SigVersion argument to IsMine
Only IsMine's internal code needs this, as part of a recursion into P2SH and P2WSH scripts. The exposed functions always operate on actual scriptPubKeys and not on redeemScripts or witness scripts.
This commit is contained in:
parent
fb1dfbbec0
commit
19fc973097
2 changed files with 24 additions and 19 deletions
|
@ -22,19 +22,7 @@ static bool HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keyst
|
|||
return true;
|
||||
}
|
||||
|
||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, SigVersion sigversion)
|
||||
{
|
||||
bool isInvalid = false;
|
||||
return IsMine(keystore, scriptPubKey, isInvalid, sigversion);
|
||||
}
|
||||
|
||||
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest, SigVersion sigversion)
|
||||
{
|
||||
CScript script = GetScriptForDestination(dest);
|
||||
return IsMine(keystore, script, sigversion);
|
||||
}
|
||||
|
||||
isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool& isInvalid, SigVersion sigversion)
|
||||
static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid, SigVersion sigversion)
|
||||
{
|
||||
isInvalid = false;
|
||||
|
||||
|
@ -70,7 +58,7 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool&
|
|||
// This also applies to the P2WSH case.
|
||||
break;
|
||||
}
|
||||
isminetype ret = ::IsMine(keystore, GetScriptForDestination(CKeyID(uint160(vSolutions[0]))), isInvalid, SigVersion::WITNESS_V0);
|
||||
isminetype ret = IsMineInner(keystore, GetScriptForDestination(CKeyID(uint160(vSolutions[0]))), isInvalid, SigVersion::WITNESS_V0);
|
||||
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
||||
return ret;
|
||||
break;
|
||||
|
@ -92,7 +80,7 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool&
|
|||
CScriptID scriptID = CScriptID(uint160(vSolutions[0]));
|
||||
CScript subscript;
|
||||
if (keystore.GetCScript(scriptID, subscript)) {
|
||||
isminetype ret = IsMine(keystore, subscript, isInvalid);
|
||||
isminetype ret = IsMineInner(keystore, subscript, isInvalid, SigVersion::BASE);
|
||||
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
||||
return ret;
|
||||
}
|
||||
|
@ -108,7 +96,7 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool&
|
|||
CScriptID scriptID = CScriptID(hash);
|
||||
CScript subscript;
|
||||
if (keystore.GetCScript(scriptID, subscript)) {
|
||||
isminetype ret = IsMine(keystore, subscript, isInvalid, SigVersion::WITNESS_V0);
|
||||
isminetype ret = IsMineInner(keystore, subscript, isInvalid, SigVersion::WITNESS_V0);
|
||||
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
||||
return ret;
|
||||
}
|
||||
|
@ -144,3 +132,20 @@ isminetype IsMine(const CKeyStore &keystore, const CScript& scriptPubKey, bool&
|
|||
}
|
||||
return ISMINE_NO;
|
||||
}
|
||||
|
||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid)
|
||||
{
|
||||
return IsMineInner(keystore, scriptPubKey, isInvalid, SigVersion::BASE);
|
||||
}
|
||||
|
||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey)
|
||||
{
|
||||
bool isInvalid = false;
|
||||
return IsMine(keystore, scriptPubKey, isInvalid);
|
||||
}
|
||||
|
||||
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest)
|
||||
{
|
||||
CScript script = GetScriptForDestination(dest);
|
||||
return IsMine(keystore, script);
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ typedef uint8_t isminefilter;
|
|||
* different SIGVERSION may have different network rules. Currently the only use of isInvalid is indicate uncompressed
|
||||
* keys in SigVersion::WITNESS_V0 script, but could also be used in similar cases in the future
|
||||
*/
|
||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid, SigVersion = SigVersion::BASE);
|
||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, SigVersion = SigVersion::BASE);
|
||||
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest, SigVersion = SigVersion::BASE);
|
||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid);
|
||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey);
|
||||
isminetype IsMine(const CKeyStore& keystore, const CTxDestination& dest);
|
||||
|
||||
#endif // BITCOIN_SCRIPT_ISMINE_H
|
||||
|
|
Loading…
Reference in a new issue