Class: Bitcoin::Protocol::ScriptWitness

Inherits:
Object
  • Object
show all
Defined in:
lib/bitcoin/protocol/script_witness.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScriptWitness

Returns a new instance of ScriptWitness.



12
13
14
# File 'lib/bitcoin/protocol/script_witness.rb', line 12

def initialize
  @stack = []
end

Instance Attribute Details

#stackObject (readonly)

witness stack



10
11
12
# File 'lib/bitcoin/protocol/script_witness.rb', line 10

def stack
  @stack
end

Instance Method Details

#empty?Boolean

check empty

Returns:

  • (Boolean)


17
18
19
# File 'lib/bitcoin/protocol/script_witness.rb', line 17

def empty?
  stack.empty?
end

#to_payloadObject

output script in raw binary format



22
23
24
25
# File 'lib/bitcoin/protocol/script_witness.rb', line 22

def to_payload
  payload = Bitcoin::Protocol.pack_var_int(stack.size)
  payload << stack.map{|e| Bitcoin::Protocol.pack_var_int(e.bytesize) << e }.join
end