Class: Lightning::Onion::HopData

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(realm, per_hop, hmac) ⇒ HopData

Returns a new instance of HopData.



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

def initialize(realm, per_hop, hmac)
  @realm = realm
  @per_hop = per_hop
  @hmac = hmac
end

Instance Attribute Details

#hmacObject

Returns the value of attribute hmac.



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

def hmac
  @hmac
end

#per_hopObject

Returns the value of attribute per_hop.



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

def per_hop
  @per_hop
end

#realmObject

Returns the value of attribute realm.



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

def realm
  @realm
end

Class Method Details

.parse(payload) ⇒ Object



13
14
15
16
17
# File 'lib/lightning/onion/hop_data.rb', line 13

def self.parse(payload)
  realm, per_hop_payload, hmac = payload.unpack('Ca32a32')
  per_hop = Lightning::Onion::PerHop.parse(per_hop_payload)
  new(realm, per_hop, hmac)
end

Instance Method Details

#to_payloadObject



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

def to_payload
  [realm, per_hop.to_payload, hmac].pack('Ca32a32')
end