diff options
author | Peter Todd <pete@petertodd.org> | 2014-09-29 01:00:01 -0400 |
---|---|---|
committer | Peter Todd <pete@petertodd.org> | 2015-10-08 17:39:17 +0200 |
commit | 689746841afd0f2076a7d93d30974c2f7d29cd83 (patch) | |
tree | dc1828542aa2ea198e6431e73a8172020cd5b657 | |
parent | 1cea6b0dee0b0f10d5f41433e27c70213a4c531f (diff) | |
download | bitcoin-689746841afd0f2076a7d93d30974c2f7d29cd83.tar.xz |
Make CScriptNum() take nMaxNumSize as an argument
While the existing numeric opcodes are all limited to 4-byte bignum
arguments, new opcodes will need different limits.
Rebased-From: 99088d60d8a7747c6d1a7fd5d8cd388be1b3e138
-rw-r--r-- | src/script/script.h | 7 | ||||
-rw-r--r-- | src/test/scriptnum_tests.cpp | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/src/script/script.h b/src/script/script.h index 9c22cb908c..e3af4a6fd9 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -194,7 +194,10 @@ public: m_value = n; } - explicit CScriptNum(const std::vector<unsigned char>& vch, bool fRequireMinimal) + static const size_t nDefaultMaxNumSize = 4; + + explicit CScriptNum(const std::vector<unsigned char>& vch, bool fRequireMinimal, + const size_t nMaxNumSize = nDefaultMaxNumSize) { if (vch.size() > nMaxNumSize) { throw scriptnum_error("script number overflow"); @@ -317,8 +320,6 @@ public: return result; } - static const size_t nMaxNumSize = 4; - private: static int64_t set_vch(const std::vector<unsigned char>& vch) { diff --git a/src/test/scriptnum_tests.cpp b/src/test/scriptnum_tests.cpp index 5621e12729..2f88b06766 100644 --- a/src/test/scriptnum_tests.cpp +++ b/src/test/scriptnum_tests.cpp @@ -142,7 +142,7 @@ static void RunCreate(const int64_t& num) { CheckCreateInt(num); CScriptNum scriptnum(num); - if (scriptnum.getvch().size() <= CScriptNum::nMaxNumSize) + if (scriptnum.getvch().size() <= CScriptNum::nDefaultMaxNumSize) CheckCreateVch(num); else { |