Changeset View
Changeset View
Standalone View
Standalone View
src/script/script.cpp
Show First 20 Lines • Show All 364 Lines • ▼ Show 20 Lines | for (size_t i = data.size() - 1; i > 0; i--) { | ||||
} | } | ||||
} | } | ||||
// If we the whole thing is zeros, then we have a zero. | // If we the whole thing is zeros, then we have a zero. | ||||
data = {}; | data = {}; | ||||
return true; | return true; | ||||
} | } | ||||
uint32_t CScript::GetSigOpCount(uint32_t flags, bool fAccurate) const { | |||||
return 0; | |||||
} | |||||
uint32_t CScript::GetSigOpCount(uint32_t flags, | |||||
const CScript &scriptSig) const { | |||||
if ((flags & SCRIPT_VERIFY_P2SH) == 0 || !IsPayToScriptHash()) { | |||||
return GetSigOpCount(flags, true); | |||||
} | |||||
// This is a pay-to-script-hash scriptPubKey; | |||||
// get the last item that the scriptSig | |||||
// pushes onto the stack: | |||||
const_iterator pc = scriptSig.begin(); | |||||
std::vector<uint8_t> vData; | |||||
while (pc < scriptSig.end()) { | |||||
opcodetype opcode; | |||||
if (!scriptSig.GetOp(pc, opcode, vData)) { | |||||
return 0; | |||||
} | |||||
if (opcode > OP_16) { | |||||
return 0; | |||||
} | |||||
} | |||||
/// ... and return its opcount: | |||||
CScript subscript(vData.begin(), vData.end()); | |||||
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); | ||||
} | } | ||||
bool CScript::IsCommitment(const std::vector<uint8_t> &data) const { | bool CScript::IsCommitment(const std::vector<uint8_t> &data) const { | ||||
// To ensure we have an immediate push, we limit the commitment size to 64 | // To ensure we have an immediate push, we limit the commitment size to 64 | ||||
▲ Show 20 Lines • Show All 132 Lines • Show Last 20 Lines |