Sha256: fd45d6c1b8937363b63ccc88c403e3160639bfa1d125518b40ae976e1b41ddf6

Contents?: true

Size: 898 Bytes

Versions: 7

Compression:

Stored size: 898 Bytes

Contents

# frozen_string_literal: true

module Lightning
  module Onion
    class PerHop
      attr_accessor :short_channel_id, :amt_to_forward, :outgoing_cltv_value, :padding
      def initialize(short_channel_id, amt_to_forward, outgoing_cltv_value, padding)
        @short_channel_id = short_channel_id
        @amt_to_forward = amt_to_forward
        @outgoing_cltv_value = outgoing_cltv_value
        @padding = padding
      end

      def self.parse(payload)
        new(*payload.unpack('Q>2Na12'))
      end
      LAST_NODE = PerHop.parse("\x00" * 32)

      def to_payload
        to_a.pack('Q>2Na12')
      end

      def ==(other)
        other.class == self.class && other.to_a == to_a
      end

      alias eql? ==

      def hash
        to_a.hash
      end

      protected

      def to_a
        [short_channel_id, amt_to_forward, outgoing_cltv_value, padding]
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lightning-onion-0.2.10 lib/lightning/onion/per_hop.rb
lightning-onion-0.2.9 lib/lightning/onion/per_hop.rb
lightning-onion-0.2.8 lib/lightning/onion/per_hop.rb
lightning-onion-0.2.6 lib/lightning/onion/per_hop.rb
lightning-onion-0.2.5 lib/lightning/onion/per_hop.rb
lightning-onion-0.2.4 lib/lightning/onion/per_hop.rb
lightning-onion-0.2.3 lib/lightning/onion/per_hop.rb