From bab187e963dd579f8c495c31c1403d1512b6cbfa Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 1 Oct 2016 01:16:51 +1300 Subject: [PATCH] Disable OP_CODESEPARATOR --- src/script/interpreter.cpp | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index b83d67d9..ccc98957 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -289,7 +289,8 @@ bool EvalScript(vector >& stack, const CScript& script, un opcode == OP_DIV || opcode == OP_MOD || opcode == OP_LSHIFT || - opcode == OP_RSHIFT) + opcode == OP_RSHIFT || + opcode == OP_CODESEPARATOR) return set_error(serror, SCRIPT_ERR_DISABLED_OPCODE); // Disabled opcodes. if (fExec && 0 <= opcode && opcode <= OP_PUSHDATA4) { @@ -814,13 +815,6 @@ bool EvalScript(vector >& stack, const CScript& script, un popstack(stack); stack.push_back(vchHash); } - break; - - case OP_CODESEPARATOR: - { - // Hash starts after the code separator - pbegincodehash = pc; - } break; case OP_CHECKSIG: @@ -981,27 +975,12 @@ public: fHashSingle((nHashTypeIn & 0x1f) == SIGHASH_SINGLE), fHashNone((nHashTypeIn & 0x1f) == SIGHASH_NONE) {} - /** Serialize the passed scriptCode, skipping OP_CODESEPARATORs */ + /** Serialize the passed scriptCode */ template void SerializeScriptCode(S &s, int nType, int nVersion) const { - CScript::const_iterator it = scriptCode.begin(); - CScript::const_iterator itBegin = it; - opcodetype opcode; - unsigned int nCodeSeparators = 0; - while (scriptCode.GetOp(it, opcode)) { - if (opcode == OP_CODESEPARATOR) - nCodeSeparators++; - } - ::WriteCompactSize(s, scriptCode.size() - nCodeSeparators); - it = itBegin; - while (scriptCode.GetOp(it, opcode)) { - if (opcode == OP_CODESEPARATOR) { - s.write((char*)&itBegin[0], it-itBegin-1); - itBegin = it; - } - } - if (itBegin != scriptCode.end()) - s.write((char*)&itBegin[0], it-itBegin); + auto size = scriptCode.size(); + ::WriteCompactSize(s, size); + s.write((char*)&scriptCode.begin()[0], size); } /** Serialize an input of txTo */