Class: Bitcoin::Protocol::ScriptWitness

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

Overview

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScriptWitness

Returns a new instance of ScriptWitness.



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

def initialize
  @stack = []
end

Instance Attribute Details

#stackObject (readonly)

witness stack



8
9
10
# File 'lib/bitcoin/protocol/script_witness.rb', line 8

def stack
  @stack
end

Instance Method Details

#empty?Boolean

check empty

Returns:

  • (Boolean)


15
16
17
# File 'lib/bitcoin/protocol/script_witness.rb', line 15

def empty?
  stack.empty?
end

#to_payloadObject

output script in raw binary format



20
21
22
23
# File 'lib/bitcoin/protocol/script_witness.rb', line 20

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