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.
| 329 | // A witness program is any valid CScript that consists of a 1-byte push opcode |
| 330 | // followed by a data push between 2 and 40 bytes. |
| 331 | bool CScript::IsWitnessProgram(int& version, std::vector<unsigned char>& program) const |
| 332 | { |
| 333 | if (this->size() < 4 || this->size() > 42) { |
| 334 | return false; |
| 335 | } |
| 336 | if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) { |
| 337 | return false; |
| 338 | } |
| 339 | if ((size_t)((*this)[1] + 2) == this->size()) { |
| 340 | version = DecodeOP_N((opcodetype)(*this)[0]); |
| 341 | program = std::vector<unsigned char>(this->begin() + 2, this->end()); |
| 342 | return true; |
| 343 | } |
| 344 | return false; |
| 345 | } |
| 346 | |
| 347 | bool CScript::IsPushOnly(const_iterator pc) const |
| 348 | { |