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.
| 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. |
| 348 | bool 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 | |
| 364 | bool CScript::IsPushOnly(const_iterator pc) const |
| 365 | { |
no test coverage detected