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.
| 214 | // A witness program is any valid CScript that consists of a 1-byte push opcode |
| 215 | // followed by a data push between 2 and 40 bytes. |
| 216 | bool CScript::IsWitnessProgram(int& version, std::vector<unsigned char>& program) const |
| 217 | { |
| 218 | if (this->size() < 4 || this->size() > 42) { |
| 219 | return false; |
| 220 | } |
| 221 | if ((*this)[0] != OP_0 && ((*this)[0] < OP_1 || (*this)[0] > OP_16)) { |
| 222 | return false; |
| 223 | } |
| 224 | if ((size_t)((*this)[1] + 2) == this->size()) { |
| 225 | version = DecodeOP_N((opcodetype)(*this)[0]); |
| 226 | program = std::vector<unsigned char>(this->begin() + 2, this->end()); |
| 227 | return true; |
| 228 | } |
| 229 | return false; |
| 230 | } |
| 231 | |
| 232 | bool CScript::IsPushOnly(const_iterator pc) const |
| 233 | { |
no test coverage detected