lighstorm 0.0.7 → 0.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3a0597ad2e13c24bcf64efd0e12e2b6c8ae0c7b6b012b6fab89caffd2ac06a9
4
- data.tar.gz: 01fa72d76dcdb97c62a1edd5f8829d8038baba9639de245e75059bbf6309d199
3
+ metadata.gz: 643a80fa54f053a2f647dbeb4df8b959cb0d512a7aa220c338c136220775c960
4
+ data.tar.gz: 5fd770e41ad436cc920c4c3723eeddc4027feb0bb9a3ace19f3856e5f516b948
5
5
  SHA512:
6
- metadata.gz: e7e7d996345446669475259095ad4843783ec21083094e3acbb883fbde421b57efec0d1ca5a495526ee6e1c536920003a3472db21eb6ee2394218bcf07fc235e
7
- data.tar.gz: 8e4b80f814feff68293a6db0ecdc9346640d19e3f761d16fafa5c0f1dcfbea978208dca9c6e186834ef9b28bac0b296f37d5b3aeba5a0b05f4cac06e38bcbc4f
6
+ metadata.gz: 403f808bf48235a765f8c50fb840cddd86c0c77ece348b3b907460c8f84cb932c91fc688ac8e7f488ced08974f1acabd0e5019661de6bdd0956178b657249ac7
7
+ data.tar.gz: 4dbbb229dbe1204dc189d179b2106e55ad45d3ed36f28ded6206674400aeac80595fd45f52f755bd118f90e6e14bfff5f4fc7e096a8b2dfab1bfa94da4ddc430
data/Gemfile CHANGED
@@ -9,6 +9,6 @@ group :test, :development do
9
9
  gem 'dotenv', '~> 2.8', '>= 2.8.1'
10
10
  gem 'pry-byebug', '~> 3.10', '>= 3.10.1'
11
11
  gem 'rspec', '~> 3.12'
12
- gem 'rubocop', '~> 1.45', '>= 1.45.1'
12
+ gem 'rubocop', '~> 1.47'
13
13
  gem 'rubocop-rspec', '~> 2.18', '>= 2.18.1'
14
14
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- lighstorm (0.0.7)
4
+ lighstorm (0.0.8)
5
5
  dotenv (~> 2.8, >= 2.8.1)
6
6
  lnd-client (~> 0.0.5)
7
7
  zache (~> 0.12.0)
@@ -50,7 +50,7 @@ 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.46.0)
53
+ rubocop (1.47.0)
54
54
  json (~> 2.3)
55
55
  parallel (~> 1.10)
56
56
  parser (>= 3.2.0.0)
@@ -60,14 +60,14 @@ GEM
60
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
- rubocop-ast (1.26.0)
63
+ rubocop-ast (1.27.0)
64
64
  parser (>= 3.2.1.0)
65
65
  rubocop-capybara (2.17.1)
66
66
  rubocop (~> 1.41)
67
67
  rubocop-rspec (2.18.1)
68
68
  rubocop (~> 1.33)
69
69
  rubocop-capybara (~> 2.17)
70
- ruby-progressbar (1.11.0)
70
+ ruby-progressbar (1.13.0)
71
71
  unicode-display_width (2.4.2)
72
72
  zache (0.12.0)
73
73
 
@@ -80,7 +80,7 @@ DEPENDENCIES
80
80
  lighstorm!
81
81
  pry-byebug (~> 3.10, >= 3.10.1)
82
82
  rspec (~> 3.12)
83
- rubocop (~> 1.45, >= 1.45.1)
83
+ rubocop (~> 1.47)
84
84
  rubocop-rspec (~> 2.18, >= 2.18.1)
85
85
 
86
86
  BUNDLED WITH
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.7'
37
+ gem 'lighstorm', '~> 0.0.8'
38
38
  ```
39
39
 
40
40
  ```ruby
@@ -46,7 +46,7 @@ Lighstorm.config!(
46
46
  macaroon_path: '/lnd/data/chain/bitcoin/mainnet/admin.macaroon',
47
47
  )
48
48
 
49
- puts Lighstorm.version # => 0.0.7
49
+ puts Lighstorm.version # => 0.0.8
50
50
 
51
51
  Lighstorm::Node.myself.alias # => icebaker/old-stone
52
52
 
data/adapters/invoice.rb CHANGED
@@ -7,6 +7,26 @@ require_relative 'payment_request'
7
7
  module Lighstorm
8
8
  module Adapter
9
9
  class Invoice
10
+ def self.decode_pay_req(grpc, request_code = nil)
11
+ adapted = {
12
+ _source: :decode_pay_req,
13
+ _key: Digest::SHA256.hexdigest(
14
+ [
15
+ grpc[:payment_hash],
16
+ grpc[:num_satoshis],
17
+ grpc[:timestamp],
18
+ grpc[:payment_addr]
19
+ ].join('/')
20
+ ),
21
+ created_at: Time.at(grpc[:timestamp]),
22
+ request: PaymentRequest.decode_pay_req(grpc)
23
+ }
24
+
25
+ adapted[:request][:code] = request_code unless request_code.nil?
26
+
27
+ adapted
28
+ end
29
+
10
30
  def self.add_invoice(grpc)
11
31
  {
12
32
  _source: :add_invoice,
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../ports/grpc'
4
+ require_relative '../../adapters/invoice'
5
+ require_relative '../../models/invoice'
6
+
7
+ module Lighstorm
8
+ module Controllers
9
+ module Invoice
10
+ module Decode
11
+ def self.fetch(request_code)
12
+ {
13
+ _request_code: request_code,
14
+ decode_pay_req: Ports::GRPC.lightning.decode_pay_req(pay_req: request_code).to_h
15
+ }
16
+ end
17
+
18
+ def self.adapt(raw)
19
+ {
20
+ decode_pay_req: Lighstorm::Adapter::Invoice.decode_pay_req(
21
+ raw[:decode_pay_req], raw[:_request_code]
22
+ )
23
+ }
24
+ end
25
+
26
+ def self.transform(adapted)
27
+ adapted[:decode_pay_req]
28
+ end
29
+
30
+ def self.data(request_code, &vcr)
31
+ raw = vcr.nil? ? fetch(request_code) : vcr.call(-> { fetch(request_code) })
32
+
33
+ adapted = adapt(raw)
34
+
35
+ transform(adapted)
36
+ end
37
+
38
+ def self.model(data)
39
+ Lighstorm::Models::Invoice.new(data)
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative './invoice/all'
4
+ require_relative './invoice/decode'
4
5
  require_relative './invoice/find_by_secret_hash'
5
6
  require_relative './invoice/actions/create'
6
7
 
@@ -23,6 +24,10 @@ module Lighstorm
23
24
  FindBySecretHash.model(FindBySecretHash.data(secret_hash))
24
25
  end
25
26
 
27
+ def self.decode(request_code, &vcr)
28
+ Decode.model(Decode.data(request_code, &vcr))
29
+ end
30
+
26
31
  def self.create(description: nil, millisatoshis: nil, preview: false, &vcr)
27
32
  Create.perform(
28
33
  description: description,
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.7'
30
+ gem 'lighstorm', '~> 0.0.8'
31
31
  ```
32
32
 
33
33
  Run `bundle install`.
@@ -60,7 +60,7 @@ Lighstorm.config!(
60
60
  ```ruby
61
61
  require 'lighstorm'
62
62
 
63
- puts Lighstorm.version # => 0.0.7
63
+ puts Lighstorm.version # => 0.0.8
64
64
 
65
65
  Lighstorm::Invoice.create(
66
66
  description: 'Coffee', millisatoshis: 1000
@@ -360,6 +360,8 @@ Lighstorm::Invoice.all(limit: 10)
360
360
  Lighstorm::Invoice.first
361
361
  Lighstorm::Invoice.last
362
362
 
363
+ Lighstorm::Invoice.decode('lnbc20n1pj...0eqps7h0k9')
364
+
363
365
  Lighstorm::Invoice.find_by_secret_hash(
364
366
  '1d438b8100518c9fba0a607e3317d6b36f74ceef3a6591836eb2f679c6853501'
365
367
  )
@@ -765,7 +767,7 @@ gem 'lighstorm', path: '/home/user/lighstorm'
765
767
  # demo.rb
766
768
  require 'lighstorm'
767
769
 
768
- puts Lighstorm.version # => 0.0.7
770
+ puts Lighstorm.version # => 0.0.8
769
771
  ```
770
772
 
771
773
  ```sh
@@ -982,13 +984,13 @@ gem build lighstorm.gemspec
982
984
 
983
985
  gem signin
984
986
 
985
- gem push lighstorm-0.0.7.gem
987
+ gem push lighstorm-0.0.8.gem
986
988
  ```
987
989
 
988
990
  _________________
989
991
 
990
992
  <center>
991
- lighstorm 0.0.7
993
+ lighstorm 0.0.8
992
994
  |
993
995
  <a href="https://github.com/icebaker/lighstorm" rel="noopener noreferrer" target="_blank">GitHub</a>
994
996
  |
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.7
11
+ 0.0.8
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.7',
21
+ name: 'Lighstorm 0.0.8',
22
22
  repo: 'https://github.com/icebaker/lighstorm'
23
23
  }
24
24
  </script>
@@ -12,7 +12,7 @@ module Lighstorm
12
12
  @data = data
13
13
 
14
14
  @_key = data[:_key] || Digest::SHA256.hexdigest(
15
- data[:code] || "#{data[:code][:amount][:millisatoshis]}#{Time.now}"
15
+ data[:code] || "#{data[:amount][:millisatoshis]}#{Time.now}"
16
16
  )
17
17
 
18
18
  @code = data[:code]
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',
7
+ version: '0.0.8',
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - icebaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-28 00:00:00.000000000 Z
11
+ date: 2023-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -102,6 +102,7 @@ files:
102
102
  - controllers/invoice/actions/pay.rb
103
103
  - controllers/invoice/actions/pay_through_route.rb
104
104
  - controllers/invoice/all.rb
105
+ - controllers/invoice/decode.rb
105
106
  - controllers/invoice/find_by_secret_hash.rb
106
107
  - controllers/node.rb
107
108
  - controllers/node/actions/apply_gossip.rb