aboutsummaryrefslogtreecommitdiff
path: root/src/script/script.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-10-08 18:48:59 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2014-10-25 03:03:20 -0700
commit698c6abb25c1fbbc7fa4ba46b60e9f17d97332ef (patch)
tree96e1a25fa76033be494f9760be03872e5ba554eb /src/script/script.h
parentd752ba86c1872f64a4641cf77008826d32bde65f (diff)
downloadbitcoin-698c6abb25c1fbbc7fa4ba46b60e9f17d97332ef.tar.xz
Add SCRIPT_VERIFY_MINIMALDATA (BIP62 rules 3 and 4)
Also use the new flag as a standard rule, and replace the IsCanonicalPush standardness check with it (as it is more complete).
Diffstat (limited to 'src/script/script.h')
-rw-r--r--src/script/script.h18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/script/script.h b/src/script/script.h
index 706a85a29b..e97967dcea 100644
--- a/src/script/script.h
+++ b/src/script/script.h
@@ -192,10 +192,14 @@ public:
m_value = n;
}
- explicit CScriptNum(const std::vector<unsigned char>& vch)
+ explicit CScriptNum(const std::vector<unsigned char>& vch, bool fRequireMinimal)
{
- if (vch.size() > nMaxNumSize)
- throw scriptnum_error("CScriptNum(const std::vector<unsigned char>&) : overflow");
+ if (vch.size() > nMaxNumSize) {
+ throw scriptnum_error("script number overflow");
+ }
+ if (fRequireMinimal && vch.size() > 0 && (vch.back() & 0x7f) == 0 && (vch.size() <= 1 || (vch[vch.size() - 2] & 0x80) == 0)) {
+ throw scriptnum_error("non-minimally encoded script number");
+ }
m_value = set_vch(vch);
}
@@ -319,7 +323,6 @@ private:
int64_t m_value;
};
-
/** Serialized script, used inside transaction inputs and outputs */
class CScript : public std::vector<unsigned char>
{
@@ -330,6 +333,10 @@ protected:
{
push_back(n + (OP_1 - 1));
}
+ else if (n == 0)
+ {
+ push_back(OP_0);
+ }
else
{
*this << CScriptNum::serialize(n);
@@ -554,9 +561,6 @@ public:
// Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical).
bool IsPushOnly() const;
- // Called by IsStandardTx.
- bool HasCanonicalPushes() const;
-
// Returns whether the script is guaranteed to fail at execution,
// regardless of the initial stack. This allows outputs to be pruned
// instantly when entering the UTXO set.