Sha256: 895461f5c50fb06c700203cff24c2bfda9f02b59ceb0a138927f973da0c1962d

Contents?: true

Size: 724 Bytes

Versions: 3

Compression:

Stored size: 724 Bytes

Contents

# encoding: ascii-8bit

module Bitcoin
  module Protocol

    class TxWitness

      attr_reader :tx_in_wit

      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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
openassets-ruby-0.6.4 lib/segwit/tx_witness.rb
openassets-ruby-0.6.3 lib/segwit/tx_witness.rb
openassets-ruby-0.6.2 lib/segwit/tx_witness.rb