Class: Bitcoin::Message::PrefilledTx

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin/message/prefilled_tx.rb

Overview

A PrefilledTransaction structure is used in HeaderAndShortIDs to provide a list of a few transactions explicitly. github.com/bitcoin/bips/blob/master/bip-0152.mediawiki

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(index, tx) ⇒ PrefilledTx

Returns a new instance of PrefilledTx.



11
12
13
14
# File 'lib/bitcoin/message/prefilled_tx.rb', line 11

def initialize(index, tx)
  @index = index
  @tx = tx
end

Instance Attribute Details

#indexObject

Returns the value of attribute index.



8
9
10
# File 'lib/bitcoin/message/prefilled_tx.rb', line 8

def index
  @index
end

#txObject

Returns the value of attribute tx.



9
10
11
# File 'lib/bitcoin/message/prefilled_tx.rb', line 9

def tx
  @tx
end

Class Method Details

.parse_from_io(io) ⇒ Object



16
17
18
19
20
# File 'lib/bitcoin/message/prefilled_tx.rb', line 16

def self.parse_from_io(io)
  index = Bitcoin.unpack_var_int_from_io(io)
  tx = Bitcoin::Tx.parse_from_payload(io)
  self.new(index, tx)
end

Instance Method Details

#to_payloadObject



22
23
24
# File 'lib/bitcoin/message/prefilled_tx.rb', line 22

def to_payload
  Bitcoin.pack_var_int(index) << tx.to_payload
end