lightning-onion 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.ruby-version +1 -1
- data/lib/lightning/onion/failure_messages/amount_below_minimum.rb +3 -3
- data/lib/lightning/onion/failure_messages/channel_disabled.rb +3 -3
- data/lib/lightning/onion/failure_messages/expiry_too_far.rb +2 -2
- data/lib/lightning/onion/failure_messages/expiry_too_soon.rb +3 -3
- data/lib/lightning/onion/failure_messages/fee_insufficient.rb +3 -3
- data/lib/lightning/onion/failure_messages/final_expiry_too_soon.rb +3 -3
- data/lib/lightning/onion/failure_messages/final_incorrect_cltv_expiry.rb +2 -2
- data/lib/lightning/onion/failure_messages/final_incorrect_htlc_amount.rb +2 -2
- data/lib/lightning/onion/failure_messages/incorrect_cltv_expiry.rb +3 -3
- data/lib/lightning/onion/failure_messages/incorrect_payment_amount.rb +3 -3
- data/lib/lightning/onion/failure_messages/invalid_onion_hmac.rb +3 -3
- data/lib/lightning/onion/failure_messages/invalid_onion_key.rb +3 -3
- data/lib/lightning/onion/failure_messages/invalid_onion_version.rb +3 -3
- data/lib/lightning/onion/failure_messages/invalid_realm.rb +3 -3
- data/lib/lightning/onion/failure_messages/permanent_channel_failure.rb +3 -3
- data/lib/lightning/onion/failure_messages/permanent_node_failure.rb +2 -2
- data/lib/lightning/onion/failure_messages/required_channel_feature_missing.rb +2 -2
- data/lib/lightning/onion/failure_messages/required_node_feature_missing.rb +2 -2
- data/lib/lightning/onion/failure_messages/temporary_channel_failure.rb +3 -3
- data/lib/lightning/onion/failure_messages/temporary_node_failure.rb +2 -2
- data/lib/lightning/onion/failure_messages/unknown_next_peer.rb +2 -2
- data/lib/lightning/onion/failure_messages/unknown_payment_hash.rb +3 -3
- data/lib/lightning/onion/failure_messages.rb +24 -57
- data/lib/lightning/onion/sphinx.rb +1 -0
- data/lib/lightning/onion/version.rb +1 -1
- data/lib/lightning/onion.rb +1 -1
- data/lightning-onion.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9cc1140de863ddf69d940e23377106aef0c9403b7186a6c659cae59703b15713
|
4
|
+
data.tar.gz: 75b3378abe3ee65e02df8866cea2d21752e06eb187e8352e40b86fda52729210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8f8043b6420760cb4a211a5c4342c30bb07647d090109b5d432eefd7e2fc9b324872019c0d045d029bbf5baeabe98dd8ab950f5849a35f265a053e69b11da99
|
7
|
+
data.tar.gz: d244305278a85f1f7e0a920345c8b7924f1446b326cd303fbb8c6544f227b0203fe9618a21150fbc393e413b6bf395c43d93ad459e9889aa6f5e804720401a0b
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.5.1
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module AmountBelowMinimum
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:amount_below_minimum], htlc_msat, channel_update.htb.bytesize].pack('nq>n') + channel_update.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
htlc_msat, len, rest = payload.unpack('q>nH*')
|
13
|
+
new(htlc_msat, rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module ChannelDisabled
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:channel_disabled], flags, channel_update.htb.bytesize].pack('nH4n') + channel_update.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
flags, len, rest = payload.unpack('H4nH*')
|
13
|
+
new(flags, rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module ExpiryTooSoon
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:expiry_too_soon], channel_update.htb.bytesize].pack('n2') + channel_update.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
len, rest = payload.unpack('nH*')
|
13
|
+
new(rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module FeeInsufficient
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:fee_insufficient], htlc_msat, channel_update.htb.bytesize].pack('nq>n') + channel_update.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
htlc_msat, len, rest = payload.unpack('q>nH*')
|
13
|
+
new(htlc_msat, rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module FinalExpiryTooSoon
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:final_expiry_too_soon]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.load(
|
12
|
-
|
11
|
+
def self.load(_)
|
12
|
+
FinalExpiryTooSoon
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module FinalIncorrectCltvExpiry
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:final_incorrect_cltv_expiry], cltv_expiry].pack('nq>')
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
new(*payload.unpack('
|
12
|
+
new(*payload.unpack('q>'))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module FinalIncorrectHtlcAmount
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:final_incorrect_htlc_amount], incoming_htlc_amt].pack('nq>')
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
new(*payload.unpack('
|
12
|
+
new(*payload.unpack('q>'))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module IncorrectCltvExpiry
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:incorrect_cltv_expiry], cltv_expiry, channel_update.htb.bytesize].pack('nq>n') + channel_update.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
cltv_expiry, len, rest = payload.unpack('q>nH*')
|
13
|
+
new(cltv_expiry, rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module IncorrectPaymentAmount
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:incorrect_payment_amount]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.load(
|
12
|
-
|
11
|
+
def self.load(_)
|
12
|
+
IncorrectPaymentAmount
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module InvalidOnionHmac
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:invalid_onion_hmac], sha256_of_onion.htb.bytesize].pack('n2') + sha256_of_onion.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
len, rest = payload.unpack('nH*')
|
13
|
+
new(rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module InvalidOnionKey
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:invalid_onion_key], sha256_of_onion.htb.bytesize].pack('n2') + sha256_of_onion.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
len, rest = payload.unpack('nH*')
|
13
|
+
new(rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module InvalidOnionVersion
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:invalid_onion_version], sha256_of_onion.htb.bytesize].pack('n2') + sha256_of_onion.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
len, rest = payload.unpack('nH*')
|
13
|
+
new(rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module InvalidRealm
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:invalid_realm]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.load(
|
12
|
-
|
11
|
+
def self.load(_)
|
12
|
+
InvalidRealm
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module PermanentChannelFailure
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:permanent_channel_failure]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.load(
|
12
|
-
|
11
|
+
def self.load(_)
|
12
|
+
PermanentChannelFailure
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module PermanentNodeFailure
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:permanent_node_failure]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
12
|
+
PermanentNodeFailure
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module RequiredChannelFeatureMissing
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:required_channel_feature_missing]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
12
|
+
RequiredChannelFeatureMissing
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module RequiredNodeFeatureMissing
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:required_node_feature_missing]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
12
|
+
RequiredNodeFeatureMissing
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,12 +5,12 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module TemporaryChannelFailure
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:temporary_channel_failure], channel_update.bytesize].pack('n2') + channel_update.htb
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
13
|
-
new(
|
12
|
+
len, rest = payload.unpack('nH*')
|
13
|
+
new(rest[0..len * 2])
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module TemporaryNodeFailure
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:temporary_node_failure]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
12
|
+
TemporaryNodeFailure
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module UnknownNextPeer
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:unknown_next_peer]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.load(payload)
|
12
|
-
|
12
|
+
UnknownNextPeer
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -5,11 +5,11 @@ module Lightning
|
|
5
5
|
module FailureMessages
|
6
6
|
module UnknownPaymentHash
|
7
7
|
def to_payload
|
8
|
-
[
|
8
|
+
[TYPES[:unknown_payment_hash]].pack('n')
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.load(
|
12
|
-
|
11
|
+
def self.load(_)
|
12
|
+
UnknownPaymentHash
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -41,87 +41,54 @@ module Lightning
|
|
41
41
|
}.freeze
|
42
42
|
|
43
43
|
FailureMessage = Algebrick.type do
|
44
|
-
InvalidRealm =
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
fields! type_code: Numeric
|
49
|
-
end
|
50
|
-
PermanentNodeFailure = type do
|
51
|
-
fields! type_code: Numeric
|
52
|
-
end
|
53
|
-
RequiredNodeFeatureMissing = type do
|
54
|
-
fields! type_code: Numeric
|
55
|
-
end
|
44
|
+
InvalidRealm = atom
|
45
|
+
TemporaryNodeFailure = atom
|
46
|
+
PermanentNodeFailure = atom
|
47
|
+
RequiredNodeFeatureMissing = atom
|
56
48
|
InvalidOnionVersion = type do
|
57
|
-
fields!
|
58
|
-
sha256_of_onion: String
|
49
|
+
fields! sha256_of_onion: String
|
59
50
|
end
|
60
51
|
InvalidOnionHmac = type do
|
61
|
-
fields!
|
62
|
-
sha256_of_onion: String
|
52
|
+
fields! sha256_of_onion: String
|
63
53
|
end
|
64
54
|
InvalidOnionKey = type do
|
65
|
-
fields!
|
66
|
-
sha256_of_onion: String
|
55
|
+
fields! sha256_of_onion: String
|
67
56
|
end
|
68
57
|
TemporaryChannelFailure = type do
|
69
|
-
fields!
|
70
|
-
channel_update: String
|
71
|
-
end
|
72
|
-
PermanentChannelFailure = type do
|
73
|
-
fields! type_code: Numeric
|
74
|
-
end
|
75
|
-
RequiredChannelFeatureMissing = type do
|
76
|
-
fields! type_code: Numeric
|
77
|
-
end
|
78
|
-
UnknownNextPeer = type do
|
79
|
-
fields! type_code: Numeric
|
58
|
+
fields! channel_update: String
|
80
59
|
end
|
60
|
+
PermanentChannelFailure = atom
|
61
|
+
RequiredChannelFeatureMissing = atom
|
62
|
+
UnknownNextPeer = atom
|
81
63
|
AmountBelowMinimum = type do
|
82
|
-
fields!
|
83
|
-
htlc_msat: Numeric,
|
64
|
+
fields! htlc_msat: Numeric,
|
84
65
|
channel_update: String
|
85
66
|
end
|
86
67
|
FeeInsufficient = type do
|
87
|
-
fields!
|
88
|
-
htlc_msat: Numeric,
|
68
|
+
fields! htlc_msat: Numeric,
|
89
69
|
channel_update: String
|
90
70
|
end
|
91
71
|
IncorrectCltvExpiry = type do
|
92
|
-
fields!
|
93
|
-
cltv_expiry: Numeric,
|
72
|
+
fields! cltv_expiry: Numeric,
|
94
73
|
channel_update: String
|
95
74
|
end
|
96
75
|
ExpiryTooSoon = type do
|
97
|
-
fields!
|
98
|
-
channel_update: String
|
99
|
-
end
|
100
|
-
UnknownPaymentHash = type do
|
101
|
-
fields! type_code: Numeric
|
102
|
-
end
|
103
|
-
IncorrectPaymentAmount = type do
|
104
|
-
fields! type_code: Numeric
|
105
|
-
end
|
106
|
-
FinalExpiryTooSoon = type do
|
107
|
-
fields! type_code: Numeric
|
76
|
+
fields! channel_update: String
|
108
77
|
end
|
78
|
+
UnknownPaymentHash = atom
|
79
|
+
IncorrectPaymentAmount = atom
|
80
|
+
FinalExpiryTooSoon = atom
|
109
81
|
FinalIncorrectCltvExpiry = type do
|
110
|
-
fields!
|
111
|
-
cltv_expiry: Numeric
|
82
|
+
fields! cltv_expiry: Numeric
|
112
83
|
end
|
113
84
|
FinalIncorrectHtlcAmount = type do
|
114
|
-
fields!
|
115
|
-
incoming_htlc_amt: Numeric
|
85
|
+
fields! incoming_htlc_amt: Numeric
|
116
86
|
end
|
117
87
|
ChannelDisabled = type do
|
118
|
-
fields!
|
119
|
-
flags: String,
|
88
|
+
fields! flags: String,
|
120
89
|
channel_update: String
|
121
90
|
end
|
122
|
-
ExpiryTooFar =
|
123
|
-
fields! type_code: Numeric
|
124
|
-
end
|
91
|
+
ExpiryTooFar = atom
|
125
92
|
variants InvalidRealm,
|
126
93
|
TemporaryNodeFailure,
|
127
94
|
PermanentNodeFailure,
|
@@ -147,11 +114,11 @@ module Lightning
|
|
147
114
|
end
|
148
115
|
|
149
116
|
def self.load(payload)
|
150
|
-
type, = payload.unpack('na*')
|
117
|
+
type, rest = payload.unpack('na*')
|
151
118
|
message_class = FailureMessage.variants.find do |t|
|
152
119
|
TYPES[t.name.split('::').last.snake.to_sym] == type
|
153
120
|
end
|
154
|
-
message_class.load(
|
121
|
+
message_class.load(rest)
|
155
122
|
end
|
156
123
|
|
157
124
|
require 'lightning/onion/failure_messages/invalid_realm'
|
@@ -38,6 +38,7 @@ module Lightning
|
|
38
38
|
|
39
39
|
# @return payload 33bytes payload of the outermost layer of onions,which including realm
|
40
40
|
# @return packet
|
41
|
+
# @return Shared Secret
|
41
42
|
def self.parse(private_key, raw_packet)
|
42
43
|
packet = Lightning::Onion::Packet.parse(raw_packet)
|
43
44
|
shared_secret = compute_shared_secret(packet.public_key, private_key)
|
data/lib/lightning/onion.rb
CHANGED
data/lightning-onion.gemspec
CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
|
23
23
|
spec.add_runtime_dependency 'algebrick'
|
24
24
|
spec.add_runtime_dependency 'bitcoinrb'
|
25
|
-
spec.add_runtime_dependency 'rbnacl'
|
25
|
+
spec.add_runtime_dependency 'rbnacl-libsodium'
|
26
26
|
|
27
27
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
28
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lightning-onion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hajime Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-08-
|
11
|
+
date: 2018-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: algebrick
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: rbnacl
|
42
|
+
name: rbnacl-libsodium
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -166,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
166
166
|
version: '0'
|
167
167
|
requirements: []
|
168
168
|
rubyforge_project:
|
169
|
-
rubygems_version: 2.6
|
169
|
+
rubygems_version: 2.7.6
|
170
170
|
signing_key:
|
171
171
|
specification_version: 4
|
172
172
|
summary: Onion routing for the Lightning Network.
|