def witness_program?
      return false if size < 4 || size > 42 || chunks.size < 2

      opcode = chunks[0].opcode

      return false if opcode != OP_0 && (opcode < OP_1 || opcode > OP_16)
      return false unless chunks[1].pushdata?

      if size == (chunks[1][0].unpack('C').first + 2)
        program_size = chunks[1].pushed_data.bytesize
        return program_size >= 2 && program_size <= 40
      end

      false
    end
def witness_program?
      return false if size < 4 || size > 42 || chunks.size < 2

      opcode = chunks[0].opcode

      return false if opcode != OP_0 && (opcode < OP_1 || opcode > OP_16)
      return false unless chunks[1].pushdata?

      if size == (chunks[1][0].unpack('C').first + 2)
        program_size = chunks[1].pushed_data.bytesize
        return program_size >= 2 && program_size <= 40
      end

      false
    end
A witness program is any valid Script that consists of a 1-byte push opcode followed by a data push between 2 and 40 bytes.