lighstorm 0.0.12 → 0.0.14
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/.env.example +18 -3
- data/Gemfile.lock +4 -4
- data/README.md +11 -5
- 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/transaction.rb +23 -0
- data/adapters/wallet.rb +42 -0
- data/components/cache.rb +1 -1
- data/components/lnd.rb +67 -29
- data/controllers/action.rb +5 -0
- data/controllers/activity/all.rb +194 -0
- data/controllers/activity.rb +26 -0
- 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 +29 -73
- data/controllers/transaction.rb +14 -6
- data/controllers/wallet/balance.rb +34 -0
- data/controllers/wallet.rb +19 -0
- data/docs/README.md +204 -31
- data/docs/_coverpage.md +1 -1
- data/docs/index.html +1 -1
- data/lighstorm.gemspec +1 -1
- data/models/activity.rb +52 -0
- 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/transaction.rb +10 -15
- data/models/wallet.rb +40 -0
- data/ports/dsl/lighstorm.rb +8 -4
- data/ports/grpc.rb +30 -2
- data/static/cache.rb +3 -0
- data/static/spec.rb +1 -1
- metadata +14 -5
- data/deleted.sh +0 -1
@@ -13,9 +13,11 @@ module Lighstorm
|
|
13
13
|
|
14
14
|
attr_reader :state
|
15
15
|
|
16
|
-
def initialize(data, is_mine, transaction)
|
16
|
+
def initialize(data, components, is_mine, transaction)
|
17
17
|
@data = data
|
18
|
+
@components = components
|
18
19
|
@state = data[:state]
|
20
|
+
@initiator = data[:initiator]
|
19
21
|
@is_mine = is_mine
|
20
22
|
@transaction = transaction
|
21
23
|
end
|
@@ -24,12 +26,16 @@ module Lighstorm
|
|
24
26
|
state == 'active'
|
25
27
|
end
|
26
28
|
|
29
|
+
def initiator?
|
30
|
+
@initiator
|
31
|
+
end
|
32
|
+
|
27
33
|
def node
|
28
|
-
@node ||= Node.new(@data[:node])
|
34
|
+
@node ||= Node.new(@data[:node], @components)
|
29
35
|
end
|
30
36
|
|
31
37
|
def policy
|
32
|
-
@policy ||= Policy.new(@data[:policy], @transaction)
|
38
|
+
@policy ||= Policy.new(@data[:policy], @components, @transaction)
|
33
39
|
end
|
34
40
|
|
35
41
|
def accounting
|
@@ -39,7 +45,11 @@ module Lighstorm
|
|
39
45
|
end
|
40
46
|
|
41
47
|
def to_h
|
42
|
-
restult = {
|
48
|
+
restult = {
|
49
|
+
state: state,
|
50
|
+
initiator: @initiator,
|
51
|
+
node: node.to_h
|
52
|
+
}
|
43
53
|
|
44
54
|
restult[:accounting] = accounting.to_h if @is_mine
|
45
55
|
restult[:policy] = policy.to_h if @data[:policy]
|
@@ -5,8 +5,9 @@ require_relative '../edges/channel'
|
|
5
5
|
module Lighstorm
|
6
6
|
module Models
|
7
7
|
class ForwardChannel
|
8
|
-
def initialize(data)
|
8
|
+
def initialize(data, components)
|
9
9
|
@data = data
|
10
|
+
@components = components
|
10
11
|
end
|
11
12
|
|
12
13
|
def amount
|
@@ -14,7 +15,7 @@ module Lighstorm
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def channel
|
17
|
-
@channel ||= Channel.new(@data[:channel])
|
18
|
+
@channel ||= Channel.new(@data[:channel], @components)
|
18
19
|
end
|
19
20
|
|
20
21
|
def to_h
|
data/models/edges/channel/hop.rb
CHANGED
data/models/edges/channel.rb
CHANGED
@@ -5,9 +5,6 @@ require 'time'
|
|
5
5
|
require_relative '../../ports/grpc'
|
6
6
|
require_relative '../../adapters/edges/channel'
|
7
7
|
|
8
|
-
require_relative '../../components/lnd'
|
9
|
-
require_relative '../../components/cache'
|
10
|
-
|
11
8
|
require_relative '../nodes/node'
|
12
9
|
require_relative './channel/accounting'
|
13
10
|
|
@@ -22,8 +19,9 @@ module Lighstorm
|
|
22
19
|
class Channel
|
23
20
|
attr_reader :data, :_key, :id
|
24
21
|
|
25
|
-
def initialize(data)
|
22
|
+
def initialize(data, components)
|
26
23
|
@data = data
|
24
|
+
@components = components
|
27
25
|
|
28
26
|
@_key = data[:_key]
|
29
27
|
@id = data[:id]
|
@@ -78,7 +76,7 @@ module Lighstorm
|
|
78
76
|
def partners
|
79
77
|
@partners ||= if @data[:partners]
|
80
78
|
@data[:partners].map do |data|
|
81
|
-
ChannelNode.new(data, known? ? mine? : nil, transaction)
|
79
|
+
ChannelNode.new(data, @components, known? ? mine? : nil, transaction)
|
82
80
|
end
|
83
81
|
else
|
84
82
|
[]
|
@@ -170,9 +168,9 @@ module Lighstorm
|
|
170
168
|
raise ArgumentError, 'missing gossip: or dump:' if gossip.nil? && dump.nil?
|
171
169
|
|
172
170
|
if !gossip.nil?
|
173
|
-
new(Adapter::Channel.subscribe_channel_graph(gossip))
|
171
|
+
new(Adapter::Channel.subscribe_channel_graph(gossip), nil)
|
174
172
|
elsif !dump.nil?
|
175
|
-
new(dump)
|
173
|
+
new(dump, nil)
|
176
174
|
end
|
177
175
|
end
|
178
176
|
|
data/models/edges/forward.rb
CHANGED
@@ -12,8 +12,9 @@ module Lighstorm
|
|
12
12
|
class Forward
|
13
13
|
attr_reader :_key, :at
|
14
14
|
|
15
|
-
def initialize(data)
|
15
|
+
def initialize(data, components)
|
16
16
|
@data = data
|
17
|
+
@components = components
|
17
18
|
|
18
19
|
@_key = data[:_key]
|
19
20
|
@at = data[:at]
|
@@ -24,11 +25,11 @@ module Lighstorm
|
|
24
25
|
end
|
25
26
|
|
26
27
|
def in
|
27
|
-
@in ||= ForwardChannel.new(@data[:in])
|
28
|
+
@in ||= ForwardChannel.new(@data[:in], @components)
|
28
29
|
end
|
29
30
|
|
30
31
|
def out
|
31
|
-
@out ||= ForwardChannel.new(@data[:out])
|
32
|
+
@out ||= ForwardChannel.new(@data[:out], @components)
|
32
33
|
end
|
33
34
|
|
34
35
|
def to_h
|
@@ -8,8 +8,9 @@ module Lighstorm
|
|
8
8
|
class ChannelForwardsGroup
|
9
9
|
attr_reader :_key, :last_at
|
10
10
|
|
11
|
-
def initialize(data)
|
11
|
+
def initialize(data, components)
|
12
12
|
@data = data
|
13
|
+
@components = components
|
13
14
|
|
14
15
|
@_key = data[:_key]
|
15
16
|
@last_at = data[:last_at]
|
@@ -20,7 +21,7 @@ module Lighstorm
|
|
20
21
|
end
|
21
22
|
|
22
23
|
def channel
|
23
|
-
@channel ||= Channel.new(@data[:channel])
|
24
|
+
@channel ||= Channel.new(@data[:channel], @components)
|
24
25
|
end
|
25
26
|
|
26
27
|
def to_h
|
data/models/edges/payment.rb
CHANGED
@@ -14,8 +14,9 @@ module Lighstorm
|
|
14
14
|
class Payment
|
15
15
|
attr_reader :_key, :at, :state, :secret, :purpose, :through, :message
|
16
16
|
|
17
|
-
def initialize(data)
|
17
|
+
def initialize(data, components)
|
18
18
|
@data = data
|
19
|
+
@components = components
|
19
20
|
|
20
21
|
@_key = data[:_key]
|
21
22
|
@at = data[:at]
|
@@ -30,7 +31,7 @@ module Lighstorm
|
|
30
31
|
end
|
31
32
|
|
32
33
|
def invoice
|
33
|
-
@invoice ||= !spontaneous? && @data[:invoice] ? Invoice.new(@data[:invoice]) : nil
|
34
|
+
@invoice ||= !spontaneous? && @data[:invoice] ? Invoice.new(@data[:invoice], @components) : nil
|
34
35
|
end
|
35
36
|
|
36
37
|
def amount
|
@@ -42,7 +43,7 @@ module Lighstorm
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def secret
|
45
|
-
@secret ||= @data[:secret] ? Secret.new(@data[:secret]) : nil
|
46
|
+
@secret ||= @data[:secret] ? Secret.new(@data[:secret], @components) : nil
|
46
47
|
end
|
47
48
|
|
48
49
|
def hops
|
data/models/errors.rb
CHANGED
@@ -3,23 +3,18 @@
|
|
3
3
|
module Lighstorm
|
4
4
|
module Errors
|
5
5
|
class LighstormError < StandardError
|
6
|
-
|
7
|
-
|
8
|
-
def initialize(message = nil, grpc: nil)
|
6
|
+
def initialize(message = nil)
|
9
7
|
super(message)
|
10
|
-
@grpc = grpc
|
11
8
|
end
|
12
9
|
|
13
10
|
def to_h
|
14
|
-
|
15
|
-
output[:grpc] = grpc.message unless grpc.nil?
|
16
|
-
|
17
|
-
output
|
11
|
+
{ class: self.class, message: message }
|
18
12
|
end
|
19
13
|
end
|
20
14
|
|
21
15
|
class ToDoError < LighstormError; end
|
22
16
|
|
17
|
+
class MissingComponentsError < LighstormError; end
|
23
18
|
class ArgumentError < LighstormError; end
|
24
19
|
class TooManyArgumentsError < LighstormError; end
|
25
20
|
class IncoherentGossipError < LighstormError; end
|
@@ -31,45 +26,42 @@ module Lighstorm
|
|
31
26
|
class NotYourChannelError < LighstormError; end
|
32
27
|
class NotYourNodeError < LighstormError; end
|
33
28
|
class OperationNotAllowedError < LighstormError; end
|
34
|
-
class UnexpectedNumberOfHTLCsError < LighstormError; end
|
35
29
|
class UnknownChannelError < LighstormError; end
|
36
|
-
class NoInvoiceFoundError < LighstormError; end
|
37
30
|
|
38
31
|
class InvoiceMayHaveMultiplePaymentsError < LighstormError; end
|
39
32
|
|
40
|
-
class
|
41
|
-
attr_reader :response, :result, :grpc
|
33
|
+
class RequestError < LighstormError
|
34
|
+
attr_reader :request, :response, :result, :grpc
|
42
35
|
|
43
|
-
def initialize(message, response: nil, result: nil, grpc: nil)
|
36
|
+
def initialize(message, request: nil, response: nil, result: nil, grpc: nil)
|
44
37
|
super(message)
|
38
|
+
@request = request
|
45
39
|
@response = response
|
46
40
|
@result = result
|
47
41
|
@grpc = grpc
|
48
42
|
end
|
49
43
|
|
50
44
|
def to_h
|
51
|
-
output = { message: message }
|
45
|
+
output = { class: self.class, message: message }
|
52
46
|
|
47
|
+
output[:request] = request unless request.nil?
|
53
48
|
output[:response] = response unless response.nil?
|
54
49
|
output[:result] = result.to_h unless result.nil?
|
55
|
-
output[:grpc] = grpc.message unless grpc.nil?
|
50
|
+
output[:grpc] = { class: grpc.class, message: grpc.message } unless grpc.nil?
|
56
51
|
|
57
52
|
output
|
58
53
|
end
|
59
54
|
end
|
60
55
|
|
56
|
+
class UpdateChannelPolicyError < RequestError; end
|
57
|
+
|
58
|
+
class NoInvoiceFoundError < RequestError; end
|
59
|
+
|
60
|
+
class PaymentError < RequestError; end
|
61
|
+
|
61
62
|
class NoRouteFoundError < PaymentError; end
|
62
63
|
class AlreadyPaidError < PaymentError; end
|
63
64
|
class AmountForNonZeroError < PaymentError; end
|
64
65
|
class MissingMillisatoshisError < PaymentError; end
|
65
|
-
|
66
|
-
class UpdateChannelPolicyError < LighstormError
|
67
|
-
attr_reader :response
|
68
|
-
|
69
|
-
def initialize(message, response)
|
70
|
-
super(message)
|
71
|
-
@response = response
|
72
|
-
end
|
73
|
-
end
|
74
66
|
end
|
75
67
|
end
|
data/models/invoice.rb
CHANGED
@@ -12,8 +12,9 @@ module Lighstorm
|
|
12
12
|
class Invoice
|
13
13
|
attr_reader :_key, :created_at, :expires_at, :settled_at, :state, :payable, :code
|
14
14
|
|
15
|
-
def initialize(data)
|
15
|
+
def initialize(data, components)
|
16
16
|
@data = data
|
17
|
+
@components = components
|
17
18
|
|
18
19
|
@_key = data[:_key]
|
19
20
|
@created_at = data[:created_at]
|
@@ -35,7 +36,7 @@ module Lighstorm
|
|
35
36
|
end
|
36
37
|
|
37
38
|
def payments
|
38
|
-
@payments ||= @data[:payments]&.map { |data| Payment.new(data) }
|
39
|
+
@payments ||= @data[:payments]&.map { |data| Payment.new(data, @components) }
|
39
40
|
end
|
40
41
|
|
41
42
|
def amount
|
@@ -47,7 +48,7 @@ module Lighstorm
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def secret
|
50
|
-
@secret ||= Secret.new(@data[:secret])
|
51
|
+
@secret ||= Secret.new(@data[:secret], @components)
|
51
52
|
end
|
52
53
|
|
53
54
|
def description
|
@@ -89,10 +90,15 @@ module Lighstorm
|
|
89
90
|
times_out_in: { seconds: 5 },
|
90
91
|
preview: false
|
91
92
|
)
|
93
|
+
raise MissingComponentsError if @components.nil?
|
94
|
+
|
92
95
|
if route
|
93
|
-
Controllers::Invoice::PayThroughRoute.perform(
|
96
|
+
Controllers::Invoice::PayThroughRoute.perform(
|
97
|
+
@components, self, route: route, preview: preview
|
98
|
+
)
|
94
99
|
else
|
95
100
|
Controllers::Invoice::Pay.perform(
|
101
|
+
@components,
|
96
102
|
code: code,
|
97
103
|
amount: amount,
|
98
104
|
fee: fee,
|
data/models/nodes/node.rb
CHANGED
@@ -16,8 +16,9 @@ module Lighstorm
|
|
16
16
|
|
17
17
|
attr_reader :data, :_key, :alias, :public_key, :color
|
18
18
|
|
19
|
-
def initialize(data)
|
19
|
+
def initialize(data, components)
|
20
20
|
@data = data
|
21
|
+
@components = components
|
21
22
|
|
22
23
|
@_key = @data[:_key]
|
23
24
|
@alias = @data[:alias]
|
@@ -36,7 +37,9 @@ module Lighstorm
|
|
36
37
|
def channels
|
37
38
|
raise Errors::NotYourNodeError unless myself?
|
38
39
|
|
39
|
-
|
40
|
+
raise MissingComponentsError if @components.nil?
|
41
|
+
|
42
|
+
Controllers::Channel.mine(@components)
|
40
43
|
end
|
41
44
|
|
42
45
|
def to_h
|
@@ -87,9 +90,9 @@ module Lighstorm
|
|
87
90
|
raise ArgumentError, 'missing gossip: or dump:' if gossip.nil? && dump.nil?
|
88
91
|
|
89
92
|
if !gossip.nil?
|
90
|
-
new(Adapter::Node.subscribe_channel_graph(gossip))
|
93
|
+
new(Adapter::Node.subscribe_channel_graph(gossip), nil)
|
91
94
|
elsif !dump.nil?
|
92
|
-
new(dump)
|
95
|
+
new(dump, nil)
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
@@ -121,7 +124,10 @@ module Lighstorm
|
|
121
124
|
times_out_in: { seconds: 5 }, through: 'amp',
|
122
125
|
preview: false
|
123
126
|
)
|
127
|
+
raise MissingComponentsError if @components.nil?
|
128
|
+
|
124
129
|
Controllers::Node::Pay.perform(
|
130
|
+
@components,
|
125
131
|
public_key: public_key,
|
126
132
|
amount: amount,
|
127
133
|
fee: fee,
|
data/models/secret.rb
CHANGED
@@ -15,14 +15,15 @@ module Lighstorm
|
|
15
15
|
data
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.create(&vcr)
|
18
|
+
def self.create(components = nil, &vcr)
|
19
19
|
data = vcr.nil? ? generate : vcr.call(-> { generate })
|
20
20
|
|
21
|
-
Secret.new(data)
|
21
|
+
Secret.new(data, components)
|
22
22
|
end
|
23
23
|
|
24
|
-
def initialize(data)
|
24
|
+
def initialize(data, components)
|
25
25
|
@data = data
|
26
|
+
@components = components
|
26
27
|
|
27
28
|
@preimage = data[:preimage]
|
28
29
|
@hash = data[:hash]
|
@@ -33,9 +34,14 @@ module Lighstorm
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def valid_proof?(candidate_preimage, &vcr)
|
37
|
+
raise MissingComponentsError if @components.nil?
|
38
|
+
|
36
39
|
return true if candidate_preimage == preimage
|
37
40
|
|
38
|
-
Controllers::Secret::ValidProof.data(
|
41
|
+
Controllers::Secret::ValidProof.data(
|
42
|
+
@components,
|
43
|
+
@hash, candidate_preimage, &vcr
|
44
|
+
)
|
39
45
|
end
|
40
46
|
|
41
47
|
def to_h
|
data/models/transaction.rb
CHANGED
@@ -1,43 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative '
|
3
|
+
require_relative './satoshis'
|
4
4
|
|
5
5
|
module Lighstorm
|
6
6
|
module Models
|
7
7
|
class Transaction
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :_key, :at, :hash, :label
|
9
9
|
|
10
10
|
def initialize(data)
|
11
11
|
@data = data
|
12
12
|
|
13
13
|
@_key = @data[:_key]
|
14
14
|
@at = @data[:at]
|
15
|
-
@
|
16
|
-
@
|
17
|
-
@message = @data[:message]
|
15
|
+
@hash = @data[:hash]
|
16
|
+
@label = @data[:label]
|
18
17
|
end
|
19
18
|
|
20
19
|
def amount
|
21
20
|
@amount ||= Satoshis.new(millisatoshis: @data[:amount][:millisatoshis])
|
22
21
|
end
|
23
22
|
|
24
|
-
def
|
25
|
-
@
|
23
|
+
def fee
|
24
|
+
@fee ||= Satoshis.new(millisatoshis: @data[:fee][:millisatoshis])
|
26
25
|
end
|
27
26
|
|
28
27
|
def to_h
|
29
|
-
|
28
|
+
{
|
30
29
|
_key: _key,
|
31
30
|
at: at,
|
32
|
-
|
31
|
+
hash: hash,
|
33
32
|
amount: amount.to_h,
|
34
|
-
|
35
|
-
|
33
|
+
fee: fee.to_h,
|
34
|
+
label: label
|
36
35
|
}
|
37
|
-
|
38
|
-
output[:invoice] = invoice.to_h unless invoice.nil?
|
39
|
-
|
40
|
-
output
|
41
36
|
end
|
42
37
|
end
|
43
38
|
end
|
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
@@ -11,7 +11,9 @@ require_relative '../../controllers/channel'
|
|
11
11
|
require_relative '../../controllers/payment'
|
12
12
|
require_relative '../../controllers/forward'
|
13
13
|
require_relative '../../controllers/invoice'
|
14
|
-
require_relative '../../controllers/
|
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
|
@@ -19,12 +21,14 @@ module Lighstorm
|
|
19
21
|
Payment = Controllers::Payment
|
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.
|
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.14',
|
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.14
|
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.7
|
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.7
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: zache
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -85,15 +85,21 @@ files:
|
|
85
85
|
- adapters/edges/payment/purpose.rb
|
86
86
|
- adapters/invoice.rb
|
87
87
|
- adapters/nodes/node.rb
|
88
|
+
- adapters/transaction.rb
|
89
|
+
- adapters/wallet.rb
|
88
90
|
- components/cache.rb
|
89
91
|
- components/lnd.rb
|
90
92
|
- controllers/action.rb
|
93
|
+
- controllers/activity.rb
|
94
|
+
- controllers/activity/all.rb
|
91
95
|
- controllers/channel.rb
|
92
96
|
- controllers/channel/actions/apply_gossip.rb
|
93
97
|
- controllers/channel/actions/update_fee.rb
|
94
98
|
- controllers/channel/all.rb
|
95
99
|
- controllers/channel/find_by_id.rb
|
96
100
|
- controllers/channel/mine.rb
|
101
|
+
- controllers/concerns/impersonatable.rb
|
102
|
+
- controllers/connection.rb
|
97
103
|
- controllers/forward.rb
|
98
104
|
- controllers/forward/all.rb
|
99
105
|
- controllers/forward/group_by_channel.rb
|
@@ -117,7 +123,8 @@ files:
|
|
117
123
|
- controllers/secret/valid_proof.rb
|
118
124
|
- controllers/transaction.rb
|
119
125
|
- controllers/transaction/all.rb
|
120
|
-
-
|
126
|
+
- controllers/wallet.rb
|
127
|
+
- controllers/wallet/balance.rb
|
121
128
|
- docs/.nojekyll
|
122
129
|
- docs/README.md
|
123
130
|
- docs/_coverpage.md
|
@@ -130,6 +137,7 @@ files:
|
|
130
137
|
- docs/vendor/prismjs/prism-tomorrow.min.css
|
131
138
|
- helpers/time_expression.rb
|
132
139
|
- lighstorm.gemspec
|
140
|
+
- models/activity.rb
|
133
141
|
- models/concerns/protectable.rb
|
134
142
|
- models/connections/channel_node.rb
|
135
143
|
- models/connections/channel_node/accounting.rb
|
@@ -155,6 +163,7 @@ files:
|
|
155
163
|
- models/satoshis.rb
|
156
164
|
- models/secret.rb
|
157
165
|
- models/transaction.rb
|
166
|
+
- models/wallet.rb
|
158
167
|
- ports/dsl/lighstorm.rb
|
159
168
|
- ports/dsl/lighstorm/errors.rb
|
160
169
|
- ports/grpc.rb
|
data/deleted.sh
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
deleted.sh
|