lib/segwit/tx_witness.rb in openassets-ruby-0.6.1 vs lib/segwit/tx_witness.rb in openassets-ruby-0.6.2
- old
+ new
@@ -1,22 +1,43 @@
-class Bitcoin::Protocol::TxWitness
+# encoding: ascii-8bit
- attr_reader :tx_in_wit
+module Bitcoin
+ module Protocol
- def initialize
- @tx_in_wit = []
- end
+ class TxWitness
- # Add witness
- # @param[Bitcoin::Protocol::TxInWitness] tx_in_wit witness object
- def add_witness(tx_in_wit)
- (@tx_in_wit ||= []) << tx_in_wit
- end
+ attr_reader :tx_in_wit
- # output witness in raw binary format
- def to_payload
- payload = ""
- tx_in_wit.each{|w|payload << w.to_payload}
- payload
- end
+ def initialize
+ @tx_in_wit = []
+ end
+ # Add witness
+ # @param[Bitcoin::Protocol::TxInWitness] tx_in_wit witness object
+ def add_witness(tx_in_wit)
+ (@tx_in_wit ||= []) << tx_in_wit
+ end
+
+ # add empty witness
+ def add_empty_witness
+ add_witness(TxInWitness.new)
+ end
+
+ # output witness in raw binary format
+ def to_payload
+ payload = ""
+ @tx_in_wit.each{|w|payload << w.to_payload}
+ payload
+ end
+
+ def size
+ tx_in_wit.length
+ end
+
+ def empty?
+ size == 0
+ end
+
+ end
+
+ end
end
\ No newline at end of file