Skip to content
Permalink
Browse files

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: 99088d6
  • Loading branch information...
petertodd committed Sep 29, 2014
1 parent 71cc9d9 commit 684636ba67c3eba145a0af8890ed9a7a15deb60a
Showing with 5 additions and 4 deletions.
  1. +4 −3 src/script/script.h
  2. +1 −1 src/test/scriptnum_tests.cpp
@@ -196,7 +196,10 @@ class CScriptNum
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");
@@ -319,8 +322,6 @@ class CScriptNum
return result;
}

static const size_t nMaxNumSize = 4;

private:
static int64_t set_vch(const std::vector<unsigned char>& vch)
{
@@ -145,7 +145,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
{

0 comments on commit 684636b

Please sign in to comment.
You can’t perform that action at this time.