Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 1,265 Lines • ▼ Show 20 Lines | try { | ||||
stack.pop_back(); | stack.pop_back(); | ||||
} break; | } break; | ||||
case OP_SPLIT: { | case OP_SPLIT: { | ||||
if (!fEnabledOpCodesMonolith) { | if (!fEnabledOpCodesMonolith) { | ||||
// Disabled opcodes. | // Disabled opcodes. | ||||
return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); | return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); | ||||
} | } | ||||
// (in position -- x1 x2) | |||||
if (stack.size() < 2) { | |||||
return set_error( | |||||
serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | |||||
} | |||||
valtype vch = stacktop(-2); | |||||
int64_t nPosition = CScriptNum(stacktop(-1), fRequireMinimal).getint(); | |||||
// if nPosition is less than 0 or is larger than the | |||||
// input then throw error | |||||
if (nPosition < 0 || static_cast<size_t>(nPosition) > vch.size()) { | |||||
return set_error( | |||||
serror, SCRIPT_ERR_INVALID_SPLIT_RANGE); | |||||
} | |||||
stack.pop_back(); | |||||
stack.pop_back(); | |||||
// initialize outputs | |||||
if (nPosition == 0) { | |||||
stack.push_back(valtype()); | |||||
stack.push_back(vch); | |||||
} else if (static_cast<size_t>(nPosition) == vch.size()) { | |||||
stack.push_back(vch); | |||||
stack.push_back(valtype()); | |||||
} else { | |||||
valtype vchOut1, vchOut2; | |||||
vchOut1.insert(vchOut1.end(), vch.begin(), vch.begin() + nPosition); | |||||
vchOut2.insert(vchOut2.end(), vch.begin() + nPosition, vch.end()); | |||||
stack.emplace_back(move(vchOut1)); | |||||
stack.emplace_back(move(vchOut2)); | |||||
} | |||||
} break; | } break; | ||||
// | // | ||||
// Conversion operations | // Conversion operations | ||||
// | // | ||||
case OP_BIN2NUM: { | case OP_BIN2NUM: { | ||||
if (!fEnabledOpCodesMonolith) { | if (!fEnabledOpCodesMonolith) { | ||||
// Disabled opcodes. | // Disabled opcodes. | ||||
▲ Show 20 Lines • Show All 463 Lines • Show Last 20 Lines |