Changeset View
Changeset View
Standalone View
Standalone View
src/script/script.cpp
Show First 20 Lines • Show All 302 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
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::IsPayToWitnessScriptHash() const { | |||||
// Extra-fast test for pay-to-witness-script-hash CScripts: | |||||
return (this->size() == 34 && (*this)[0] == OP_0 && (*this)[1] == 0x20); | |||||
} | |||||
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 | ||||
// bytes. In addition to the data themselves, we have 2 extra bytes: | // bytes. In addition to the data themselves, we have 2 extra bytes: | ||||
// OP_RETURN and the push opcode itself. | // OP_RETURN and the push opcode itself. | ||||
if (data.size() > 64 || this->size() != data.size() + 2) { | if (data.size() > 64 || this->size() != data.size() + 2) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |