Skip to content

Commit 4e91820

Browse files
committed
Make IsMine stop distinguishing solvable/unsolvable
1 parent 6d714c3 commit 4e91820

File tree

2 files changed

+14
-16
lines changed

2 files changed

+14
-16
lines changed

src/script/ismine.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, b
4949
std::vector<valtype> vSolutions;
5050
txnouttype whichType;
5151
if (!Solver(scriptPubKey, whichType, vSolutions)) {
52-
if (keystore.HaveWatchOnly(scriptPubKey))
53-
return ISMINE_WATCH_UNSOLVABLE;
54-
return ISMINE_NO;
52+
if (keystore.HaveWatchOnly(scriptPubKey)) {
53+
return ISMINE_WATCH_ONLY;
54+
}
5555
}
5656

5757
CKeyID keyID;
@@ -79,8 +79,9 @@ isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, b
7979
break;
8080
}
8181
isminetype ret = IsMineInner(keystore, GetScriptForDestination(CKeyID(uint160(vSolutions[0]))), isInvalid, IsMineSigVersion::WITNESS_V0);
82-
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
82+
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_ONLY || (ret == ISMINE_NO && isInvalid)) {
8383
return ret;
84+
}
8485
break;
8586
}
8687
case TX_PUBKEYHASH:
@@ -101,8 +102,9 @@ isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, b
101102
CScript subscript;
102103
if (keystore.GetCScript(scriptID, subscript)) {
103104
isminetype ret = IsMineInner(keystore, subscript, isInvalid, IsMineSigVersion::P2SH);
104-
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
105+
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_ONLY || (ret == ISMINE_NO && isInvalid)) {
105106
return ret;
107+
}
106108
}
107109
break;
108110
}
@@ -117,8 +119,9 @@ isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, b
117119
CScript subscript;
118120
if (keystore.GetCScript(scriptID, subscript)) {
119121
isminetype ret = IsMineInner(keystore, subscript, isInvalid, IsMineSigVersion::WITNESS_V0);
120-
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_SOLVABLE || (ret == ISMINE_NO && isInvalid))
122+
if (ret == ISMINE_SPENDABLE || ret == ISMINE_WATCH_ONLY || (ret == ISMINE_NO && isInvalid)) {
121123
return ret;
124+
}
122125
}
123126
break;
124127
}
@@ -142,16 +145,15 @@ isminetype IsMineInner(const CKeyStore& keystore, const CScript& scriptPubKey, b
142145
}
143146
}
144147
}
145-
if (HaveKeys(keys, keystore))
148+
if (HaveKeys(keys, keystore)) {
146149
return ISMINE_SPENDABLE;
150+
}
147151
break;
148152
}
149153
}
150154

151155
if (keystore.HaveWatchOnly(scriptPubKey)) {
152-
// TODO: This could be optimized some by doing some work after the above solver
153-
SignatureData sigs;
154-
return ProduceSignature(keystore, DUMMY_SIGNATURE_CREATOR, scriptPubKey, sigs) ? ISMINE_WATCH_SOLVABLE : ISMINE_WATCH_UNSOLVABLE;
156+
return ISMINE_WATCH_ONLY;
155157
}
156158
return ISMINE_NO;
157159
}

src/script/ismine.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,8 @@ class CScript;
1717
enum isminetype
1818
{
1919
ISMINE_NO = 0,
20-
//! Indicates that we don't know how to create a scriptSig that would solve this if we were given the appropriate private keys
21-
ISMINE_WATCH_UNSOLVABLE = 1,
22-
//! Indicates that we know how to create a scriptSig that would solve this if we were given the appropriate private keys
23-
ISMINE_WATCH_SOLVABLE = 2,
24-
ISMINE_WATCH_ONLY = ISMINE_WATCH_SOLVABLE | ISMINE_WATCH_UNSOLVABLE,
25-
ISMINE_SPENDABLE = 4,
20+
ISMINE_WATCH_ONLY = 1,
21+
ISMINE_SPENDABLE = 2,
2622
ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE
2723
};
2824
/** used for bitflags of isminetype */

0 commit comments

Comments
 (0)