Class: Tapyrus::Message::PrefilledTx

Inherits:
Object
  • Object
show all
Defined in:
lib/tapyrus/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.



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

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

Instance Attribute Details

#indexObject

Returns the value of attribute index.



6
7
8
# File 'lib/tapyrus/message/prefilled_tx.rb', line 6

def index
  @index
end

#txObject

Returns the value of attribute tx.



7
8
9
# File 'lib/tapyrus/message/prefilled_tx.rb', line 7

def tx
  @tx
end

Class Method Details

.parse_from_io(io) ⇒ Object



14
15
16
17
18
# File 'lib/tapyrus/message/prefilled_tx.rb', line 14

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

Instance Method Details

#to_payloadObject



20
21
22
# File 'lib/tapyrus/message/prefilled_tx.rb', line 20

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