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.
| 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. |
| 250 | bool 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 | |
| 266 | bool CScript::IsPushOnly(const_iterator pc) const |
| 267 | { |