Class: Bitcoin::Message::SendCmpct
- Defined in:
- lib/bitcoin/message/send_cmpct.rb
Overview
sendcmpct message github.com/bitcoin/bips/blob/master/bip-0152.mediawiki
Constant Summary collapse
- COMMAND =
'sendcmpct'
- MODE_HIGH =
1
- MODE_LOW =
0
Instance Attribute Summary collapse
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #high? ⇒ Boolean
-
#initialize(mode = MODE_HIGH, version = 1) ⇒ SendCmpct
constructor
TODO support version 2.
- #low? ⇒ Boolean
- #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
Instance Attribute Details
#mode ⇒ Object
Returns the value of attribute mode.
13 14 15 |
# File 'lib/bitcoin/message/send_cmpct.rb', line 13 def mode @mode end |
#version ⇒ Object
Returns the value of attribute version.
14 15 16 |
# File 'lib/bitcoin/message/send_cmpct.rb', line 14 def version @version end |
Class Method Details
.parse_from_payload(payload) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/bitcoin/message/send_cmpct.rb', line 22 def self.parse_from_payload(payload) buf = StringIO.new(payload) mode = buf.read(1).unpack1('c') version = buf.read(8).unpack1('Q') new(mode, version) end |
Instance Method Details
#high? ⇒ Boolean
33 34 35 |
# File 'lib/bitcoin/message/send_cmpct.rb', line 33 def high? mode == 1 end |
#low? ⇒ Boolean
37 38 39 |
# File 'lib/bitcoin/message/send_cmpct.rb', line 37 def low? mode.zero? end |
#to_payload ⇒ Object
29 30 31 |
# File 'lib/bitcoin/message/send_cmpct.rb', line 29 def to_payload [mode, version].pack('cQ') end |