MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / IsWitnessProgram

Method IsWitnessProgram

src/script/script.cpp:250–264  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

248// A witness program is any valid CScript that consists of a 1-byte push opcode
249// followed by a data push between 2 and 40 bytes.
250bool CScript::IsWitnessProgram(int& version, std::vector<unsigned char>& program) const
251{
252 if (this->size() < 4 || this->size() > 42) {
253 return false;
254 }
255 if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) {
256 return false;
257 }
258 if ((size_t)((*this)[1] + 2) == this->size()) {
259 version = DecodeOP_N((opcodetype)(*this)[0]);
260 program = std::vector<unsigned char>(this->begin() + 2, this->end());
261 return true;
262 }
263 return false;
264}
265
266bool CScript::IsPushOnly(const_iterator pc) const
267{

Callers 13

GetDustThresholdFunction · 0.45
IsWitnessStandardFunction · 0.45
SolverFunction · 0.45
VerifyScriptFunction · 0.45
CountWitnessSigOpsFunction · 0.45
IsSegWitOutputFunction · 0.45
BOOST_AUTO_TEST_CASEFunction · 0.45
IsExpectedWitnessProgramFunction · 0.45
IsNoWitnessProgramFunction · 0.45
FUZZ_TARGETFunction · 0.45

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 4

BOOST_AUTO_TEST_CASEFunction · 0.36
IsExpectedWitnessProgramFunction · 0.36
IsNoWitnessProgramFunction · 0.36
FUZZ_TARGETFunction · 0.36