Changeset View
Changeset View
Standalone View
Standalone View
src/script/interpreter.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | static void CleanupScriptCode(CScript &scriptCode, | ||||
uint32_t flags) { | uint32_t flags) { | ||||
// Drop the signature in scripts when SIGHASH_FORKID is not used. | // Drop the signature in scripts when SIGHASH_FORKID is not used. | ||||
SigHashType sigHashType = GetHashType(vchSig); | SigHashType sigHashType = GetHashType(vchSig); | ||||
if (!(flags & SCRIPT_ENABLE_SIGHASH_FORKID) || !sigHashType.hasForkId()) { | if (!(flags & SCRIPT_ENABLE_SIGHASH_FORKID) || !sigHashType.hasForkId()) { | ||||
scriptCode.FindAndDelete(CScript(vchSig)); | scriptCode.FindAndDelete(CScript(vchSig)); | ||||
} | } | ||||
} | } | ||||
static bool CheckMinimalPush(const valtype &data, opcodetype opcode) { | |||||
// Excludes OP_1NEGATE, OP_1-16 since they are by definition minimal | |||||
assert(0 <= opcode && opcode <= OP_PUSHDATA4); | |||||
if (data.size() == 0) { | |||||
// Should have used OP_0. | |||||
return opcode == OP_0; | |||||
} | |||||
if (data.size() == 1 && data[0] >= 1 && data[0] <= 16) { | |||||
// Should have used OP_1 .. OP_16. | |||||
return false; | |||||
} | |||||
if (data.size() == 1 && data[0] == 0x81) { | |||||
// Should have used OP_1NEGATE. | |||||
return false; | |||||
} | |||||
if (data.size() <= 75) { | |||||
// Must have used a direct push (opcode indicating number of bytes | |||||
// pushed + those bytes). | |||||
return opcode == data.size(); | |||||
} | |||||
if (data.size() <= 255) { | |||||
// Must have used OP_PUSHDATA. | |||||
return opcode == OP_PUSHDATA1; | |||||
} | |||||
if (data.size() <= 65535) { | |||||
// Must have used OP_PUSHDATA2. | |||||
return opcode == OP_PUSHDATA2; | |||||
} | |||||
return true; | |||||
} | |||||
static bool IsOpcodeDisabled(opcodetype opcode, uint32_t flags) { | static bool IsOpcodeDisabled(opcodetype opcode, uint32_t flags) { | ||||
switch (opcode) { | switch (opcode) { | ||||
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_LSHIFT: | case OP_LSHIFT: | ||||
case OP_RSHIFT: | case OP_RSHIFT: | ||||
▲ Show 20 Lines • Show All 1,679 Lines • Show Last 20 Lines |