Class: Bitcoin::Protocol::ScriptWitness
- Inherits:
-
Object
- Object
- Bitcoin::Protocol::ScriptWitness
- Defined in:
- lib/bitcoin/protocol/script_witness.rb
Instance Attribute Summary collapse
-
#stack ⇒ Object
readonly
witness stack.
Instance Method Summary collapse
-
#empty? ⇒ Boolean
check empty.
-
#initialize ⇒ ScriptWitness
constructor
A new instance of ScriptWitness.
-
#to_payload ⇒ Object
output script in raw binary format.
Constructor Details
#initialize ⇒ ScriptWitness
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
#stack ⇒ Object (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
17 18 19 |
# File 'lib/bitcoin/protocol/script_witness.rb', line 17 def empty? stack.empty? end |
#to_payload ⇒ Object
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 |