Changeset View
Changeset View
Standalone View
Standalone View
src/script/script.cpp
Show First 20 Lines • Show All 433 Lines • ▼ Show 20 Lines | for (size_t i = 0; i < data.size(); i++) { | ||||
} | } | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
// A witness program is any valid CScript that consists of a 1-byte push opcode | // A witness program is any valid CScript that consists of a 1-byte push opcode | ||||
// followed by a data push between 2 and 40 bytes. | // followed by a data push between 2 and 40 bytes. | ||||
bool CScript::IsWitnessProgram(int &version, | bool CScript::IsWitnessProgram() const { | ||||
std::vector<uint8_t> &program) const { | |||||
if (this->size() < 4 || this->size() > 42) { | if (this->size() < 4 || this->size() > 42) { | ||||
return false; | return false; | ||||
} | } | ||||
if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) { | if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) { | ||||
return false; | return false; | ||||
} | } | ||||
if (size_t((*this)[1] + 2) == this->size()) { | if (size_t((*this)[1] + 2) == this->size()) { | ||||
version = DecodeOP_N((opcodetype)(*this)[0]); | |||||
program = std::vector<uint8_t>(this->begin() + 2, this->end()); | |||||
return true; | return true; | ||||
} | } | ||||
return false; | return false; | ||||
} | } | ||||
bool CScript::IsPushOnly(const_iterator pc) const { | bool CScript::IsPushOnly(const_iterator pc) const { | ||||
while (pc < end()) { | while (pc < end()) { | ||||
opcodetype opcode; | opcodetype opcode; | ||||
Show All 18 Lines |