Skip to content

Commit

Permalink
Make IsMine stop distinguishing solvable/unsolvable
Browse files Browse the repository at this point in the history
Modified version of btc@4e91820531889e309dc4335fe0de8229c6426040
  • Loading branch information
furszy committed Aug 8, 2020
1 parent e541593 commit 8f2a156
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
9 changes: 4 additions & 5 deletions src/script/ismine.cpp
Expand Up @@ -39,8 +39,9 @@ isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey)
std::vector<valtype> vSolutions;
txnouttype whichType;
if(!Solver(scriptPubKey, whichType, vSolutions)) {
if(keystore.HaveWatchOnly(scriptPubKey))
return ISMINE_WATCH_UNSOLVABLE;
if(keystore.HaveWatchOnly(scriptPubKey)) {
return ISMINE_WATCH_ONLY;
}

return ISMINE_NO;
}
Expand Down Expand Up @@ -99,9 +100,7 @@ isminetype IsMine(const CKeyStore& keystore, const CScript& scriptPubKey)
}

if (keystore.HaveWatchOnly(scriptPubKey)) {
// TODO: This could be optimized some by doing some work after the above solver
SignatureData sigdata;
return ProduceSignature(DummySignatureCreator(&keystore), scriptPubKey, sigdata, false) ? ISMINE_WATCH_SOLVABLE : ISMINE_WATCH_UNSOLVABLE;
return ISMINE_WATCH_ONLY;
}

return ISMINE_NO;
Expand Down
12 changes: 4 additions & 8 deletions src/script/ismine.h
Expand Up @@ -16,16 +16,12 @@ class CScript;
/** IsMine() return codes */
enum isminetype {
ISMINE_NO = 0,
//! Indicates that we dont know how to create a scriptSig that would solve this if we were given the appropriate private keys
ISMINE_WATCH_UNSOLVABLE = 1,
//! Indicates that we know how to create a scriptSig that would solve this if we were given the appropriate private keys
ISMINE_WATCH_SOLVABLE = 2,
ISMINE_WATCH_ONLY = ISMINE_WATCH_SOLVABLE | ISMINE_WATCH_UNSOLVABLE,
ISMINE_SPENDABLE = 4,
ISMINE_WATCH_ONLY = 1,
ISMINE_SPENDABLE = 2,
//! Indicates that we have the staking key of a P2CS
ISMINE_COLD = 8,
ISMINE_COLD = 4,
//! Indicates that we have the spending key of a P2CS
ISMINE_SPENDABLE_DELEGATED = 16,
ISMINE_SPENDABLE_DELEGATED = 8,
ISMINE_SPENDABLE_ALL = ISMINE_SPENDABLE_DELEGATED | ISMINE_SPENDABLE,
ISMINE_SPENDABLE_STAKEABLE = ISMINE_SPENDABLE_DELEGATED | ISMINE_COLD,
ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE | ISMINE_COLD | ISMINE_SPENDABLE_DELEGATED
Expand Down

0 comments on commit 8f2a156

Please sign in to comment.