Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | bool fEnabledOpCodesMagnetic = | ||||
(flags & SCRIPT_ENABLE_MAGNETIC_OPCODES) != 0; | (flags & SCRIPT_ENABLE_MAGNETIC_OPCODES) != 0; | ||||
if (fEnabledOpCodesMagnetic) { | if (fEnabledOpCodesMagnetic) { | ||||
switch (opcode) { | switch (opcode) { | ||||
case OP_INVERT: | case OP_INVERT: | ||||
return true; | return true; | ||||
case OP_2MUL: | case OP_2MUL: | ||||
return true; | return false; | ||||
case OP_2DIV: | case OP_2DIV: | ||||
return true; | return false; | ||||
case OP_MUL: | case OP_MUL: | ||||
return true; | return true; | ||||
case OP_LSHIFT: | case OP_LSHIFT: | ||||
return true; | return true; | ||||
case OP_RSHIFT: | case OP_RSHIFT: | ||||
Show All 21 Lines | static bool IsOpcodeDisabled(opcodetype opcode, uint32_t flags) { | ||||
return false; | return false; | ||||
} | } | ||||
bool EvalScript(std::vector<valtype> &stack, const CScript &script, | bool EvalScript(std::vector<valtype> &stack, const CScript &script, | ||||
uint32_t flags, const BaseSignatureChecker &checker, | uint32_t flags, const BaseSignatureChecker &checker, | ||||
ScriptError *serror) { | ScriptError *serror) { | ||||
static const CScriptNum bnZero(0); | static const CScriptNum bnZero(0); | ||||
static const CScriptNum bnOne(1); | static const CScriptNum bnOne(1); | ||||
static const CScriptNum bnTwo(2); | |||||
static const valtype vchFalse(0); | static const valtype vchFalse(0); | ||||
static const valtype vchTrue(1, 1); | static const valtype vchTrue(1, 1); | ||||
CScript::const_iterator pc = script.begin(); | CScript::const_iterator pc = script.begin(); | ||||
CScript::const_iterator pend = script.end(); | CScript::const_iterator pend = script.end(); | ||||
CScript::const_iterator pbegincodehash = script.begin(); | CScript::const_iterator pbegincodehash = script.begin(); | ||||
opcodetype opcode; | opcodetype opcode; | ||||
valtype vchPushValue; | valtype vchPushValue; | ||||
▲ Show 20 Lines • Show All 541 Lines • ▼ Show 20 Lines | try { | ||||
} | } | ||||
break; | break; | ||||
// | // | ||||
// Numeric | // Numeric | ||||
// | // | ||||
case OP_1ADD: | case OP_1ADD: | ||||
case OP_1SUB: | case OP_1SUB: | ||||
case OP_2MUL: | |||||
case OP_2DIV: | |||||
case OP_NEGATE: | case OP_NEGATE: | ||||
case OP_ABS: | case OP_ABS: | ||||
case OP_NOT: | case OP_NOT: | ||||
case OP_0NOTEQUAL: { | case OP_0NOTEQUAL: { | ||||
// (in -- out) | // (in -- out) | ||||
if (stack.size() < 1) { | if (stack.size() < 1) { | ||||
return set_error( | return set_error( | ||||
serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | serror, SCRIPT_ERR_INVALID_STACK_OPERATION); | ||||
} | } | ||||
CScriptNum bn(stacktop(-1), fRequireMinimal); | CScriptNum bn(stacktop(-1), fRequireMinimal); | ||||
switch (opcode) { | switch (opcode) { | ||||
case OP_1ADD: | case OP_1ADD: | ||||
bn += bnOne; | bn += bnOne; | ||||
break; | break; | ||||
case OP_1SUB: | case OP_1SUB: | ||||
bn -= bnOne; | bn -= bnOne; | ||||
break; | break; | ||||
case OP_2MUL: | |||||
bn = bn * bnTwo; | |||||
break; | |||||
case OP_2DIV: | |||||
bn = bn / bnTwo; | |||||
break; | |||||
case OP_NEGATE: | case OP_NEGATE: | ||||
bn = -bn; | bn = -bn; | ||||
break; | break; | ||||
case OP_ABS: | case OP_ABS: | ||||
if (bn < bnZero) { | if (bn < bnZero) { | ||||
bn = -bn; | bn = -bn; | ||||
} | } | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 927 Lines • Show Last 20 Lines |