Class: Bitcoin::Protocol::ScriptWitness
- Inherits:
-
Object
- Object
- Bitcoin::Protocol::ScriptWitness
- Defined in:
- lib/bitcoin/protocol/script_witness.rb
Overview
TxWitness section of en.bitcoin.it/wiki/Protocol_documentation#tx
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.
10 11 12 |
# File 'lib/bitcoin/protocol/script_witness.rb', line 10 def initialize @stack = [] end |
Instance Attribute Details
#stack ⇒ Object (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
15 16 17 |
# File 'lib/bitcoin/protocol/script_witness.rb', line 15 def empty? stack.empty? end |
#to_payload ⇒ Object
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 |