Changeset View
Changeset View
Standalone View
Standalone View
src/script/script.cpp
Show First 20 Lines • Show All 388 Lines • ▼ Show 20 Lines | uint32_t CScript::GetSigOpCount(uint32_t flags, | ||||
if ((flags & SCRIPT_VERIFY_P2SH) == 0 || !IsPayToScriptHash()) { | if ((flags & SCRIPT_VERIFY_P2SH) == 0 || !IsPayToScriptHash()) { | ||||
return GetSigOpCount(flags, true); | return GetSigOpCount(flags, true); | ||||
} | } | ||||
// This is a pay-to-script-hash scriptPubKey; | // This is a pay-to-script-hash scriptPubKey; | ||||
// get the last item that the scriptSig | // get the last item that the scriptSig | ||||
// pushes onto the stack: | // pushes onto the stack: | ||||
const_iterator pc = scriptSig.begin(); | const_iterator pc = scriptSig.begin(); | ||||
std::vector<uint8_t> data; | std::vector<uint8_t> vData; | ||||
while (pc < scriptSig.end()) { | while (pc < scriptSig.end()) { | ||||
opcodetype opcode; | opcodetype opcode; | ||||
if (!scriptSig.GetOp(pc, opcode, data)) { | if (!scriptSig.GetOp(pc, opcode, vData)) { | ||||
return 0; | return 0; | ||||
} | } | ||||
if (opcode > OP_16) { | if (opcode > OP_16) { | ||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
/// ... and return its opcount: | /// ... and return its opcount: | ||||
CScript subscript(data.begin(), data.end()); | CScript subscript(vData.begin(), vData.end()); | ||||
return subscript.GetSigOpCount(flags, true); | return subscript.GetSigOpCount(flags, true); | ||||
} | } | ||||
bool CScript::IsPayToScriptHash() const { | bool CScript::IsPayToScriptHash() const { | ||||
// Extra-fast test for pay-to-script-hash CScripts: | // Extra-fast test for pay-to-script-hash CScripts: | ||||
return (this->size() == 23 && (*this)[0] == OP_HASH160 && | return (this->size() == 23 && (*this)[0] == OP_HASH160 && | ||||
(*this)[1] == 0x14 && (*this)[22] == OP_EQUAL); | (*this)[1] == 0x14 && (*this)[22] == OP_EQUAL); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |