diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 555a16a24347d..e031e5db013fb 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -273,7 +273,7 @@ bool EvalScript(vector >& 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_OPCODES_PER_SCRIPT) return set_error(serror, SCRIPT_ERR_OP_COUNT); if (opcode == OP_CAT || @@ -830,7 +830,7 @@ bool EvalScript(vector >& stack, const CScript& script, un if (nKeysCount < 0 || nKeysCount > 20) return set_error(serror, SCRIPT_ERR_PUBKEY_COUNT); nOpCount += nKeysCount; - if (nOpCount > 201) + if (nOpCount > MAX_OPCODES_PER_SCRIPT) return set_error(serror, SCRIPT_ERR_OP_COUNT); int ikey = ++i; i += nKeysCount; diff --git a/src/script/script.h b/src/script/script.h index 4904372df204b..5bf21b3822474 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -16,6 +16,7 @@ #include static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520; // bytes +static const unsigned int MAX_OPCODES_PER_SCRIPT = 201; template std::vector ToByteVector(const T& in)