def canonical?
      opcode = self.opcode
      if opcode < OP_PUSHDATA1
        return true # most compact pushdata is always canonical.
      elsif opcode == OP_PUSHDATA1
        return (self.raw_data.bytesize - (1+1)) >= OP_PUSHDATA1
      elsif opcode == OP_PUSHDATA2
        return (self.raw_data.bytesize - (1+2)) > 0xff
      elsif opcode == OP_PUSHDATA4
        return (self.raw_data.bytesize - (1+4)) > 0xffff
      else
        return true # all other opcodes are canonical (just 1 byte code)
      end
    end
def canonical?
      opcode = self.opcode
      if opcode < OP_PUSHDATA1
        return true # most compact pushdata is always canonical.
      elsif opcode == OP_PUSHDATA1
        return (self.raw_data.bytesize - (1+1)) >= OP_PUSHDATA1
      elsif opcode == OP_PUSHDATA2
        return (self.raw_data.bytesize - (1+2)) > 0xff
      elsif opcode == OP_PUSHDATA4
        return (self.raw_data.bytesize - (1+4)) > 0xffff
      else
        return true # all other opcodes are canonical (just 1 byte code)
      end
    end
Returns true if this chunk is in canonical form (the most compact one).
 Returns false if it contains pushdata with too big length prefix.
 Example of non-canonical chunk: 75 bytes pushed with OP_PUSHDATA1 instead
 of simple 0x4b prefix.
 Note: this is not as strict as `check_minimal_push` in ScriptInterpreter.