mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-15 12:51:00 +02:00
script: Remove magic numbers
This adds two new constants, MAX_OPS_PER_SCRIPT and MAX_PUBKEYS_PER_MULTISIG.
This commit is contained in:
parent
d78a880900
commit
b48da5c189
3 changed files with 12 additions and 5 deletions
|
|
@ -273,7 +273,7 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
|||
return set_error(serror, SCRIPT_ERR_PUSH_SIZE);
|
||||
|
||||
// Note how OP_RESERVED does not count towards the opcode limit.
|
||||
if (opcode > OP_16 && ++nOpCount > 201)
|
||||
if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT)
|
||||
return set_error(serror, SCRIPT_ERR_OP_COUNT);
|
||||
|
||||
if (opcode == OP_CAT ||
|
||||
|
|
@ -869,10 +869,10 @@ bool EvalScript(vector<vector<unsigned char> >& stack, const CScript& script, un
|
|||
return set_error(serror, SCRIPT_ERR_INVALID_STACK_OPERATION);
|
||||
|
||||
int nKeysCount = CScriptNum(stacktop(-i), fRequireMinimal).getint();
|
||||
if (nKeysCount < 0 || nKeysCount > 20)
|
||||
if (nKeysCount < 0 || nKeysCount > MAX_PUBKEYS_PER_MULTISIG)
|
||||
return set_error(serror, SCRIPT_ERR_PUBKEY_COUNT);
|
||||
nOpCount += nKeysCount;
|
||||
if (nOpCount > 201)
|
||||
if (nOpCount > MAX_OPS_PER_SCRIPT)
|
||||
return set_error(serror, SCRIPT_ERR_OP_COUNT);
|
||||
int ikey = ++i;
|
||||
i += nKeysCount;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue