lighstorm 0.0.9 → 0.0.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 551ffb5be38f96d6c0bb4f7b8fbde5763c623f0d100f0a1b34acb90a6074fb23
4
- data.tar.gz: 59451d54f2ad6d45c95c7649ab0a048a4adeb7a15f1af08f133d8eaae107d9bc
3
+ metadata.gz: ed188ef291ac08a9cc6f91dca92931be2c88257ee184416fd0f40a3224740b20
4
+ data.tar.gz: 1be060a12d9e755354764cc8151da8a26e114fcc9a0ecac470e9fe9b685a60a4
5
5
  SHA512:
6
- metadata.gz: 54e1e6929a1f5dc67f319461d6fc3799dd5cd5c349224c19198a6bffd203bd3e6431fb6bf571976c2a1c0d3d1d07ceb9cb272206f06794c52595c4ec8d5d57d3
7
- data.tar.gz: a903325535c6c2e98b95c4e54cb51f7bbd7123b40dfb2b9143fc9d7a392290230f1bb026c7bd30a669c8f981286ef56acfe0a2bf3751ea9cce5a4d663e160d61
6
+ metadata.gz: b37802f04bae65416f4e80590506518025d62f1ca9b502b97db3cc108792b13a077f2ebb89c3e0be4cf311fb10a53f916a3c37e2f6c729b9bf01f187b0ab4892
7
+ data.tar.gz: ac5f5a1f5f4ff271ab2ddef517763f380f1868b71339bcf1758975e35c7e520ddd65fddb9d210539fedde2dc3830912db8b0bbdbfed1aa454e781c8a6e43e948
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lighstorm (0.0.9)
4
+ lighstorm (0.0.10)
5
5
  dotenv (~> 2.8, >= 2.8.1)
6
6
  lnd-client (~> 0.0.5)
7
7
  zache (~> 0.12.0)
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.9'
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.9
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', millisatoshis: 1_000,
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, request_code = nil)
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] = request_code unless request_code.nil?
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, millisatoshis: 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 millisatoshis.nil?
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, millisatoshis: nil, preview: false, &vcr)
58
+ def self.perform(payable:, expires_in:, description: nil, amount: nil, preview: false, &vcr)
59
59
  grpc_request = prepare(
60
60
  description: description,
61
- millisatoshis: millisatoshis,
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(request_code, &vcr)
22
- Payment::Pay.fetch(request_code, &vcr)
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(request_code:, times_out_in:, millisatoshis: nil, message: nil)
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: request_code,
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 millisatoshis.nil?
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:, request_code:, millisatoshis: nil, message: nil, preview: false, &vcr
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
- request_code: request_code,
62
- millisatoshis: millisatoshis,
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(request_code, &vcr)
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(request_code)
11
+ def self.fetch(code)
12
12
  {
13
- _request_code: request_code,
14
- decode_pay_req: Ports::GRPC.lightning.decode_pay_req(pay_req: request_code).to_h
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[:_request_code]
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(request_code, &vcr)
31
- raw = vcr.nil? ? fetch(request_code) : vcr.call(-> { fetch(request_code) })
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
 
@@ -24,13 +24,13 @@ module Lighstorm
24
24
  FindBySecretHash.model(FindBySecretHash.data(secret_hash))
25
25
  end
26
26
 
27
- def self.decode(request_code, &vcr)
28
- Decode.model(Decode.data(request_code, &vcr))
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, millisatoshis: 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
- millisatoshis: millisatoshis,
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:, millisatoshis:, times_out_in:, secret:, through:, message: nil)
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:, millisatoshis:, through:,
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
- millisatoshis: millisatoshis,
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(request_code)
33
+ def self.fetch_all(code)
34
34
  {
35
- invoice_decode: request_code.nil? ? nil : Invoice::Decode.data(request_code),
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(request_code = nil, &vcr)
41
- raw = vcr.nil? ? fetch_all(request_code) : vcr.call(-> { fetch_all(request_code) })
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)
@@ -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
- data[:get_node_info][hop[:pub_key]] = grpc.lightning.get_node_info(
112
- pub_key: hop[:pub_key]
113
- ).to_h
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
- data[:get_node_info][channel[:node1_pub]] = grpc.lightning.get_node_info(
155
- pub_key: channel[:node1_pub]
156
- ).to_h
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
- data[:get_node_info][channel[:node2_pub]] = grpc.lightning.get_node_info(
162
- pub_key: channel[:node2_pub]
163
- ).to_h
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
- data[:get_node_info][channel[:remote_pubkey]] = grpc.lightning.get_node_info(
170
- pub_key: channel[:remote_pubkey]
171
- ).to_h
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.9'
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.9
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
- 'lnbc20m1pv...qqdhhwkj'
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('Hello from Lighstorm!', millisatoshis: 1000)
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('Hello from Lighstorm!', millisatoshis: 1000)
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.9
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(description: 'Coffee', millisatoshis: 1000)
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.9.gem
1243
+ gem push lighstorm-0.0.10.gem
1229
1244
  ```
1230
1245
 
1231
1246
  _________________
1232
1247
 
1233
1248
  <center>
1234
- lighstorm 0.0.9
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
@@ -8,7 +8,7 @@
8
8
  - Built for maximum **reliability**.
9
9
  - Optimized for programmer **happiness**.
10
10
 
11
- 0.0.9
11
+ 0.0.10
12
12
 
13
13
  ⚠️ _Warning: Early-stage, breaking changes are expected._
14
14
 
data/docs/index.html CHANGED
@@ -18,7 +18,7 @@
18
18
  <script>
19
19
  window.$docsify = {
20
20
  coverpage: true,
21
- name: 'Lighstorm 0.0.9',
21
+ name: 'Lighstorm 0.0.10',
22
22
  repo: 'https://github.com/icebaker/lighstorm'
23
23
  }
24
24
  </script>
data/models/invoice.rb CHANGED
@@ -84,7 +84,8 @@ module Lighstorm
84
84
  end
85
85
 
86
86
  def pay(
87
- millisatoshis: nil, message: nil, route: nil,
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
- request_code: code,
96
- millisatoshis: millisatoshis,
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, millisatoshis:, secret: nil,
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
- millisatoshis: millisatoshis,
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
- millisatoshis:, message: nil, secret: nil,
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
- millisatoshis: millisatoshis,
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.create
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.9',
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.9
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 00:00:00.000000000 Z
11
+ date: 2023-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv