lighstorm 0.0.6 → 0.0.7
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.lock +1 -1
- data/README.md +17 -55
- data/adapters/connections/channel_node/fee.rb +1 -1
- data/adapters/connections/channel_node/policy.rb +6 -6
- data/adapters/connections/channel_node.rb +1 -1
- data/adapters/connections/payment_channel.rb +2 -2
- data/adapters/edges/channel.rb +7 -7
- data/adapters/edges/forward.rb +3 -3
- data/adapters/edges/payment.rb +1 -1
- data/adapters/invoice.rb +15 -0
- data/adapters/payment_request.rb +14 -3
- data/components/cache.rb +8 -5
- data/controllers/action.rb +24 -0
- data/controllers/channel/actions/apply_gossip.rb +18 -18
- data/controllers/channel/actions/update_fee.rb +33 -22
- data/controllers/forward/group_by_channel.rb +3 -3
- data/controllers/invoice/actions/create.rb +39 -12
- data/controllers/invoice/actions/pay_through_route.rb +1 -1
- data/controllers/invoice.rb +3 -3
- data/docs/README.md +390 -145
- data/docs/_coverpage.md +6 -1
- data/docs/index.html +1 -1
- data/models/connections/channel_node/accounting.rb +1 -1
- data/models/connections/channel_node/fee.rb +5 -4
- data/models/connections/channel_node/htlc.rb +4 -4
- data/models/connections/forward_channel.rb +1 -1
- data/models/connections/payment_channel.rb +4 -4
- data/models/edges/channel/accounting.rb +5 -5
- data/models/edges/forward.rb +3 -3
- data/models/edges/groups/channel_forwards/analysis.rb +8 -8
- data/models/edges/payment.rb +3 -3
- data/models/errors.rb +1 -1
- data/models/payment_request.rb +2 -2
- data/models/satoshis.rb +12 -12
- data/static/cache.rb +2 -0
- data/static/spec.rb +1 -1
- metadata +3 -2
data/docs/_coverpage.md
CHANGED
@@ -4,8 +4,13 @@
|
|
4
4
|
|
5
5
|
- Make your Satoshis flow.
|
6
6
|
- Unleash the power of Graphs.
|
7
|
+
- Easy-to-use **intuitive** API.
|
8
|
+
- Built for maximum **reliability**.
|
9
|
+
- Optimized for programmer **happiness**.
|
7
10
|
|
8
|
-
0.0.
|
11
|
+
0.0.7
|
12
|
+
|
13
|
+
⚠️ _Warning: Early-stage, breaking changes are expected._
|
9
14
|
|
10
15
|
[Documentation](README)
|
11
16
|
[GitHub](https://github.com/icebaker/lighstorm)
|
data/docs/index.html
CHANGED
@@ -22,7 +22,7 @@ module Lighstorm
|
|
22
22
|
def base
|
23
23
|
return nil unless @data[:base]
|
24
24
|
|
25
|
-
@base ||= Satoshis.new(
|
25
|
+
@base ||= Satoshis.new(millisatoshis: @data[:base][:millisatoshis])
|
26
26
|
end
|
27
27
|
|
28
28
|
def rate
|
@@ -46,9 +46,10 @@ module Lighstorm
|
|
46
46
|
Marshal.load(Marshal.dump(@data))
|
47
47
|
end
|
48
48
|
|
49
|
-
def update(params, preview: false,
|
49
|
+
def update(params, preview: false, &vcr)
|
50
50
|
Controllers::Channel::UpdateFee.perform(
|
51
|
-
@policy,
|
51
|
+
@policy, @policy.transaction, params,
|
52
|
+
preview: preview, &vcr
|
52
53
|
)
|
53
54
|
end
|
54
55
|
|
@@ -57,7 +58,7 @@ module Lighstorm
|
|
57
58
|
|
58
59
|
@base = value[:value]
|
59
60
|
|
60
|
-
@data[:base] = {
|
61
|
+
@data[:base] = { millisatoshis: @base.millisatoshis }
|
61
62
|
|
62
63
|
base
|
63
64
|
end
|
@@ -17,7 +17,7 @@ module Lighstorm
|
|
17
17
|
def minimum
|
18
18
|
@minimum ||= if @data[:minimum]
|
19
19
|
Satoshis.new(
|
20
|
-
|
20
|
+
millisatoshis: @data[:minimum][:millisatoshis]
|
21
21
|
)
|
22
22
|
end
|
23
23
|
end
|
@@ -25,7 +25,7 @@ module Lighstorm
|
|
25
25
|
def maximum
|
26
26
|
@maximum ||= if @data[:maximum]
|
27
27
|
Satoshis.new(
|
28
|
-
|
28
|
+
millisatoshis: @data[:maximum][:millisatoshis]
|
29
29
|
)
|
30
30
|
end
|
31
31
|
end
|
@@ -67,7 +67,7 @@ module Lighstorm
|
|
67
67
|
|
68
68
|
@minimum = value[:value]
|
69
69
|
|
70
|
-
@data[:minimum] = {
|
70
|
+
@data[:minimum] = { millisatoshis: @minimum.millisatoshis }
|
71
71
|
|
72
72
|
minimum
|
73
73
|
end
|
@@ -77,7 +77,7 @@ module Lighstorm
|
|
77
77
|
|
78
78
|
@maximum = value[:value]
|
79
79
|
|
80
|
-
@data[:maximum] = {
|
80
|
+
@data[:maximum] = { millisatoshis: @maximum.millisatoshis }
|
81
81
|
|
82
82
|
maximum
|
83
83
|
end
|
@@ -24,11 +24,11 @@ module Lighstorm
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def amount
|
27
|
-
@amount ||= Satoshis.new(
|
27
|
+
@amount ||= Satoshis.new(millisatoshis: @data[:amount][:millisatoshis])
|
28
28
|
end
|
29
29
|
|
30
30
|
def fee
|
31
|
-
@fee ||= Satoshis.new(
|
31
|
+
@fee ||= Satoshis.new(millisatoshis: @data[:fee][:millisatoshis])
|
32
32
|
end
|
33
33
|
|
34
34
|
def channel
|
@@ -40,8 +40,8 @@ module Lighstorm
|
|
40
40
|
hop: hop,
|
41
41
|
amount: amount.to_h,
|
42
42
|
fee: {
|
43
|
-
|
44
|
-
parts_per_million: fee.parts_per_million(amount.
|
43
|
+
millisatoshis: fee.millisatoshis,
|
44
|
+
parts_per_million: fee.parts_per_million(amount.millisatoshis)
|
45
45
|
},
|
46
46
|
channel: channel.to_h
|
47
47
|
}
|
@@ -17,7 +17,7 @@ module Lighstorm
|
|
17
17
|
def capacity
|
18
18
|
@capacity ||= if @data[:capacity]
|
19
19
|
Satoshis.new(
|
20
|
-
|
20
|
+
millisatoshis: @data[:capacity][:millisatoshis]
|
21
21
|
)
|
22
22
|
end
|
23
23
|
end
|
@@ -27,7 +27,7 @@ module Lighstorm
|
|
27
27
|
|
28
28
|
@sent ||= if @data[:sent]
|
29
29
|
Satoshis.new(
|
30
|
-
|
30
|
+
millisatoshis: @data[:sent][:millisatoshis]
|
31
31
|
)
|
32
32
|
end
|
33
33
|
end
|
@@ -37,7 +37,7 @@ module Lighstorm
|
|
37
37
|
|
38
38
|
@received ||= if @data[:received]
|
39
39
|
Satoshis.new(
|
40
|
-
|
40
|
+
millisatoshis: @data[:received][:millisatoshis]
|
41
41
|
)
|
42
42
|
end
|
43
43
|
end
|
@@ -47,7 +47,7 @@ module Lighstorm
|
|
47
47
|
|
48
48
|
@unsettled ||= if @data[:unsettled]
|
49
49
|
Satoshis.new(
|
50
|
-
|
50
|
+
millisatoshis: @data[:unsettled][:millisatoshis]
|
51
51
|
)
|
52
52
|
end
|
53
53
|
end
|
@@ -76,7 +76,7 @@ module Lighstorm
|
|
76
76
|
|
77
77
|
@capacity = value[:value]
|
78
78
|
|
79
|
-
@data[:capacity][:
|
79
|
+
@data[:capacity][:millisatoshis] = @capacity.millisatoshis
|
80
80
|
|
81
81
|
capacity
|
82
82
|
end
|
data/models/edges/forward.rb
CHANGED
@@ -20,7 +20,7 @@ module Lighstorm
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def fee
|
23
|
-
@fee ||= Satoshis.new(
|
23
|
+
@fee ||= Satoshis.new(millisatoshis: @data[:fee][:millisatoshis])
|
24
24
|
end
|
25
25
|
|
26
26
|
def in
|
@@ -36,8 +36,8 @@ module Lighstorm
|
|
36
36
|
_key: _key,
|
37
37
|
at: at,
|
38
38
|
fee: {
|
39
|
-
|
40
|
-
parts_per_million: fee.parts_per_million(self.in.amount.
|
39
|
+
millisatoshis: fee.millisatoshis,
|
40
|
+
parts_per_million: fee.parts_per_million(self.in.amount.millisatoshis)
|
41
41
|
},
|
42
42
|
in: self.in.to_h,
|
43
43
|
out: out.to_h
|
@@ -11,19 +11,19 @@ module Lighstorm
|
|
11
11
|
def sums
|
12
12
|
Struct.new(:sums) do
|
13
13
|
def amount
|
14
|
-
Satoshis.new(
|
14
|
+
Satoshis.new(millisatoshis: sums[:amount][:millisatoshis])
|
15
15
|
end
|
16
16
|
|
17
17
|
def fee
|
18
|
-
Satoshis.new(
|
18
|
+
Satoshis.new(millisatoshis: sums[:fee][:millisatoshis])
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_h
|
22
22
|
{
|
23
23
|
amount: amount.to_h,
|
24
24
|
fee: {
|
25
|
-
|
26
|
-
parts_per_million: fee.parts_per_million(amount.
|
25
|
+
millisatoshis: fee.millisatoshis,
|
26
|
+
parts_per_million: fee.parts_per_million(amount.millisatoshis)
|
27
27
|
}
|
28
28
|
}
|
29
29
|
end
|
@@ -34,13 +34,13 @@ module Lighstorm
|
|
34
34
|
Struct.new(:data) do
|
35
35
|
def amount
|
36
36
|
Satoshis.new(
|
37
|
-
|
37
|
+
millisatoshis: data[:sums][:amount][:millisatoshis].to_f / data[:count]
|
38
38
|
)
|
39
39
|
end
|
40
40
|
|
41
41
|
def fee
|
42
42
|
Satoshis.new(
|
43
|
-
|
43
|
+
millisatoshis: data[:sums][:fee][:millisatoshis].to_f / data[:count]
|
44
44
|
)
|
45
45
|
end
|
46
46
|
|
@@ -48,8 +48,8 @@ module Lighstorm
|
|
48
48
|
{
|
49
49
|
amount: amount.to_h,
|
50
50
|
fee: {
|
51
|
-
|
52
|
-
parts_per_million: fee.parts_per_million(amount.
|
51
|
+
millisatoshis: fee.millisatoshis,
|
52
|
+
parts_per_million: fee.parts_per_million(amount.millisatoshis)
|
53
53
|
}
|
54
54
|
}
|
55
55
|
end
|
data/models/edges/payment.rb
CHANGED
@@ -28,7 +28,7 @@ module Lighstorm
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def fee
|
31
|
-
@fee ||= Satoshis.new(
|
31
|
+
@fee ||= Satoshis.new(millisatoshis: @data[:fee][:millisatoshis])
|
32
32
|
end
|
33
33
|
|
34
34
|
def hops
|
@@ -56,8 +56,8 @@ module Lighstorm
|
|
56
56
|
settled_at: settled_at,
|
57
57
|
purpose: purpose,
|
58
58
|
fee: {
|
59
|
-
|
60
|
-
parts_per_million: fee.parts_per_million(request.amount.
|
59
|
+
millisatoshis: fee.millisatoshis,
|
60
|
+
parts_per_million: fee.parts_per_million(request.amount.millisatoshis)
|
61
61
|
},
|
62
62
|
request: request.to_h,
|
63
63
|
from: from.to_h,
|
data/models/errors.rb
CHANGED
@@ -10,7 +10,7 @@ module Lighstorm
|
|
10
10
|
class IncoherentGossipError < LighstormError; end
|
11
11
|
class MissingGossipHandlerError < LighstormError; end
|
12
12
|
class MissingCredentialsError < LighstormError; end
|
13
|
-
class
|
13
|
+
class MissingMillisatoshisError < LighstormError; end
|
14
14
|
class MissingPartsPerMillionError < LighstormError; end
|
15
15
|
class MissingTTLError < LighstormError; end
|
16
16
|
class NegativeNotAllowedError < LighstormError; end
|
data/models/payment_request.rb
CHANGED
@@ -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][:
|
15
|
+
data[:code] || "#{data[:code][:amount][:millisatoshis]}#{Time.now}"
|
16
16
|
)
|
17
17
|
|
18
18
|
@code = data[:code]
|
@@ -21,7 +21,7 @@ module Lighstorm
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def amount
|
24
|
-
@amount ||= Satoshis.new(
|
24
|
+
@amount ||= Satoshis.new(millisatoshis: @data[:amount][:millisatoshis])
|
25
25
|
end
|
26
26
|
|
27
27
|
def description
|
data/models/satoshis.rb
CHANGED
@@ -5,34 +5,34 @@ require_relative '../ports/dsl/lighstorm/errors'
|
|
5
5
|
module Lighstorm
|
6
6
|
module Models
|
7
7
|
class Satoshis
|
8
|
-
def initialize(
|
9
|
-
raise
|
8
|
+
def initialize(millisatoshis: nil)
|
9
|
+
raise MissingMillisatoshisError, 'missing millisatoshis' if millisatoshis.nil?
|
10
10
|
|
11
|
-
@
|
11
|
+
@amount_in_millisatoshis = millisatoshis
|
12
12
|
end
|
13
13
|
|
14
|
-
def parts_per_million(
|
14
|
+
def parts_per_million(reference_millisatoshis)
|
15
15
|
(
|
16
16
|
(
|
17
|
-
if
|
17
|
+
if reference_millisatoshis.zero?
|
18
18
|
0
|
19
19
|
else
|
20
|
-
@
|
20
|
+
@amount_in_millisatoshis.to_f / reference_millisatoshis
|
21
21
|
end
|
22
22
|
) * 1_000_000.0
|
23
23
|
)
|
24
24
|
end
|
25
25
|
|
26
|
-
def
|
27
|
-
@
|
26
|
+
def millisatoshis
|
27
|
+
@amount_in_millisatoshis
|
28
28
|
end
|
29
29
|
|
30
30
|
def satoshis
|
31
|
-
@
|
31
|
+
@amount_in_millisatoshis.to_f / 1000.0
|
32
32
|
end
|
33
33
|
|
34
34
|
def bitcoins
|
35
|
-
@
|
35
|
+
@amount_in_millisatoshis.to_f / 100_000_000_000
|
36
36
|
end
|
37
37
|
|
38
38
|
def sats
|
@@ -40,7 +40,7 @@ module Lighstorm
|
|
40
40
|
end
|
41
41
|
|
42
42
|
def msats
|
43
|
-
|
43
|
+
millisatoshis
|
44
44
|
end
|
45
45
|
|
46
46
|
def btc
|
@@ -49,7 +49,7 @@ module Lighstorm
|
|
49
49
|
|
50
50
|
def to_h
|
51
51
|
{
|
52
|
-
|
52
|
+
millisatoshis: millisatoshis
|
53
53
|
}
|
54
54
|
end
|
55
55
|
end
|
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.7',
|
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.7
|
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-
|
11
|
+
date: 2023-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -87,6 +87,7 @@ files:
|
|
87
87
|
- adapters/payment_request.rb
|
88
88
|
- components/cache.rb
|
89
89
|
- components/lnd.rb
|
90
|
+
- controllers/action.rb
|
90
91
|
- controllers/channel.rb
|
91
92
|
- controllers/channel/actions/apply_gossip.rb
|
92
93
|
- controllers/channel/actions/update_fee.rb
|