Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 328 Lines • ▼ Show 20 Lines | try { | ||||
return set_error(serror, SCRIPT_ERR_PUSH_SIZE); | return set_error(serror, SCRIPT_ERR_PUSH_SIZE); | ||||
} | } | ||||
// Note how OP_RESERVED does not count towards the opcode limit. | // Note how OP_RESERVED does not count towards the opcode limit. | ||||
if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) { | if (opcode > OP_16 && ++nOpCount > MAX_OPS_PER_SCRIPT) { | ||||
return set_error(serror, SCRIPT_ERR_OP_COUNT); | return set_error(serror, SCRIPT_ERR_OP_COUNT); | ||||
} | } | ||||
if (opcode == OP_CAT || opcode == OP_SPLIT || | if (opcode == OP_SPLIT || opcode == OP_NUM2BIN || | ||||
opcode == OP_NUM2BIN || opcode == OP_BIN2NUM || | opcode == OP_BIN2NUM || opcode == OP_INVERT || | ||||
opcode == OP_INVERT || opcode == OP_2MUL || opcode == OP_2DIV || | opcode == OP_2MUL || opcode == OP_2DIV || opcode == OP_MUL || | ||||
opcode == OP_MUL || opcode == OP_LSHIFT || | opcode == OP_LSHIFT || opcode == OP_RSHIFT) { | ||||
opcode == OP_RSHIFT) { | |||||
// Disabled opcodes. | // Disabled opcodes. | ||||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); | return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); | ||||
} | } | ||||
// if not monolith protocol upgrade (May 2018) then still disabled | // if not monolith protocol upgrade (May 2018) then still disabled | ||||
if (!fEnabledOpCodesMonolith && | if (!fEnabledOpCodesMonolith && | ||||
(opcode == OP_AND || opcode == OP_XOR || opcode == OP_OR || | (opcode == OP_CAT || opcode == OP_AND || opcode == OP_XOR || | ||||
opcode == OP_DIV || opcode == OP_MOD)) { | opcode == OP_OR || opcode == OP_DIV || opcode == OP_MOD)) { | ||||
// Disabled opcodes. | // Disabled opcodes. | ||||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); | return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); | ||||
} | } | ||||
if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) { | if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) { | ||||
if (fRequireMinimal && | if (fRequireMinimal && | ||||
!CheckMinimalPush(vchPushValue, opcode)) { | !CheckMinimalPush(vchPushValue, opcode)) { | ||||
return set_error(serror, SCRIPT_ERR_MINIMALDATA); | return set_error(serror, SCRIPT_ERR_MINIMALDATA); | ||||
▲ Show 20 Lines • Show All 887 Lines • ▼ Show 20 Lines | try { | ||||
popstack(stack); | popstack(stack); | ||||
} else { | } else { | ||||
return set_error( | return set_error( | ||||
serror, SCRIPT_ERR_CHECKMULTISIGVERIFY); | serror, SCRIPT_ERR_CHECKMULTISIGVERIFY); | ||||
} | } | ||||
} | } | ||||
} break; | } break; | ||||
// | |||||
// Byte string operations | |||||
// | |||||
case OP_CAT: { | |||||
// (x1 x2 -- out) | |||||
if (stack.size() < 2) { | |||||
return set_error( | |||||
serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | |||||
} | |||||
valtype &vch1 = stacktop(-2); | |||||
valtype &vch2 = stacktop(-1); | |||||
if (vch1.size() + vch2.size() > | |||||
MAX_SCRIPT_ELEMENT_SIZE) { | |||||
return set_error(serror, SCRIPT_ERR_PUSH_SIZE); | |||||
} | |||||
vch1.insert(vch1.end(), vch2.begin(), vch2.end()); | |||||
stack.pop_back(); | |||||
} break; | |||||
default: | default: | ||||
return set_error(serror, SCRIPT_ERR_BAD_OPCODE); | return set_error(serror, SCRIPT_ERR_BAD_OPCODE); | ||||
} | } | ||||
// Size limits | // Size limits | ||||
if (stack.size() + altstack.size() > 1000) { | if (stack.size() + altstack.size() > 1000) { | ||||
return set_error(serror, SCRIPT_ERR_STACK_SIZE); | return set_error(serror, SCRIPT_ERR_STACK_SIZE); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 437 Lines • Show Last 20 Lines |