lib/segwit/tx_in_witness.rb in openassets-ruby-0.6.1 vs lib/segwit/tx_in_witness.rb in openassets-ruby-0.6.2
- old
+ new
@@ -1,22 +1,38 @@
-class Bitcoin::Protocol::TxInWitness
+# encoding: ascii-8bit
- attr_reader :script_witness
+module Bitcoin
- def initialize
- @script_witness = Bitcoin::Protocol::ScriptWitness.new
- end
+ module Protocol
- def add_stack(script)
- script_witness.stack << script
- end
+ class TxInWitness
+ attr_reader :script_witness
- # output witness script in raw binary format with witness
- def to_payload
- script_witness.to_payload
- end
+ def initialize
+ @script_witness = Bitcoin::Protocol::ScriptWitness.new
+ end
- def stack
- script_witness.stack
- end
+ # add witness script to stack
+ def add_stack(script)
+ script_witness.stack << script
+ end
+ # output witness script in raw binary format with witness
+ def to_payload
+ script_witness.to_payload
+ end
+
+ # get witness script stack
+ def stack
+ script_witness.stack
+ end
+
+ def self.from_hash(witnesses)
+ w = TxInWitness.new
+ witnesses.each{|item|w.add_stack(item)}
+ w
+ end
+
+ end
+
+ end
end
\ No newline at end of file