Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 289 Lines • ▼ Show 20 Lines | static bool CheckMinimalPush(const valtype &data, opcodetype opcode) { | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
static bool IsOpcodeDisabled(opcodetype opcode, uint32_t flags) { | static bool IsOpcodeDisabled(opcodetype opcode, uint32_t flags) { | ||||
switch (opcode) { | switch (opcode) { | ||||
case OP_CAT: | case OP_CAT: | ||||
case OP_SPLIT: | case OP_SPLIT: | ||||
case OP_BIN2NUM: | |||||
case OP_NUM2BIN: | case OP_NUM2BIN: | ||||
case OP_INVERT: | case OP_INVERT: | ||||
case OP_2MUL: | case OP_2MUL: | ||||
case OP_2DIV: | case OP_2DIV: | ||||
case OP_MUL: | case OP_MUL: | ||||
case OP_DIV: | case OP_DIV: | ||||
case OP_MOD: | case OP_MOD: | ||||
case OP_LSHIFT: | case OP_LSHIFT: | ||||
case OP_RSHIFT: | case OP_RSHIFT: | ||||
// Disabled opcodes. | // Disabled opcodes. | ||||
return true; | return true; | ||||
case OP_AND: | case OP_AND: | ||||
case OP_OR: | case OP_OR: | ||||
case OP_XOR: | case OP_XOR: | ||||
case OP_BIN2NUM: | |||||
// Opcodes that have been reenabled. | // Opcodes that have been reenabled. | ||||
if ((flags & SCRIPT_ENABLE_MONOLITH_OPCODES) == 0) { | if ((flags & SCRIPT_ENABLE_MONOLITH_OPCODES) == 0) { | ||||
return true; | return true; | ||||
} | } | ||||
default: | default: | ||||
break; | break; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 531 Lines • ▼ Show 20 Lines | try { | ||||
{ | { | ||||
// (x1 x2 - bool) | // (x1 x2 - bool) | ||||
if (stack.size() < 2) { | if (stack.size() < 2) { | ||||
return set_error( | return set_error( | ||||
serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | ||||
} | } | ||||
valtype &vch1 = stacktop(-2); | valtype &vch1 = stacktop(-2); | ||||
valtype &vch2 = stacktop(-1); | valtype &vch2 = stacktop(-1); | ||||
bool fEqual = (vch1 == vch2); | bool fEqual = (vch1 == vch2); | ||||
// OP_NOTEQUAL is disabled because it would be too | // OP_NOTEQUAL is disabled because it would be too | ||||
// easy to say something like n != 1 and have some | // easy to say something like n != 1 and have some | ||||
// wiseguy pass in 1 with extra zero bytes after it | // wiseguy pass in 1 with extra zero bytes after it | ||||
// (numerically, 0x01 == 0x0001 == 0x000001) | // (numerically, 0x01 == 0x0001 == 0x000001) | ||||
// if (opcode == OP_NOTEQUAL) | // if (opcode == OP_NOTEQUAL) | ||||
// fEqual = !fEqual; | // fEqual = !fEqual; | ||||
popstack(stack); | popstack(stack); | ||||
▲ Show 20 Lines • Show All 372 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; | ||||
// | |||||
// Conversion operations | |||||
// | |||||
case OP_BIN2NUM: { | |||||
// (in -- out) | |||||
if (stack.size() < 1) { | |||||
return set_error( | |||||
serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | |||||
} | |||||
valtype &n = stacktop(-1); | |||||
CScriptNum::MinimallyEncode(n); | |||||
// The resulting number must be a valid number. | |||||
if (!CScriptNum::IsMinimallyEncoded(n)) { | |||||
return set_error(serror, | |||||
SCRIPT_ERR_INVALID_NUMBER_RANGE); | |||||
} | |||||
} 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 445 Lines • Show Last 20 Lines |