Class: Bitcoin::Protocol::TxWitness

Inherits:
Object
  • Object
show all
Defined in:
lib/segwit/tx_witness.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTxWitness

Returns a new instance of TxWitness.



10
11
12
# File 'lib/segwit/tx_witness.rb', line 10

def initialize
  @tx_in_wit = []
end

Instance Attribute Details

#tx_in_witObject (readonly)

Returns the value of attribute tx_in_wit.



8
9
10
# File 'lib/segwit/tx_witness.rb', line 8

def tx_in_wit
  @tx_in_wit
end

Instance Method Details

#add_empty_witnessObject

add empty witness



21
22
23
# File 'lib/segwit/tx_witness.rb', line 21

def add_empty_witness
  add_witness(TxInWitness.new)
end

#add_witness(tx_in_wit) ⇒ Object

Add witness @param tx_in_wit witness object



16
17
18
# File 'lib/segwit/tx_witness.rb', line 16

def add_witness(tx_in_wit)
  (@tx_in_wit ||= []) << tx_in_wit
end

#empty?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/segwit/tx_witness.rb', line 36

def empty?
  size == 0
end

#sizeObject



32
33
34
# File 'lib/segwit/tx_witness.rb', line 32

def size
  tx_in_wit.length
end

#to_payloadObject

output witness in raw binary format



26
27
28
29
30
# File 'lib/segwit/tx_witness.rb', line 26

def to_payload
  payload = ""
  @tx_in_wit.each{|w|payload << w.to_payload}
  payload
end