Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
| Show First 20 Lines • Show All 287 Lines • ▼ Show 20 Lines | if (data.size() <= 65535) { | ||||
| // Could have used OP_PUSHDATA2. | // Could have used OP_PUSHDATA2. | ||||
| return opcode == OP_PUSHDATA2; | return opcode == OP_PUSHDATA2; | ||||
| } | } | ||||
| 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_SPLIT: | |||||
| 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_CAT: | case OP_CAT: | ||||
| case OP_SPLIT: | |||||
| case OP_AND: | case OP_AND: | ||||
| case OP_OR: | case OP_OR: | ||||
| case OP_XOR: | case OP_XOR: | ||||
| case OP_NUM2BIN: | case OP_NUM2BIN: | ||||
| case OP_BIN2NUM: | 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; | ||||
| ▲ Show 20 Lines • Show All 944 Lines • ▼ Show 20 Lines | try { | ||||
| if (vch1.size() + vch2.size() > | if (vch1.size() + vch2.size() > | ||||
| MAX_SCRIPT_ELEMENT_SIZE) { | MAX_SCRIPT_ELEMENT_SIZE) { | ||||
| return set_error(serror, SCRIPT_ERR_PUSH_SIZE); | return set_error(serror, SCRIPT_ERR_PUSH_SIZE); | ||||
| } | } | ||||
| vch1.insert(vch1.end(), vch2.begin(), vch2.end()); | vch1.insert(vch1.end(), vch2.begin(), vch2.end()); | ||||
| popstack(stack); | popstack(stack); | ||||
| } break; | } break; | ||||
| case OP_SPLIT: { | |||||
| // (in position -- x1 x2) | |||||
| if (stack.size() < 2) { | |||||
| return set_error( | |||||
| serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | |||||
| } | |||||
| const valtype &data = stacktop(-2); | |||||
| // Make sure the split point is apropriate. | |||||
| uint64_t position = | |||||
| CScriptNum(stacktop(-1), fRequireMinimal).getint(); | |||||
| if (position > data.size()) { | |||||
| return set_error(serror, | |||||
| SCRIPT_ERR_INVALID_SPLIT_RANGE); | |||||
| } | |||||
| // Prepare the results in their own buffer as `data` | |||||
| // will be invalidated. | |||||
| valtype n1(data.begin(), data.begin() + position); | |||||
| valtype n2(data.begin() + position, data.end()); | |||||
| // Replace existing stack values by the new values. | |||||
| stacktop(-2) = std::move(n1); | |||||
| stacktop(-1) = std::move(n2); | |||||
| } break; | |||||
| // | // | ||||
| // Conversion operations | // Conversion operations | ||||
| // | // | ||||
| case OP_NUM2BIN: { | case OP_NUM2BIN: { | ||||
| // (in size -- out) | // (in size -- out) | ||||
| 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); | ||||
| ▲ Show 20 Lines • Show All 510 Lines • Show Last 20 Lines | |||||