Class: Lightning::Onion::PerHop

Inherits:
Object
  • Object
show all
Defined in:
lib/lightning/onion/per_hop.rb

Constant Summary collapse

LAST_NODE =
PerHop.parse("\x00" * 32)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(short_channel_id, amt_to_forward, outgoing_cltv_value, padding) ⇒ PerHop

Returns a new instance of PerHop.



7
8
9
10
11
12
# File 'lib/lightning/onion/per_hop.rb', line 7

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

Instance Attribute Details

#amt_to_forwardObject

Returns the value of attribute amt_to_forward.



6
7
8
# File 'lib/lightning/onion/per_hop.rb', line 6

def amt_to_forward
  @amt_to_forward
end

#outgoing_cltv_valueObject

Returns the value of attribute outgoing_cltv_value.



6
7
8
# File 'lib/lightning/onion/per_hop.rb', line 6

def outgoing_cltv_value
  @outgoing_cltv_value
end

#paddingObject

Returns the value of attribute padding.



6
7
8
# File 'lib/lightning/onion/per_hop.rb', line 6

def padding
  @padding
end

#short_channel_idObject

Returns the value of attribute short_channel_id.



6
7
8
# File 'lib/lightning/onion/per_hop.rb', line 6

def short_channel_id
  @short_channel_id
end

Class Method Details

.parse(payload) ⇒ Object



14
15
16
# File 'lib/lightning/onion/per_hop.rb', line 14

def self.parse(payload)
  new(*payload.unpack('Q>2Na12'))
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



23
24
25
# File 'lib/lightning/onion/per_hop.rb', line 23

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

#hashObject



29
30
31
# File 'lib/lightning/onion/per_hop.rb', line 29

def hash
  to_a.hash
end

#to_payloadObject



19
20
21
# File 'lib/lightning/onion/per_hop.rb', line 19

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