Sha256: ef2ebc924d70dea5f6bf8863769ad37da85060050f1aead39a6639e642f8aec3
Contents?: true
Size: 850 Bytes
Versions: 12
Compression:
Stored size: 850 Bytes
Contents
# encoding: ascii-8bit module Bitcoin module Protocol class Reject < Struct.new(:message, :ccode, :reason, :data) CCODE_TABLE = { 0x01 => :malformed, 0x10 => :invalid, 0x11 => :obsolete, 0x12 => :duplicate, 0x40 => :nonstandard, 0x41 => :dust, 0x42 => :insufficientfee, 0x43 => :checkpoint, } def self.parse(payload) message, payload = Bitcoin::Protocol.unpack_var_string(payload) ccode, payload = payload.unpack("Ca*") reason, payload = Bitcoin::Protocol.unpack_var_string(payload) data = payload code = CCODE_TABLE[ccode] || ccode new(message, code, reason, data) end def tx_hash message == "tx" && self[:data].reverse.bth end def block_hash message == "block" && self[:data].reverse.bth end end end end
Version data entries
12 entries across 12 versions & 2 rubygems