lighstorm 0.0.13 → 0.0.15
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 +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -7
- data/README.md +2 -2
- data/adapters/connections/channel_node.rb +1 -0
- data/adapters/edges/payment/purpose.rb +3 -3
- data/adapters/edges/payment.rb +1 -3
- data/adapters/invoice.rb +0 -2
- data/adapters/wallet.rb +42 -0
- data/components/cache.rb +1 -1
- data/components/lnd.rb +24 -8
- data/controllers/action.rb +5 -0
- data/controllers/activity/all.rb +85 -20
- data/controllers/activity.rb +15 -6
- data/controllers/channel/actions/apply_gossip.rb +3 -4
- data/controllers/channel/actions/update_fee.rb +11 -7
- data/controllers/channel/all.rb +11 -7
- data/controllers/channel/find_by_id.rb +11 -11
- data/controllers/channel/mine.rb +10 -10
- data/controllers/channel.rb +25 -11
- data/controllers/concerns/impersonatable.rb +33 -0
- data/controllers/connection.rb +33 -0
- data/controllers/forward/all.rb +16 -12
- data/controllers/forward/group_by_channel.rb +2 -2
- data/controllers/forward.rb +19 -13
- data/controllers/invoice/actions/create.rb +21 -13
- data/controllers/invoice/actions/pay.rb +13 -12
- data/controllers/invoice/actions/pay_through_route.rb +2 -2
- data/controllers/invoice/all.rb +7 -7
- data/controllers/invoice/decode.rb +6 -6
- data/controllers/invoice/find_by_code.rb +7 -7
- data/controllers/invoice/find_by_secret_hash.rb +10 -6
- data/controllers/invoice.rb +46 -39
- data/controllers/node/actions/apply_gossip.rb +1 -1
- data/controllers/node/actions/pay.rb +13 -12
- data/controllers/node/all.rb +11 -7
- data/controllers/node/find_by_public_key.rb +11 -7
- data/controllers/node/myself.rb +6 -6
- data/controllers/node.rb +17 -11
- data/controllers/payment/actions/pay.rb +23 -19
- data/controllers/payment/all.rb +7 -4
- data/controllers/payment.rb +20 -14
- data/controllers/secret/valid_proof.rb +5 -5
- data/controllers/transaction/all.rb +6 -5
- data/controllers/transaction.rb +14 -6
- data/controllers/wallet/balance.rb +34 -0
- data/controllers/wallet.rb +19 -0
- data/docs/README.md +70 -7
- data/docs/_coverpage.md +1 -1
- data/docs/index.html +1 -1
- data/lighstorm.gemspec +1 -1
- data/models/activity.rb +3 -2
- data/models/connections/channel_node/fee.rb +5 -2
- data/models/connections/channel_node/policy.rb +3 -2
- data/models/connections/channel_node.rb +14 -4
- data/models/connections/forward_channel.rb +3 -2
- data/models/edges/channel/hop.rb +1 -1
- data/models/edges/channel.rb +5 -7
- data/models/edges/forward.rb +4 -3
- data/models/edges/groups/channel_forwards.rb +3 -2
- data/models/edges/payment.rb +4 -3
- data/models/errors.rb +16 -24
- data/models/invoice.rb +10 -4
- data/models/nodes/node.rb +10 -4
- data/models/secret.rb +10 -4
- data/models/wallet.rb +40 -0
- data/ports/dsl/lighstorm.rb +6 -2
- data/ports/grpc.rb +30 -2
- data/static/cache.rb +2 -0
- data/static/spec.rb +1 -1
- metadata +10 -5
- data/deleted.sh +0 -1
data/models/wallet.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative './satoshis'
|
4
|
+
|
5
|
+
module Lighstorm
|
6
|
+
module Models
|
7
|
+
class Wallet
|
8
|
+
attr_reader :_key, :at
|
9
|
+
|
10
|
+
def initialize(data)
|
11
|
+
@data = data
|
12
|
+
|
13
|
+
@_key = @data[:_key]
|
14
|
+
@at = @data[:at]
|
15
|
+
end
|
16
|
+
|
17
|
+
def lightning
|
18
|
+
@lightning ||= Satoshis.new(millisatoshis: @data[:lightning][:millisatoshis])
|
19
|
+
end
|
20
|
+
|
21
|
+
def bitcoin
|
22
|
+
@bitcoin ||= Satoshis.new(millisatoshis: @data[:bitcoin][:millisatoshis])
|
23
|
+
end
|
24
|
+
|
25
|
+
def total
|
26
|
+
@total ||= Satoshis.new(millisatoshis: @data[:total][:millisatoshis])
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_h
|
30
|
+
{
|
31
|
+
_key: _key,
|
32
|
+
at: at,
|
33
|
+
lightning: lightning.to_h,
|
34
|
+
bitcoin: bitcoin.to_h,
|
35
|
+
total: total.to_h
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/ports/dsl/lighstorm.rb
CHANGED
@@ -12,6 +12,8 @@ require_relative '../../controllers/payment'
|
|
12
12
|
require_relative '../../controllers/forward'
|
13
13
|
require_relative '../../controllers/invoice'
|
14
14
|
require_relative '../../controllers/activity'
|
15
|
+
require_relative '../../controllers/connection'
|
16
|
+
require_relative '../../controllers/wallet'
|
15
17
|
|
16
18
|
module Lighstorm
|
17
19
|
Node = Controllers::Node
|
@@ -20,11 +22,13 @@ module Lighstorm
|
|
20
22
|
Forward = Controllers::Forward
|
21
23
|
Invoice = Controllers::Invoice
|
22
24
|
Activity = Controllers::Activity
|
25
|
+
Connection = Controllers::Connection
|
26
|
+
Wallet = Controllers::Wallet
|
23
27
|
|
24
28
|
Satoshis = Models::Satoshis
|
25
29
|
|
26
|
-
def self.connect!(
|
27
|
-
|
30
|
+
def self.connect!(...)
|
31
|
+
Controllers::Connection.connect!(...)
|
28
32
|
end
|
29
33
|
|
30
34
|
def self.inject_middleware!(middleware_lambda)
|
data/ports/grpc.rb
CHANGED
@@ -7,14 +7,42 @@ require_relative 'grpc/session'
|
|
7
7
|
module Lighstorm
|
8
8
|
module Ports
|
9
9
|
class GRPC
|
10
|
-
|
10
|
+
class Impersonatable
|
11
|
+
def initialize(id)
|
12
|
+
@id = id
|
13
|
+
end
|
14
|
+
|
15
|
+
def session
|
16
|
+
GRPCSession.new(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(method_name, *_args, &block)
|
20
|
+
service_key = method_name.to_sym
|
21
|
+
|
22
|
+
unless LND.instance.as(@id).respond_to?(service_key)
|
23
|
+
raise ArgumentError,
|
24
|
+
"Method `#{method_name}` doesn't exist."
|
25
|
+
end
|
26
|
+
|
27
|
+
GRPC.new(LND.instance.as(@id).send(service_key), service_key, @id, &block)
|
28
|
+
end
|
29
|
+
|
30
|
+
def respond_to_missing?(method_name, include_private = false)
|
31
|
+
service_key = method_name.to_sym
|
32
|
+
|
33
|
+
LND.instance.as(@id).respond_to?(service_key) || super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def initialize(service, service_key, as = nil, &handler)
|
11
38
|
@service = service
|
12
39
|
@service_key = service_key
|
13
40
|
@handler = handler
|
41
|
+
@as = as
|
14
42
|
end
|
15
43
|
|
16
44
|
def call!(call_key, *args, &block)
|
17
|
-
key = "#{@service_key}.#{call_key}"
|
45
|
+
key = "[#{@as}]:#{@service_key}.#{call_key}"
|
18
46
|
|
19
47
|
if block.nil?
|
20
48
|
response = Cache.for(key, params: args&.first) do
|
data/static/cache.rb
CHANGED
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.15',
|
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.15
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -36,14 +36,14 @@ dependencies:
|
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0.0.
|
39
|
+
version: 0.0.9
|
40
40
|
type: :runtime
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.0.
|
46
|
+
version: 0.0.9
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: zache
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- adapters/invoice.rb
|
87
87
|
- adapters/nodes/node.rb
|
88
88
|
- adapters/transaction.rb
|
89
|
+
- adapters/wallet.rb
|
89
90
|
- components/cache.rb
|
90
91
|
- components/lnd.rb
|
91
92
|
- controllers/action.rb
|
@@ -97,6 +98,8 @@ files:
|
|
97
98
|
- controllers/channel/all.rb
|
98
99
|
- controllers/channel/find_by_id.rb
|
99
100
|
- controllers/channel/mine.rb
|
101
|
+
- controllers/concerns/impersonatable.rb
|
102
|
+
- controllers/connection.rb
|
100
103
|
- controllers/forward.rb
|
101
104
|
- controllers/forward/all.rb
|
102
105
|
- controllers/forward/group_by_channel.rb
|
@@ -120,7 +123,8 @@ files:
|
|
120
123
|
- controllers/secret/valid_proof.rb
|
121
124
|
- controllers/transaction.rb
|
122
125
|
- controllers/transaction/all.rb
|
123
|
-
-
|
126
|
+
- controllers/wallet.rb
|
127
|
+
- controllers/wallet/balance.rb
|
124
128
|
- docs/.nojekyll
|
125
129
|
- docs/README.md
|
126
130
|
- docs/_coverpage.md
|
@@ -159,6 +163,7 @@ files:
|
|
159
163
|
- models/satoshis.rb
|
160
164
|
- models/secret.rb
|
161
165
|
- models/transaction.rb
|
166
|
+
- models/wallet.rb
|
162
167
|
- ports/dsl/lighstorm.rb
|
163
168
|
- ports/dsl/lighstorm/errors.rb
|
164
169
|
- ports/grpc.rb
|
data/deleted.sh
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
deleted.sh
|