MCPcopy Create free account
hub / github.com/LUX-Core/lux / IsWitnessProgram

Method IsWitnessProgram

src/script/script.cpp:348–362  ·  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

346// A witness program is any valid CScript that consists of a 1-byte push opcode
347// followed by a data push between 2 and 40 bytes.
348bool CScript::IsWitnessProgram(int& version, std::vector<unsigned char>& program) const
349{
350 if (this->size() < 4 || this->size() > 42) {
351 return false;
352 }
353 if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) {
354 return false;
355 }
356 if ((size_t)((*this)[1] + 2) == this->size()) {
357 version = DecodeOP_N((opcodetype)(*this)[0]);
358 program = std::vector<unsigned char>(this->begin() + 2, this->end());
359 return true;
360 }
361 return false;
362}
363
364bool CScript::IsPushOnly(const_iterator pc) const
365{

Callers 9

TransactionChangeTypeMethod · 0.80
IsWitnessStandardFunction · 0.80
VerifyScriptFunction · 0.80
CountWitnessSigOpsFunction · 0.80
SolverFunction · 0.80
GetHashForDestinationFunction · 0.80
SIZE_OF_TXMethod · 0.80
updateLabelsMethod · 0.80
GetDustThresholdMethod · 0.80

Calls 3

sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected