aboutsummaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-10-08 16:29:45 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2014-10-25 03:03:16 -0700
commitd752ba86c1872f64a4641cf77008826d32bde65f (patch)
tree07728ee7eee5a8dacc3d31496ef4b9b204f9f06e /src/script
parent65e4e8427d900b27f579dc12af6c74b3ec628286 (diff)
downloadbitcoin-d752ba86c1872f64a4641cf77008826d32bde65f.tar.xz
Add SCRIPT_VERIFY_SIGPUSHONLY (BIP62 rule 2)
Diffstat (limited to 'src/script')
-rw-r--r--src/script/interpreter.cpp4
-rw-r--r--src/script/interpreter.h3
-rw-r--r--src/script/script.cpp2
-rw-r--r--src/script/script.h2
4 files changed, 9 insertions, 2 deletions
diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp
index cd73b88210..e463de8cc2 100644
--- a/src/script/interpreter.cpp
+++ b/src/script/interpreter.cpp
@@ -980,6 +980,10 @@ bool SignatureChecker::CheckSig(const vector<unsigned char>& vchSigIn, const vec
bool VerifyScript(const CScript& scriptSig, const CScript& scriptPubKey, unsigned int flags, const BaseSignatureChecker& checker)
{
+ if ((flags & SCRIPT_VERIFY_SIGPUSHONLY) != 0 && !scriptSig.IsPushOnly()) {
+ return false;
+ }
+
vector<vector<unsigned char> > stack, stackCopy;
if (!EvalScript(stack, scriptSig, flags, checker))
return false;
diff --git a/src/script/interpreter.h b/src/script/interpreter.h
index de5ce2ced1..085cd867da 100644
--- a/src/script/interpreter.h
+++ b/src/script/interpreter.h
@@ -46,6 +46,9 @@ enum
// verify dummy stack item consumed by CHECKMULTISIG is of zero-length (softfork safe, BIP62 rule 7).
SCRIPT_VERIFY_NULLDUMMY = (1U << 4),
+
+ // Using a non-push operator in the scriptSig causes script failure (softfork safe, BIP62 rule 2).
+ SCRIPT_VERIFY_SIGPUSHONLY = (1U << 5),
};
uint256 SignatureHash(const CScript &scriptCode, const CTransaction& txTo, unsigned int nIn, int nHashType);
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 3e19d0c2bf..bbcfe9dfdd 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -230,7 +230,7 @@ bool CScript::IsPushOnly() const
return false;
// Note that IsPushOnly() *does* consider OP_RESERVED to be a
// push-type opcode, however execution of OP_RESERVED fails, so
- // it's not relevant to P2SH as the scriptSig would fail prior to
+ // it's not relevant to P2SH/BIP62 as the scriptSig would fail prior to
// the P2SH special validation code being executed.
if (opcode > OP_16)
return false;
diff --git a/src/script/script.h b/src/script/script.h
index d450db5cad..706a85a29b 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -551,7 +551,7 @@ public:
bool IsPayToScriptHash() const;
- // Called by IsStandardTx and P2SH VerifyScript (which makes it consensus-critical).
+ // Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).
bool IsPushOnly() const;
// Called by IsStandardTx.