aboutsummaryrefslogtreecommitdiff
path: root/src/script/interpreter.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-09-10 14:42:22 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-10-02 20:26:16 +0200
commitc7829ea797c840dda7888ee860a50b7a3308069d (patch)
tree55eafd1b6fef2ba1a5d3aa1aec9e0c6165091893 /src/script/interpreter.h
parent6faee7942671141649b74e50908cb99cabc840e5 (diff)
Abstract out SignatureChecker
Diffstat (limited to 'src/script/interpreter.h')
-rw-r--r--src/script/interpreter.h28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index adca2142ac..f3fd49a3b6 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -38,8 +38,30 @@ bool IsCanonicalPubKey(const std::vector<unsigned char> &vchPubKey, unsigned int
bool IsCanonicalSignature(const std::vector<unsigned char> &vchSig, unsigned int flags);
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
-bool CheckSig(std::vector<unsigned char> vchSig, const std::vector<unsigned char> &vchPubKey, const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int flags);
-bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags);
-bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags);
+
+class SignatureChecker
+{
+private:
+ const CTransaction& txTo;
+ unsigned int nIn;
+
+public:
+ SignatureChecker(const CTransaction& txToIn, unsigned int nInIn) : txTo(txToIn), nIn(nInIn) {}
+ bool CheckSig(const std::vector<unsigned char>& scriptSig, const std::vector<unsigned char>& vchPubKey, const CScript& scriptCode, int nFlags) const;
+};
+
+bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, unsigned int flags, const SignatureChecker& checker);
+bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigned int flags, const SignatureChecker& checker);
+
+// Wrappers using a default SignatureChecker.
+bool inline EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript& script, const CTransaction& txTo, unsigned int nIn, unsigned int flags)
+{
+ return EvalScript(stack, script, flags, SignatureChecker(txTo, nIn));
+}
+
+bool inline VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, const CTransaction& txTo, unsigned int nIn, unsigned int flags)
+{
+ return VerifyScript(scriptSig, scriptPubKey, flags, SignatureChecker(txTo, nIn));
+}
#endif // H_BITCOIN_SCRIPT_INTERPRETER