Class: Bitcoin::Message::Reject
- Defined in:
- lib/bitcoin/message/reject.rb
Overview
reject message bitcoin.org/en/developer-reference#reject
Constant Summary collapse
- COMMAND =
'reject'
- CODE_MALFORMED =
0x01
- CODE_INVALID =
0x10
- CODE_OBSOLETE =
0x11
- CODE_DUPLICATE =
0x12
- CODE_NONSTANDARD =
0x40
- CODE_DUST =
0x41
- CODE_INSUFFICIENT_FEE =
0x42
- CODE_CHECKPOINT =
0x43
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#extra ⇒ Object
Returns the value of attribute extra.
-
#message ⇒ Object
Returns the value of attribute message.
-
#reason ⇒ Object
Returns the value of attribute reason.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(message, code, reason = '', extra = '') ⇒ Reject
constructor
A new instance of Reject.
- #to_payload ⇒ Object
Methods inherited from Base
Methods included from Util
#byte_to_bit, #calc_checksum, #decode_base58_address, #double_sha256, #encode_base58_address, #hash160, #hkdf_sha256, #hmac_sha256, #pack_boolean, #pack_var_int, #pack_var_string, #padding_zero, #sha256, #tagged_hash, #unpack_boolean, #unpack_var_int, #unpack_var_int_from_io, #unpack_var_string, #valid_address?
Methods included from HexConverter
Constructor Details
#initialize(message, code, reason = '', extra = '') ⇒ Reject
Returns a new instance of Reject.
24 25 26 27 28 29 |
# File 'lib/bitcoin/message/reject.rb', line 24 def initialize(, code, reason = '', extra = '') @message = @code = code @reason = reason @extra = extra end |
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
9 10 11 |
# File 'lib/bitcoin/message/reject.rb', line 9 def code @code end |
#extra ⇒ Object
Returns the value of attribute extra.
11 12 13 |
# File 'lib/bitcoin/message/reject.rb', line 11 def extra @extra end |
#message ⇒ Object
Returns the value of attribute message.
8 9 10 |
# File 'lib/bitcoin/message/reject.rb', line 8 def @message end |
#reason ⇒ Object
Returns the value of attribute reason.
10 11 12 |
# File 'lib/bitcoin/message/reject.rb', line 10 def reason @reason end |
Class Method Details
.parse_from_payload(payload) ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/bitcoin/message/reject.rb', line 31 def self.parse_from_payload(payload) , payload = Bitcoin.unpack_var_string(payload) code, payload = payload.unpack('Ca*') reason, payload = Bitcoin.unpack_var_string(payload) extra = ['tx', 'block'].include?() ? payload.bth : payload new(, code, reason, extra) end |
Instance Method Details
#to_payload ⇒ Object
39 40 41 42 |
# File 'lib/bitcoin/message/reject.rb', line 39 def to_payload e = ['tx', 'block'].include?() ? extra.htb : extra Bitcoin.pack_var_string() << [code].pack('C') << Bitcoin.pack_var_string(reason) << e end |