aboutsummaryrefslogtreecommitdiff
path: root/src/script.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script.cpp')
-rw-r--r--src/script.cpp36
1 files changed, 34 insertions, 2 deletions
diff --git a/src/script.cpp b/src/script.cpp
index c17525034a..13a53d6b9c 100644
--- a/src/script.cpp
+++ b/src/script.cpp
@@ -1089,8 +1089,40 @@ bool IsStandard(const CScript& scriptPubKey)
bool IsMine(const CKeyStore &keystore, const CScript& scriptPubKey)
{
- CScript scriptSig;
- return Solver(keystore, scriptPubKey, 0, 0, scriptSig);
+ vector<pair<opcodetype, valtype> > vSolution;
+ if (!Solver(scriptPubKey, vSolution))
+ return false;
+
+ // Compile solution
+ CRITICAL_BLOCK(keystore.cs_KeyStore)
+ {
+ BOOST_FOREACH(PAIRTYPE(opcodetype, valtype)& item, vSolution)
+ {
+ if (item.first == OP_PUBKEY)
+ {
+ // Sign
+ const valtype& vchPubKey = item.second;
+ if (!keystore.HaveKey(vchPubKey))
+ return false;
+ }
+ else if (item.first == OP_PUBKEYHASH)
+ {
+ // Sign and give pubkey
+ map<uint160, valtype>::iterator mi = mapPubKeys.find(uint160(item.second));
+ if (mi == mapPubKeys.end())
+ return false;
+ const vector<unsigned char>& vchPubKey = (*mi).second;
+ if (!keystore.HaveKey(vchPubKey))
+ return false;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+
+ return true;
}