Switch to a private version of SigVersion inside IsMine
This will allow us to have the consensus code and IsMine code diverge.
This commit is contained in:
parent
19fc973097
commit
ac6ec62522
1 changed files with 14 additions and 8 deletions
|
@ -13,6 +13,12 @@
|
||||||
|
|
||||||
typedef std::vector<unsigned char> valtype;
|
typedef std::vector<unsigned char> valtype;
|
||||||
|
|
||||||
|
enum class IsMineSigVersion
|
||||||
|
{
|
||||||
|
BASE = 0,
|
||||||
|
WITNESS_V0 = 1
|
||||||
|
};
|
||||||
|
|
||||||
static bool HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keystore)
|
static bool HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keystore)
|
||||||
{
|
{
|
||||||
for (const valtype& pubkey : pubkeys) {
|
for (const valtype& pubkey : pubkeys) {
|
||||||
|
@ -22,7 +28,7 @@ static bool HaveKeys(const std::vector<valtype>& pubkeys, const CKeyStore& keyst
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid, SigVersion sigversion)
|
static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid, IsMineSigVersion sigversion)
|
||||||
{
|
{
|
||||||
isInvalid = false;
|
isInvalid = false;
|
||||||
|
|
||||||
|
@ -43,7 +49,7 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
|
||||||
break;
|
break;
|
||||||
case TX_PUBKEY:
|
case TX_PUBKEY:
|
||||||
keyID = CPubKey(vSolutions[0]).GetID();
|
keyID = CPubKey(vSolutions[0]).GetID();
|
||||||
if (sigversion != SigVersion::BASE && vSolutions[0].size() != 33) {
|
if (sigversion != IsMineSigVersion::BASE && vSolutions[0].size() != 33) {
|
||||||
isInvalid = true;
|
isInvalid = true;
|
||||||
return ISMINE_NO;
|
return ISMINE_NO;
|
||||||
}
|
}
|
||||||
|
@ -58,14 +64,14 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
|
||||||
// This also applies to the P2WSH case.
|
// This also applies to the P2WSH case.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
isminetype ret = IsMineInner(keystore, GetScriptForDestination(CKeyID(uint160(vSolutions[0]))), isInvalid, SigVersion::WITNESS_V0);
|
isminetype ret = IsMineInner(keystore, GetScriptForDestination(CKeyID(uint160(vSolutions[0]))), isInvalid, IsMineSigVersion::WITNESS_V0);
|
||||||
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
||||||
return ret;
|
return ret;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TX_PUBKEYHASH:
|
case TX_PUBKEYHASH:
|
||||||
keyID = CKeyID(uint160(vSolutions[0]));
|
keyID = CKeyID(uint160(vSolutions[0]));
|
||||||
if (sigversion != SigVersion::BASE) {
|
if (sigversion != IsMineSigVersion::BASE) {
|
||||||
CPubKey pubkey;
|
CPubKey pubkey;
|
||||||
if (keystore.GetPubKey(keyID, pubkey) && !pubkey.IsCompressed()) {
|
if (keystore.GetPubKey(keyID, pubkey) && !pubkey.IsCompressed()) {
|
||||||
isInvalid = true;
|
isInvalid = true;
|
||||||
|
@ -80,7 +86,7 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
|
||||||
CScriptID scriptID = CScriptID(uint160(vSolutions[0]));
|
CScriptID scriptID = CScriptID(uint160(vSolutions[0]));
|
||||||
CScript subscript;
|
CScript subscript;
|
||||||
if (keystore.GetCScript(scriptID, subscript)) {
|
if (keystore.GetCScript(scriptID, subscript)) {
|
||||||
isminetype ret = IsMineInner(keystore, subscript, isInvalid, SigVersion::BASE);
|
isminetype ret = IsMineInner(keystore, subscript, isInvalid, IsMineSigVersion::BASE);
|
||||||
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +102,7 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
|
||||||
CScriptID scriptID = CScriptID(hash);
|
CScriptID scriptID = CScriptID(hash);
|
||||||
CScript subscript;
|
CScript subscript;
|
||||||
if (keystore.GetCScript(scriptID, subscript)) {
|
if (keystore.GetCScript(scriptID, subscript)) {
|
||||||
isminetype ret = IsMineInner(keystore, subscript, isInvalid, SigVersion::WITNESS_V0);
|
isminetype ret = IsMineInner(keystore, subscript, isInvalid, IsMineSigVersion::WITNESS_V0);
|
||||||
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -111,7 +117,7 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
|
||||||
// them) enable spend-out-from-under-you attacks, especially
|
// them) enable spend-out-from-under-you attacks, especially
|
||||||
// in shared-wallet situations.
|
// in shared-wallet situations.
|
||||||
std::vector<valtype> keys(vSolutions.begin()+1, vSolutions.begin()+vSolutions.size()-1);
|
std::vector<valtype> keys(vSolutions.begin()+1, vSolutions.begin()+vSolutions.size()-1);
|
||||||
if (sigversion != SigVersion::BASE) {
|
if (sigversion != IsMineSigVersion::BASE) {
|
||||||
for (size_t i = 0; i < keys.size(); i++) {
|
for (size_t i = 0; i < keys.size(); i++) {
|
||||||
if (keys[i].size() != 33) {
|
if (keys[i].size() != 33) {
|
||||||
isInvalid = true;
|
isInvalid = true;
|
||||||
|
@ -135,7 +141,7 @@ static isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPu
|
||||||
|
|
||||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid)
|
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey, bool& isInvalid)
|
||||||
{
|
{
|
||||||
return IsMineInner(keystore, scriptPubKey, isInvalid, SigVersion::BASE);
|
return IsMineInner(keystore, scriptPubKey, isInvalid, IsMineSigVersion::BASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey)
|
isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey)
|
||||||
|
|
Loading…
Reference in a new issue