lighstorm 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9138a744ed51a4f15025f97f27e09ec5f3b100ef8def0a6d992895cb42f8b0c
4
- data.tar.gz: 85435136bfbb78cc7c6baa74ea6a745e958d8eb3d3f08d42ef42d03a1d2230eb
3
+ metadata.gz: bea078c4355c1f245ed7800a6d235763e325d3c4cf71e42f14589513eb69a429
4
+ data.tar.gz: 026c1c57b2dc8a6d06cebc2155f32189b7d998574d1e802b8e64f90ae63938ae
5
5
  SHA512:
6
- metadata.gz: e728481bdafde3c30dc23e85a8a48d0d3a5ac020410d14cbafe48b17d86661c2df86bab4f75a65099919adf09b3808ce19f410f915cb7287d2a7802884cc8f0a
7
- data.tar.gz: 6efa2544e1d08c49966b322e10d8cc40f3d1de0238534665148bff8515686be8817abf039442308563d0cc6ee15d3cf71ef1486f55a946103dcdd663a735684b
6
+ metadata.gz: d69e4361ef42951fa5d316a476ce7f2ac63b9ee307198646a2b263601ec0e79d75792b99985767f61a38942401a4e3d24d8ff5b938b7e4fddcb8d427b566d2b4
7
+ data.tar.gz: 85de98976d458ba9279291f37ae4cda03c8aa3965a53751932360a546b406004915d5035666bf6b45f624e1eaa8c0e2d2b8b135632cdee3b8c622b83e94b6631
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lighstorm (0.0.5)
4
+ lighstorm (0.0.6)
5
5
  dotenv (~> 2.8, >= 2.8.1)
6
6
  lnd-client (~> 0.0.5)
7
7
  zache (~> 0.12.0)
@@ -50,14 +50,14 @@ GEM
50
50
  diff-lcs (>= 1.2.0, < 2.0)
51
51
  rspec-support (~> 3.12.0)
52
52
  rspec-support (3.12.0)
53
- rubocop (1.45.1)
53
+ rubocop (1.46.0)
54
54
  json (~> 2.3)
55
55
  parallel (~> 1.10)
56
56
  parser (>= 3.2.0.0)
57
57
  rainbow (>= 2.2.2, < 4.0)
58
58
  regexp_parser (>= 1.8, < 3.0)
59
59
  rexml (>= 3.2.5, < 4.0)
60
- rubocop-ast (>= 1.24.1, < 2.0)
60
+ rubocop-ast (>= 1.26.0, < 2.0)
61
61
  ruby-progressbar (~> 1.7)
62
62
  unicode-display_width (>= 2.4.0, < 3.0)
63
63
  rubocop-ast (1.26.0)
data/README.md CHANGED
@@ -33,7 +33,7 @@ Although it tries to stay close to [Lightning's terminologies](https://docs.ligh
33
33
  Add to your `Gemfile`:
34
34
 
35
35
  ```ruby
36
- gem 'lighstorm', '~> 0.0.5'
36
+ gem 'lighstorm', '~> 0.0.6'
37
37
  ```
38
38
 
39
39
  ```ruby
@@ -45,7 +45,7 @@ Lighstorm.config!(
45
45
  macaroon_path: '/lnd/data/chain/bitcoin/mainnet/admin.macaroon',
46
46
  )
47
47
 
48
- puts Lighstorm.version # => 0.0.5
48
+ puts Lighstorm.version # => 0.0.6
49
49
 
50
50
  Lighstorm::Satoshis.new(
51
51
  milisatoshis: 75_621_650
@@ -67,7 +67,7 @@ gem 'lighstorm', path: '/home/user/lighstorm'
67
67
  # demo.rb
68
68
  require 'lighstorm'
69
69
 
70
- puts Lighstorm.version # => 0.0.5
70
+ puts Lighstorm.version # => 0.0.6
71
71
  ```
72
72
 
73
73
  ```sh
@@ -100,5 +100,5 @@ gem build lighstorm.gemspec
100
100
 
101
101
  gem signin
102
102
 
103
- gem push lighstorm-0.0.5.gem
103
+ gem push lighstorm-0.0.6.gem
104
104
  ```
data/adapters/invoice.rb CHANGED
@@ -29,7 +29,7 @@ module Lighstorm
29
29
  {
30
30
  _key: _key(grpc),
31
31
  created_at: Time.at(grpc[:creation_date]),
32
- settle_at: Time.at(grpc[:settle_date]),
32
+ settle_at: grpc[:settle_date].nil? || !grpc[:settle_date].positive? ? nil : Time.at(grpc[:settle_date]),
33
33
  state: grpc[:state].to_s.downcase
34
34
  }
35
35
  end
@@ -2,14 +2,13 @@
2
2
 
3
3
  require_relative '../../../ports/grpc'
4
4
  require_relative '../../../models/errors'
5
+ require_relative '../../invoice'
5
6
 
6
7
  module Lighstorm
7
8
  module Controllers
8
9
  module Invoice
9
10
  module Create
10
- def self.perform(description: nil, milisatoshis: nil, preview: false, fake: false)
11
- raise Errors::ToDoError, self
12
-
11
+ def self.perform(description: nil, milisatoshis: nil, preview: false, fake: nil)
13
12
  grpc_request = {
14
13
  service: :lightning,
15
14
  method: :add_invoice,
@@ -22,13 +21,15 @@ module Lighstorm
22
21
  return grpc_request if preview
23
22
 
24
23
  # expiry: Default is 86400 (24 hours).
25
- response = LND.instance.middleware("lightning.#{grpc_request[:method]}") do
26
- LND.instance.client.lightning.send(grpc_request[:method], grpc_request[:params])
27
- end
24
+ response = if fake.nil?
25
+ LND.instance.middleware("lightning.#{grpc_request[:method]}") do
26
+ LND.instance.client.lightning.send(grpc_request[:method], grpc_request[:params])
27
+ end.to_h
28
+ else
29
+ fake
30
+ end
28
31
 
29
- # TODO
30
- # find_by_secret_hash(invoice.r_hash.unpack1('H*'))
31
- # response
32
+ Invoice.find_by_secret_hash(response[:r_hash].unpack1('H*'))
32
33
  end
33
34
  end
34
35
  end
@@ -23,7 +23,7 @@ module Lighstorm
23
23
  FindBySecretHash.model(FindBySecretHash.data(secret_hash))
24
24
  end
25
25
 
26
- def self.create(description: nil, milisatoshis: nil, preview: false, fake: false)
26
+ def self.create(description: nil, milisatoshis: nil, preview: false, fake: nil)
27
27
  Create.perform(
28
28
  description: description,
29
29
  milisatoshis: milisatoshis,
data/docs/README.md CHANGED
@@ -23,7 +23,7 @@ Lighstorm::Channel.mine.first.myself.node.alias
23
23
  Add to your `Gemfile`:
24
24
 
25
25
  ```ruby
26
- gem 'lighstorm', '~> 0.0.5'
26
+ gem 'lighstorm', '~> 0.0.6'
27
27
  ```
28
28
 
29
29
  Run `bundle install`.
@@ -56,7 +56,7 @@ Lighstorm.config!(
56
56
  ```ruby
57
57
  require 'lighstorm'
58
58
 
59
- puts Lighstorm.version # => 0.0.5
59
+ puts Lighstorm.version # => 0.0.6
60
60
 
61
61
  Lighstorm::Satoshis.new(
62
62
  milisatoshis: 75_621_650
@@ -396,6 +396,8 @@ channel.myself.policy.htlc.blocks.delta.minimum
396
396
  ```ruby
397
397
  channel = Lighstorm::Channel.mine.first
398
398
 
399
+ # 'preview' let you check the expected operation
400
+ # before actually performing it for debug purposes
399
401
  channel.myself.policy.fee.update(
400
402
  { rate: { parts_per_million: 25 } }, preview: true
401
403
  )
@@ -415,6 +417,8 @@ channel.myself.policy.fee.update(
415
417
 
416
418
  ## Invoice
417
419
 
420
+ [Understanding Lightning Invoices](https://docs.lightning.engineering/the-lightning-network/payment-lifecycle/understanding-lightning-invoices)
421
+
418
422
  ```ruby
419
423
  Lighstorm::Invoice
420
424
  Lighstorm::Invoice.all
@@ -452,6 +456,22 @@ invoice.request.secret.hash
452
456
  invoice.request.address
453
457
  ```
454
458
 
459
+ ### Operations
460
+
461
+ [Understanding Lightning Invoices](https://docs.lightning.engineering/the-lightning-network/payment-lifecycle/understanding-lightning-invoices)
462
+
463
+ ```ruby
464
+ # 'preview' let you check the expected operation
465
+ # before actually performing it for debug purposes
466
+ invoice = Lighstorm::Invoice.create(
467
+ milisatoshis: 1000, description: 'Coffee', preview: true
468
+ )
469
+
470
+ invoice = Lighstorm::Invoice.create(
471
+ milisatoshis: 1000, description: 'Piña Colada'
472
+ )
473
+ ```
474
+
455
475
  ## Payment
456
476
 
457
477
  [![This is an image representing Payment as a graph.](https://raw.githubusercontent.com/icebaker/assets/main/lighstorm/graph-payment.png)](https://raw.githubusercontent.com/icebaker/assets/main/lighstorm/graph-payment.png)
@@ -723,7 +743,7 @@ satoshis.parts_per_million(reference_in_milisatoshis)
723
743
  _________________
724
744
 
725
745
  <center>
726
- lighstorm 0.0.5
746
+ lighstorm 0.0.6
727
747
  |
728
748
  <a href="https://github.com/icebaker/lighstorm" rel="noopener noreferrer" target="_blank">GitHub</a>
729
749
  |
data/docs/_coverpage.md CHANGED
@@ -5,7 +5,7 @@
5
5
  - Make your Satoshis flow.
6
6
  - Unleash the power of Graphs.
7
7
 
8
- 0.0.5
8
+ 0.0.6
9
9
 
10
10
  [Documentation](README)
11
11
  [GitHub](https://github.com/icebaker/lighstorm)
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.5',
21
+ name: 'Lighstorm 0.0.6',
22
22
  repo: 'https://github.com/icebaker/lighstorm'
23
23
  }
24
24
  </script>
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.5',
7
+ version: '0.0.6',
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,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lighstorm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - icebaker