lighstorm 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -3
- data/adapters/invoice.rb +2 -2
- data/controllers/invoice/actions/create.rb +4 -4
- data/controllers/invoice/actions/pay.rb +17 -9
- data/controllers/invoice/decode.rb +6 -6
- data/controllers/invoice.rb +4 -4
- data/controllers/node/actions/pay.rb +10 -5
- data/controllers/payment/actions/pay.rb +4 -4
- data/controllers/payment/all.rb +30 -12
- data/docs/README.md +41 -26
- data/docs/_coverpage.md +1 -1
- data/docs/index.html +1 -1
- data/models/invoice.rb +5 -3
- data/models/nodes/node.rb +7 -4
- data/models/secret.rb +7 -1
- data/static/spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed188ef291ac08a9cc6f91dca92931be2c88257ee184416fd0f40a3224740b20
|
4
|
+
data.tar.gz: 1be060a12d9e755354764cc8151da8a26e114fcc9a0ecac470e9fe9b685a60a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b37802f04bae65416f4e80590506518025d62f1ca9b502b97db3cc108792b13a077f2ebb89c3e0be4cf311fb10a53f916a3c37e2f6c729b9bf01f187b0ab4892
|
7
|
+
data.tar.gz: ac5f5a1f5f4ff271ab2ddef517763f380f1868b71339bcf1758975e35c7e520ddd65fddb9d210539fedde2dc3830912db8b0bbdbfed1aa454e781c8a6e43e948
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -34,7 +34,7 @@ Although it tries to stay close to [Lightning's terminologies](https://docs.ligh
|
|
34
34
|
Add to your `Gemfile`:
|
35
35
|
|
36
36
|
```ruby
|
37
|
-
gem 'lighstorm', '~> 0.0.
|
37
|
+
gem 'lighstorm', '~> 0.0.10'
|
38
38
|
```
|
39
39
|
|
40
40
|
```ruby
|
@@ -46,15 +46,22 @@ Lighstorm.config!(
|
|
46
46
|
macaroon_path: '/lnd/data/chain/bitcoin/mainnet/admin.macaroon',
|
47
47
|
)
|
48
48
|
|
49
|
-
puts Lighstorm.version # => 0.0.
|
49
|
+
puts Lighstorm.version # => 0.0.10
|
50
50
|
|
51
51
|
Lighstorm::Node.myself.alias # => icebaker/old-stone
|
52
52
|
|
53
53
|
Lighstorm::Invoice.create(
|
54
|
-
description: 'Coffee',
|
54
|
+
description: 'Coffee',
|
55
|
+
amount: { millisatoshis: 1_000 },
|
55
56
|
payable: 'once'
|
56
57
|
)
|
57
58
|
|
59
|
+
Lighstorm::Invoice.decode('lnbc20m1pv...qqdhhwkj').pay
|
60
|
+
|
61
|
+
Lighstorm::Invoice.decode('lnbc20m1pv...qqdhhwkj').pay(
|
62
|
+
fee: { maximum: { millisatoshis: 1000 } }
|
63
|
+
)
|
64
|
+
|
58
65
|
Lighstorm::Satoshis.new(
|
59
66
|
millisatoshis: 75_621_650
|
60
67
|
).satoshis # => 75_621
|
data/adapters/invoice.rb
CHANGED
@@ -18,7 +18,7 @@ module Lighstorm
|
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.decode_pay_req(grpc,
|
21
|
+
def self.decode_pay_req(grpc, code = nil)
|
22
22
|
adapted = {
|
23
23
|
_source: :decode_pay_req,
|
24
24
|
_key: Digest::SHA256.hexdigest(
|
@@ -43,7 +43,7 @@ module Lighstorm
|
|
43
43
|
}
|
44
44
|
}
|
45
45
|
|
46
|
-
adapted[:code] =
|
46
|
+
adapted[:code] = code unless code.nil?
|
47
47
|
|
48
48
|
if grpc[:features].key?(30) && grpc[:features][30][:is_required]
|
49
49
|
raise "unexpected feature[30] name #{grpc[:features][30][:name]}" if grpc[:features][30][:name] != 'amp'
|
@@ -16,7 +16,7 @@ module Lighstorm
|
|
16
16
|
).to_h
|
17
17
|
end
|
18
18
|
|
19
|
-
def self.prepare(payable:, expires_in:, description: nil,
|
19
|
+
def self.prepare(payable:, expires_in:, description: nil, amount: nil)
|
20
20
|
request = {
|
21
21
|
service: :lightning,
|
22
22
|
method: :add_invoice,
|
@@ -28,7 +28,7 @@ module Lighstorm
|
|
28
28
|
}
|
29
29
|
}
|
30
30
|
|
31
|
-
request[:params][:value_msat] = millisatoshis unless
|
31
|
+
request[:params][:value_msat] = amount[:millisatoshis] unless amount.nil?
|
32
32
|
|
33
33
|
if payable.to_sym == :indefinitely
|
34
34
|
request[:params][:is_amp] = true
|
@@ -55,10 +55,10 @@ module Lighstorm
|
|
55
55
|
FindBySecretHash.model(data)
|
56
56
|
end
|
57
57
|
|
58
|
-
def self.perform(payable:, expires_in:, description: nil,
|
58
|
+
def self.perform(payable:, expires_in:, description: nil, amount: nil, preview: false, &vcr)
|
59
59
|
grpc_request = prepare(
|
60
60
|
description: description,
|
61
|
-
|
61
|
+
amount: amount,
|
62
62
|
expires_in: expires_in,
|
63
63
|
payable: payable
|
64
64
|
)
|
@@ -18,8 +18,8 @@ module Lighstorm
|
|
18
18
|
Payment::Pay.dispatch(grpc_request, &vcr)
|
19
19
|
end
|
20
20
|
|
21
|
-
def self.fetch(
|
22
|
-
Payment::Pay.fetch(
|
21
|
+
def self.fetch(code, &vcr)
|
22
|
+
Payment::Pay.fetch(code, &vcr)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.adapt(data, node_get_info)
|
@@ -30,19 +30,23 @@ module Lighstorm
|
|
30
30
|
Payment::Pay.model(data)
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.prepare(
|
33
|
+
def self.prepare(code:, times_out_in:, amount: nil, fee: nil, message: nil)
|
34
34
|
request = {
|
35
35
|
service: :router,
|
36
36
|
method: :send_payment_v2,
|
37
37
|
params: {
|
38
|
-
payment_request:
|
38
|
+
payment_request: code,
|
39
39
|
timeout_seconds: Helpers::TimeExpression.seconds(times_out_in),
|
40
40
|
allow_self_payment: true,
|
41
41
|
dest_custom_records: {}
|
42
42
|
}
|
43
43
|
}
|
44
44
|
|
45
|
-
request[:params][:amt_msat] = millisatoshis unless
|
45
|
+
request[:params][:amt_msat] = amount[:millisatoshis] unless amount.nil?
|
46
|
+
|
47
|
+
unless fee.nil? || fee[:maximum].nil? || fee[:maximum][:millisatoshis].nil?
|
48
|
+
request[:params][:fee_limit_msat] = fee[:maximum][:millisatoshis]
|
49
|
+
end
|
46
50
|
|
47
51
|
if !message.nil? && !message.empty?
|
48
52
|
# https://github.com/satoshisstream/satoshis.stream/blob/main/TLV_registry.md
|
@@ -55,11 +59,15 @@ module Lighstorm
|
|
55
59
|
end
|
56
60
|
|
57
61
|
def self.perform(
|
58
|
-
times_out_in:,
|
62
|
+
times_out_in:, code:,
|
63
|
+
amount: nil, fee: nil,
|
64
|
+
message: nil,
|
65
|
+
preview: false, &vcr
|
59
66
|
)
|
60
67
|
grpc_request = prepare(
|
61
|
-
|
62
|
-
|
68
|
+
code: code,
|
69
|
+
amount: amount,
|
70
|
+
fee: fee,
|
63
71
|
message: message,
|
64
72
|
times_out_in: times_out_in
|
65
73
|
)
|
@@ -70,7 +78,7 @@ module Lighstorm
|
|
70
78
|
|
71
79
|
Payment::Pay.raise_error_if_exists!(response)
|
72
80
|
|
73
|
-
data = fetch(
|
81
|
+
data = fetch(code, &vcr)
|
74
82
|
|
75
83
|
adapted = adapt(response, data)
|
76
84
|
|
@@ -8,17 +8,17 @@ module Lighstorm
|
|
8
8
|
module Controllers
|
9
9
|
module Invoice
|
10
10
|
module Decode
|
11
|
-
def self.fetch(
|
11
|
+
def self.fetch(code)
|
12
12
|
{
|
13
|
-
|
14
|
-
decode_pay_req: Ports::GRPC.lightning.decode_pay_req(pay_req:
|
13
|
+
_code: code,
|
14
|
+
decode_pay_req: Ports::GRPC.lightning.decode_pay_req(pay_req: code).to_h
|
15
15
|
}
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.adapt(raw)
|
19
19
|
{
|
20
20
|
decode_pay_req: Lighstorm::Adapter::Invoice.decode_pay_req(
|
21
|
-
raw[:decode_pay_req], raw[:
|
21
|
+
raw[:decode_pay_req], raw[:_code]
|
22
22
|
)
|
23
23
|
}
|
24
24
|
end
|
@@ -27,8 +27,8 @@ module Lighstorm
|
|
27
27
|
adapted[:decode_pay_req]
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.data(
|
31
|
-
raw = vcr.nil? ? fetch(
|
30
|
+
def self.data(code, &vcr)
|
31
|
+
raw = vcr.nil? ? fetch(code) : vcr.call(-> { fetch(code) })
|
32
32
|
|
33
33
|
adapted = adapt(raw)
|
34
34
|
|
data/controllers/invoice.rb
CHANGED
@@ -24,13 +24,13 @@ module Lighstorm
|
|
24
24
|
FindBySecretHash.model(FindBySecretHash.data(secret_hash))
|
25
25
|
end
|
26
26
|
|
27
|
-
def self.decode(
|
28
|
-
Decode.model(Decode.data(
|
27
|
+
def self.decode(code, &vcr)
|
28
|
+
Decode.model(Decode.data(code, &vcr))
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.create(
|
32
32
|
payable:,
|
33
|
-
description: nil,
|
33
|
+
description: nil, amount: nil,
|
34
34
|
# Lightning Invoice Expiration: UX Considerations
|
35
35
|
# https://d.elor.me/2022/01/lightning-invoice-expiration-ux-considerations/
|
36
36
|
expires_in: { hours: 24 },
|
@@ -39,7 +39,7 @@ module Lighstorm
|
|
39
39
|
Create.perform(
|
40
40
|
payable: payable,
|
41
41
|
description: description,
|
42
|
-
|
42
|
+
amount: amount,
|
43
43
|
expires_in: expires_in,
|
44
44
|
preview: preview,
|
45
45
|
&vcr
|
@@ -34,7 +34,7 @@ module Lighstorm
|
|
34
34
|
Payment::Pay.model(data)
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.prepare(public_key:,
|
37
|
+
def self.prepare(public_key:, amount:, times_out_in:, secret:, through:, fee: nil, message: nil)
|
38
38
|
# Appreciation note for people that suffered in the past and shared
|
39
39
|
# their knowledge, so we don't have to struggle the same:
|
40
40
|
# - https://github.com/lightningnetwork/lnd/discussions/6357
|
@@ -46,7 +46,7 @@ module Lighstorm
|
|
46
46
|
method: :send_payment_v2,
|
47
47
|
params: {
|
48
48
|
dest: [public_key].pack('H*'),
|
49
|
-
amt_msat: millisatoshis,
|
49
|
+
amt_msat: amount[:millisatoshis],
|
50
50
|
timeout_seconds: Helpers::TimeExpression.seconds(times_out_in),
|
51
51
|
allow_self_payment: true,
|
52
52
|
dest_custom_records: {}
|
@@ -58,6 +58,10 @@ module Lighstorm
|
|
58
58
|
request[:params][:dest_custom_records][34_349_334] = message
|
59
59
|
end
|
60
60
|
|
61
|
+
unless fee.nil? || fee[:maximum].nil? || fee[:maximum][:millisatoshis].nil?
|
62
|
+
request[:params][:fee_limit_msat] = fee[:maximum][:millisatoshis]
|
63
|
+
end
|
64
|
+
|
61
65
|
if through.to_sym == :keysend
|
62
66
|
request[:params][:payment_hash] = [secret[:hash]].pack('H*')
|
63
67
|
request[:params][:dest_custom_records][5_482_373_484] = [secret[:preimage]].pack('H*')
|
@@ -71,8 +75,8 @@ module Lighstorm
|
|
71
75
|
end
|
72
76
|
|
73
77
|
def self.perform(
|
74
|
-
public_key:,
|
75
|
-
times_out_in:,
|
78
|
+
public_key:, amount:, through:,
|
79
|
+
times_out_in:, fee: nil,
|
76
80
|
message: nil, secret: nil,
|
77
81
|
preview: false, &vcr
|
78
82
|
)
|
@@ -80,7 +84,8 @@ module Lighstorm
|
|
80
84
|
|
81
85
|
grpc_request = prepare(
|
82
86
|
public_key: public_key,
|
83
|
-
|
87
|
+
amount: amount,
|
88
|
+
fee: fee,
|
84
89
|
through: through,
|
85
90
|
times_out_in: times_out_in,
|
86
91
|
secret: secret,
|
@@ -30,15 +30,15 @@ module Lighstorm
|
|
30
30
|
vcr.nil? ? call(grpc_request) : vcr.call(-> { call(grpc_request) }, :dispatch)
|
31
31
|
end
|
32
32
|
|
33
|
-
def self.fetch_all(
|
33
|
+
def self.fetch_all(code)
|
34
34
|
{
|
35
|
-
invoice_decode:
|
35
|
+
invoice_decode: code.nil? ? nil : Invoice::Decode.data(code),
|
36
36
|
node_myself: Node::Myself.data
|
37
37
|
}
|
38
38
|
end
|
39
39
|
|
40
|
-
def self.fetch(
|
41
|
-
raw = vcr.nil? ? fetch_all(
|
40
|
+
def self.fetch(code = nil, &vcr)
|
41
|
+
raw = vcr.nil? ? fetch_all(code) : vcr.call(-> { fetch_all(code) })
|
42
42
|
end
|
43
43
|
|
44
44
|
def self.adapt(grpc_data, fetch_data)
|
data/controllers/payment/all.rb
CHANGED
@@ -108,9 +108,13 @@ module Lighstorm
|
|
108
108
|
|
109
109
|
next if fetch[:get_node_info] == false || data[:get_node_info][hop[:pub_key]]
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
111
|
+
begin
|
112
|
+
data[:get_node_info][hop[:pub_key]] = grpc.lightning.get_node_info(
|
113
|
+
pub_key: hop[:pub_key]
|
114
|
+
).to_h
|
115
|
+
rescue StandardError => e
|
116
|
+
data[:get_node_info][hop[:pub_key]] = { _error: e }
|
117
|
+
end
|
114
118
|
end
|
115
119
|
end
|
116
120
|
end
|
@@ -151,24 +155,36 @@ module Lighstorm
|
|
151
155
|
end
|
152
156
|
|
153
157
|
unless fetch[:get_node_info] == false || data[:get_node_info][channel[:node1_pub]]
|
154
|
-
|
155
|
-
|
156
|
-
|
158
|
+
begin
|
159
|
+
data[:get_node_info][channel[:node1_pub]] = grpc.lightning.get_node_info(
|
160
|
+
pub_key: channel[:node1_pub]
|
161
|
+
).to_h
|
162
|
+
rescue StandardError => e
|
163
|
+
data[:get_node_info][channel[:node1_pub]] = { _error: e }
|
164
|
+
end
|
157
165
|
end
|
158
166
|
|
159
167
|
next if fetch[:get_node_info] == false || data[:get_node_info][channel[:node2_pub]]
|
160
168
|
|
161
|
-
|
162
|
-
|
163
|
-
|
169
|
+
begin
|
170
|
+
data[:get_node_info][channel[:node2_pub]] = grpc.lightning.get_node_info(
|
171
|
+
pub_key: channel[:node2_pub]
|
172
|
+
).to_h
|
173
|
+
rescue StandardError => e
|
174
|
+
data[:get_node_info][channel[:node2_pub]] = { _error: e }
|
175
|
+
end
|
164
176
|
end
|
165
177
|
|
166
178
|
data[:list_channels].each_value do |channel|
|
167
179
|
next if fetch[:get_node_info] == false || data[:get_node_info][channel[:remote_pubkey]]
|
168
180
|
|
169
|
-
|
170
|
-
|
171
|
-
|
181
|
+
begin
|
182
|
+
data[:get_node_info][channel[:remote_pubkey]] = grpc.lightning.get_node_info(
|
183
|
+
pub_key: channel[:remote_pubkey]
|
184
|
+
).to_h
|
185
|
+
rescue StandardError => e
|
186
|
+
data[:get_node_info][channel[:remote_pubkey]] = { _error: e }
|
187
|
+
end
|
172
188
|
end
|
173
189
|
|
174
190
|
data[:@meta] = { calls: grpc.calls }
|
@@ -223,6 +239,8 @@ module Lighstorm
|
|
223
239
|
end
|
224
240
|
|
225
241
|
raw[:get_node_info].each_key do |key|
|
242
|
+
next if raw[:get_node_info][key][:_error]
|
243
|
+
|
226
244
|
adapted[:get_node_info][key] = Lighstorm::Adapter::Node.get_node_info(
|
227
245
|
raw[:get_node_info][key]
|
228
246
|
)
|
data/docs/README.md
CHANGED
@@ -27,7 +27,7 @@ Lighstorm::Channel.mine.first.myself.node.alias
|
|
27
27
|
Add to your `Gemfile`:
|
28
28
|
|
29
29
|
```ruby
|
30
|
-
gem 'lighstorm', '~> 0.0.
|
30
|
+
gem 'lighstorm', '~> 0.0.10'
|
31
31
|
```
|
32
32
|
|
33
33
|
Run `bundle install`.
|
@@ -60,23 +60,25 @@ Lighstorm.config!(
|
|
60
60
|
```ruby
|
61
61
|
require 'lighstorm'
|
62
62
|
|
63
|
-
puts Lighstorm.version # => 0.0.
|
63
|
+
puts Lighstorm.version # => 0.0.10
|
64
64
|
|
65
65
|
Lighstorm::Invoice.create(
|
66
|
-
description: 'Coffee', millisatoshis: 1000, payable: 'once'
|
66
|
+
description: 'Coffee', amount: { millisatoshis: 1000 }, payable: 'once'
|
67
67
|
)
|
68
68
|
|
69
|
-
Lighstorm::Invoice.decode(
|
70
|
-
|
71
|
-
).pay
|
69
|
+
Lighstorm::Invoice.decode('lnbc20m1pv...qqdhhwkj').pay
|
70
|
+
|
71
|
+
Lighstorm::Invoice.decode('lnbc20m1pv...qqdhhwkj').pay(
|
72
|
+
fee: { maximum: { millisatoshis: 1000 } }
|
73
|
+
)
|
72
74
|
|
73
75
|
Lighstorm::Node.find_by_public_key(
|
74
76
|
'02d3c80335a8ccb2ed364c06875f32240f36f7edb37d80f8dbe321b4c364b6e997'
|
75
|
-
).pay(millisatoshis: 1000)
|
77
|
+
).pay(amount: { millisatoshis: 1000 })
|
76
78
|
|
77
79
|
Lighstorm::Node.find_by_public_key(
|
78
80
|
'02d3c80335a8ccb2ed364c06875f32240f36f7edb37d80f8dbe321b4c364b6e997'
|
79
|
-
).send_message('Hello from Lighstorm!', millisatoshis: 1000)
|
81
|
+
).send_message('Hello from Lighstorm!', amount: { millisatoshis: 1000 })
|
80
82
|
|
81
83
|
Lighstorm::Node.myself.alias # => icebaker/old-stone
|
82
84
|
Lighstorm::Node.myself.public_key # => 02d3...e997
|
@@ -264,23 +266,25 @@ destination = Lighstorm::Node.find_by_public_key(
|
|
264
266
|
|
265
267
|
destination.alias # => 'icebaker/old-stone'
|
266
268
|
|
267
|
-
destination.pay(millisatoshis: 1000)
|
269
|
+
destination.pay(amount: { millisatoshis: 1000 })
|
268
270
|
|
269
271
|
destination.pay(
|
270
|
-
millisatoshis: 1500,
|
272
|
+
amount: { millisatoshis: 1500 },
|
273
|
+
fee: { maximum: { millisatoshis: 1000 } },
|
271
274
|
message: 'Hello from Lighstorm!',
|
272
275
|
through: 'amp',
|
273
276
|
times_out_in: { seconds: 5 }
|
274
277
|
)
|
275
278
|
|
276
279
|
destination.pay(
|
277
|
-
millisatoshis: 1200,
|
280
|
+
amount: { millisatoshis: 1200 },
|
281
|
+
fee: { maximum: { millisatoshis: 1000 } },
|
278
282
|
message: 'Hello from Lighstorm!',
|
279
283
|
through: 'keysend',
|
280
284
|
times_out_in: { seconds: 5 }
|
281
285
|
)
|
282
286
|
|
283
|
-
action = destination.pay(millisatoshis: 1000)
|
287
|
+
action = destination.pay(amount: { millisatoshis: 1000 })
|
284
288
|
action.result.fee.millisatoshis
|
285
289
|
```
|
286
290
|
|
@@ -295,23 +299,31 @@ destination = Lighstorm::Node.find_by_public_key(
|
|
295
299
|
|
296
300
|
destination.alias # => 'icebaker/old-stone'
|
297
301
|
|
298
|
-
destination.send_message(
|
302
|
+
destination.send_message(
|
303
|
+
'Hello from Lighstorm!',
|
304
|
+
amount: { millisatoshis: 1000 }
|
305
|
+
)
|
299
306
|
|
300
307
|
destination.send_message(
|
301
308
|
'Hello from Lighstorm!',
|
302
|
-
millisatoshis: 1000,
|
309
|
+
amount: { millisatoshis: 1000 },
|
310
|
+
fee: { maximum: { millisatoshis: 1000 } },
|
303
311
|
through: 'amp',
|
304
312
|
times_out_in: { seconds: 5 }
|
305
313
|
)
|
306
314
|
|
307
315
|
destination.send_message(
|
308
316
|
'Hello from Lighstorm!',
|
309
|
-
millisatoshis: 1000,
|
317
|
+
amount: { millisatoshis: 1000 },
|
318
|
+
fee: { maximum: { millisatoshis: 1000 } },
|
310
319
|
through: 'keysend',
|
311
320
|
times_out_in: { seconds: 5 }
|
312
321
|
)
|
313
322
|
|
314
|
-
action = destination.send_message(
|
323
|
+
action = destination.send_message(
|
324
|
+
'Hello from Lighstorm!',
|
325
|
+
amount: { millisatoshis: 1000 }
|
326
|
+
)
|
315
327
|
action.result.fee.millisatoshis
|
316
328
|
```
|
317
329
|
|
@@ -485,12 +497,12 @@ invoice.secret.hash
|
|
485
497
|
# 'preview' let you check the expected operation
|
486
498
|
# before actually performing it for debug purposes
|
487
499
|
preview = Lighstorm::Invoice.create(
|
488
|
-
description: 'Coffee', millisatoshis: 1000,
|
500
|
+
description: 'Coffee', amount: { millisatoshis: 1000 },
|
489
501
|
payable: 'once', preview: true
|
490
502
|
)
|
491
503
|
|
492
504
|
action = Lighstorm::Invoice.create(
|
493
|
-
description: 'Coffee', millisatoshis: 1000,
|
505
|
+
description: 'Coffee', amount: { millisatoshis: 1000 },
|
494
506
|
payable: 'once', expires_in: { minutes: 5 }
|
495
507
|
)
|
496
508
|
|
@@ -504,7 +516,7 @@ action = Lighstorm::Invoice.create(
|
|
504
516
|
)
|
505
517
|
|
506
518
|
action = Lighstorm::Invoice.create(
|
507
|
-
description: 'Concert Ticket', millisatoshis: 500000000,
|
519
|
+
description: 'Concert Ticket', amount: { millisatoshis: 500000000 },
|
508
520
|
payable: 'indefinitely', expires_in: { days: 5 }
|
509
521
|
)
|
510
522
|
|
@@ -547,7 +559,8 @@ payment.hops.size
|
|
547
559
|
|
548
560
|
```ruby
|
549
561
|
invoice.pay(
|
550
|
-
millisatoshis: 1500,
|
562
|
+
amount: { millisatoshis: 1500 },
|
563
|
+
fee: { maximum: { millisatoshis: 1000 } },
|
551
564
|
message: 'here we go',
|
552
565
|
times_out_in: { seconds: 5 }
|
553
566
|
)
|
@@ -568,7 +581,7 @@ end
|
|
568
581
|
|
569
582
|
```ruby
|
570
583
|
begin
|
571
|
-
invoice.pay(millisatoshis: 1000)
|
584
|
+
invoice.pay(amount: { millisatoshis: 1000 })
|
572
585
|
rescue AmountForNonZeroError => error
|
573
586
|
error.message # 'Millisatoshis must not be specified...'
|
574
587
|
error.grpc.class # GRPC::Unknown
|
@@ -990,7 +1003,7 @@ gem 'lighstorm', path: '/home/user/lighstorm'
|
|
990
1003
|
# demo.rb
|
991
1004
|
require 'lighstorm'
|
992
1005
|
|
993
|
-
puts Lighstorm.version # => 0.0.
|
1006
|
+
puts Lighstorm.version # => 0.0.10
|
994
1007
|
```
|
995
1008
|
|
996
1009
|
```sh
|
@@ -1050,13 +1063,15 @@ The downside is that we can't [lazy-load](https://en.wikipedia.org/wiki/Lazy_loa
|
|
1050
1063
|
To perform an _action_, like creating an Invoice, you:
|
1051
1064
|
```ruby
|
1052
1065
|
Lighstorm::Invoice.create(
|
1053
|
-
description: 'Coffee', millisatoshis: 1000
|
1066
|
+
description: 'Coffee', amount: { millisatoshis: 1000 }
|
1054
1067
|
)
|
1055
1068
|
```
|
1056
1069
|
|
1057
1070
|
Internally, what's happening:
|
1058
1071
|
```ruby
|
1059
|
-
action = Lighstorm::Invoice.create(
|
1072
|
+
action = Lighstorm::Invoice.create(
|
1073
|
+
description: 'Coffee', amount: { millisatoshis: 1000 }
|
1074
|
+
)
|
1060
1075
|
|
1061
1076
|
request = Controllers::Invoice::Create.prepare(params) # pure
|
1062
1077
|
response = Controllers::Invoice::Create.dispatch(request) # side effect
|
@@ -1225,13 +1240,13 @@ gem build lighstorm.gemspec
|
|
1225
1240
|
|
1226
1241
|
gem signin
|
1227
1242
|
|
1228
|
-
gem push lighstorm-0.0.
|
1243
|
+
gem push lighstorm-0.0.10.gem
|
1229
1244
|
```
|
1230
1245
|
|
1231
1246
|
_________________
|
1232
1247
|
|
1233
1248
|
<center>
|
1234
|
-
lighstorm 0.0.
|
1249
|
+
lighstorm 0.0.10
|
1235
1250
|
|
|
1236
1251
|
<a href="https://github.com/icebaker/lighstorm" rel="noopener noreferrer" target="_blank">GitHub</a>
|
1237
1252
|
|
|
data/docs/_coverpage.md
CHANGED
data/docs/index.html
CHANGED
data/models/invoice.rb
CHANGED
@@ -84,7 +84,8 @@ module Lighstorm
|
|
84
84
|
end
|
85
85
|
|
86
86
|
def pay(
|
87
|
-
|
87
|
+
amount: nil, message: nil, route: nil,
|
88
|
+
fee: nil,
|
88
89
|
times_out_in: { seconds: 5 },
|
89
90
|
preview: false
|
90
91
|
)
|
@@ -92,8 +93,9 @@ module Lighstorm
|
|
92
93
|
Controllers::Invoice::PayThroughRoute.perform(self, route: route, preview: preview)
|
93
94
|
else
|
94
95
|
Controllers::Invoice::Pay.perform(
|
95
|
-
|
96
|
-
|
96
|
+
code: code,
|
97
|
+
amount: amount,
|
98
|
+
fee: fee,
|
97
99
|
message: message,
|
98
100
|
times_out_in: times_out_in,
|
99
101
|
preview: preview
|
data/models/nodes/node.rb
CHANGED
@@ -100,13 +100,14 @@ module Lighstorm
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def send_message(
|
103
|
-
message,
|
103
|
+
message, amount:, fee: nil, secret: nil,
|
104
104
|
times_out_in: { seconds: 5 }, through: 'amp',
|
105
105
|
preview: false
|
106
106
|
)
|
107
107
|
pay(
|
108
108
|
message: message,
|
109
|
-
|
109
|
+
amount: amount,
|
110
|
+
fee: fee,
|
110
111
|
secret: secret,
|
111
112
|
times_out_in: times_out_in,
|
112
113
|
through: through,
|
@@ -115,13 +116,15 @@ module Lighstorm
|
|
115
116
|
end
|
116
117
|
|
117
118
|
def pay(
|
118
|
-
|
119
|
+
amount:, message: nil, secret: nil,
|
120
|
+
fee: nil,
|
119
121
|
times_out_in: { seconds: 5 }, through: 'amp',
|
120
122
|
preview: false
|
121
123
|
)
|
122
124
|
Controllers::Node::Pay.perform(
|
123
125
|
public_key: public_key,
|
124
|
-
|
126
|
+
amount: amount,
|
127
|
+
fee: fee,
|
125
128
|
through: through,
|
126
129
|
secret: secret,
|
127
130
|
message: message,
|
data/models/secret.rb
CHANGED
@@ -7,9 +7,15 @@ module Lighstorm
|
|
7
7
|
class Secret
|
8
8
|
attr_reader :preimage, :hash
|
9
9
|
|
10
|
-
def self.
|
10
|
+
def self.generate
|
11
11
|
data = { preimage: SecureRandom.hex(32) }
|
12
12
|
data[:hash] = Digest::SHA256.hexdigest([data[:preimage]].pack('H*'))
|
13
|
+
data
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.create(&vcr)
|
17
|
+
data = vcr.nil? ? generate : vcr.call(-> { generate })
|
18
|
+
|
13
19
|
Secret.new(data)
|
14
20
|
end
|
15
21
|
|
data/static/spec.rb
CHANGED
@@ -4,7 +4,7 @@ module Lighstorm
|
|
4
4
|
module Static
|
5
5
|
SPEC = {
|
6
6
|
name: 'lighstorm',
|
7
|
-
version: '0.0.
|
7
|
+
version: '0.0.10',
|
8
8
|
author: 'icebaker',
|
9
9
|
summary: 'API for interacting with a Lightning Node.',
|
10
10
|
description: 'Lighstorm is an opinionated abstraction layer on top of the lnd-client for interacting with a Lightning Node.',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lighstorm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- icebaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-03-
|
11
|
+
date: 2023-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|