lighstorm 0.0.14 → 0.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/Gemfile.lock +7 -7
  4. data/README.md +7 -7
  5. data/adapters/bitcoin/address.rb +19 -0
  6. data/adapters/bitcoin/transaction.rb +34 -0
  7. data/adapters/lightning/connections/channel_node/fee.rb +28 -0
  8. data/adapters/lightning/connections/channel_node/policy.rb +63 -0
  9. data/adapters/lightning/connections/channel_node.rb +77 -0
  10. data/adapters/lightning/connections/payment_channel.rb +30 -0
  11. data/adapters/lightning/edges/channel.rb +98 -0
  12. data/adapters/lightning/edges/forward.rb +42 -0
  13. data/adapters/lightning/edges/payment/purpose.rb +45 -0
  14. data/adapters/lightning/edges/payment.rb +89 -0
  15. data/adapters/lightning/invoice.rb +186 -0
  16. data/adapters/lightning/nodes/node.rb +113 -0
  17. data/controllers/action.rb +1 -1
  18. data/controllers/bitcoin/address/actions/create.rb +91 -0
  19. data/controllers/bitcoin/address/actions/pay.rb +119 -0
  20. data/controllers/bitcoin/address.rb +24 -0
  21. data/controllers/bitcoin/transaction/all.rb +65 -0
  22. data/controllers/bitcoin/transaction.rb +25 -0
  23. data/controllers/concerns/impersonatable.rb +5 -3
  24. data/controllers/connection.rb +1 -1
  25. data/controllers/lightning/channel/actions/apply_gossip.rb +201 -0
  26. data/controllers/lightning/channel/actions/update_fee.rb +94 -0
  27. data/controllers/lightning/channel/all.rb +85 -0
  28. data/controllers/lightning/channel/find_by_id.rb +155 -0
  29. data/controllers/lightning/channel/mine.rb +116 -0
  30. data/controllers/lightning/channel.rb +43 -0
  31. data/controllers/lightning/forward/all.rb +250 -0
  32. data/controllers/lightning/forward/group_by_channel.rb +91 -0
  33. data/controllers/lightning/forward.rb +36 -0
  34. data/controllers/lightning/invoice/actions/create.rb +90 -0
  35. data/controllers/lightning/invoice/actions/pay.rb +97 -0
  36. data/controllers/lightning/invoice/actions/pay_through_route.rb +73 -0
  37. data/controllers/lightning/invoice/all.rb +82 -0
  38. data/controllers/lightning/invoice/decode.rb +50 -0
  39. data/controllers/lightning/invoice/find_by_code.rb +76 -0
  40. data/controllers/lightning/invoice/find_by_secret_hash.rb +56 -0
  41. data/controllers/lightning/invoice.rb +64 -0
  42. data/controllers/lightning/node/actions/apply_gossip.rb +114 -0
  43. data/controllers/lightning/node/actions/pay.rb +117 -0
  44. data/controllers/lightning/node/all.rb +69 -0
  45. data/controllers/lightning/node/find_by_public_key.rb +55 -0
  46. data/controllers/lightning/node/myself.rb +36 -0
  47. data/controllers/lightning/node.rb +35 -0
  48. data/controllers/lightning/payment/actions/pay.rb +110 -0
  49. data/controllers/lightning/payment/all.rb +439 -0
  50. data/controllers/lightning/payment.rb +37 -0
  51. data/controllers/lightning/secret/valid_proof.rb +60 -0
  52. data/controllers/lightning/secret.rb +16 -0
  53. data/controllers/wallet/activity/all.rb +196 -0
  54. data/controllers/wallet/activity.rb +28 -0
  55. data/controllers/wallet/balance.rb +3 -3
  56. data/controllers/wallet.rb +1 -1
  57. data/docs/README.md +229 -148
  58. data/docs/_coverpage.md +1 -1
  59. data/docs/index.html +1 -1
  60. data/lighstorm.gemspec +1 -1
  61. data/models/bitcoin/address.rb +49 -0
  62. data/models/bitcoin/transaction.rb +41 -0
  63. data/models/concerns/protectable.rb +1 -1
  64. data/models/errors.rb +7 -8
  65. data/models/lightning/connections/channel_node/accounting.rb +27 -0
  66. data/models/lightning/connections/channel_node/fee.rb +82 -0
  67. data/models/lightning/connections/channel_node/htlc/blocks/delta.rb +41 -0
  68. data/models/lightning/connections/channel_node/htlc.rb +88 -0
  69. data/models/lightning/connections/channel_node/policy.rb +41 -0
  70. data/models/lightning/connections/channel_node.rb +86 -0
  71. data/models/lightning/connections/forward_channel.rb +31 -0
  72. data/models/lightning/connections/payment_channel.rb +58 -0
  73. data/models/lightning/edges/channel/accounting.rb +87 -0
  74. data/models/lightning/edges/channel/hop.rb +67 -0
  75. data/models/lightning/edges/channel.rb +197 -0
  76. data/models/lightning/edges/forward.rb +51 -0
  77. data/models/lightning/edges/groups/channel_forwards/analysis.rb +71 -0
  78. data/models/lightning/edges/groups/channel_forwards.rb +39 -0
  79. data/models/lightning/edges/payment.rb +104 -0
  80. data/models/lightning/invoice.rb +115 -0
  81. data/models/lightning/nodes/node/lightning.rb +33 -0
  82. data/models/lightning/nodes/node/platform.rb +50 -0
  83. data/models/lightning/nodes/node.rb +145 -0
  84. data/models/lightning/rate.rb +37 -0
  85. data/models/lightning/secret.rb +57 -0
  86. data/models/satoshis.rb +1 -1
  87. data/models/wallet/activity.rb +54 -0
  88. data/models/wallet/balance.rb +42 -0
  89. data/ports/dsl/lighstorm.rb +29 -16
  90. data/static/cache.rb +2 -0
  91. data/static/spec.rb +1 -1
  92. metadata +76 -70
  93. data/adapters/connections/channel_node/fee.rb +0 -26
  94. data/adapters/connections/channel_node/policy.rb +0 -61
  95. data/adapters/connections/channel_node.rb +0 -75
  96. data/adapters/connections/payment_channel.rb +0 -28
  97. data/adapters/edges/channel.rb +0 -96
  98. data/adapters/edges/forward.rb +0 -40
  99. data/adapters/edges/payment/purpose.rb +0 -43
  100. data/adapters/edges/payment.rb +0 -87
  101. data/adapters/invoice.rb +0 -184
  102. data/adapters/nodes/node.rb +0 -111
  103. data/adapters/transaction.rb +0 -23
  104. data/controllers/activity/all.rb +0 -194
  105. data/controllers/activity.rb +0 -26
  106. data/controllers/channel/actions/apply_gossip.rb +0 -193
  107. data/controllers/channel/actions/update_fee.rb +0 -91
  108. data/controllers/channel/all.rb +0 -83
  109. data/controllers/channel/find_by_id.rb +0 -153
  110. data/controllers/channel/mine.rb +0 -114
  111. data/controllers/channel.rb +0 -41
  112. data/controllers/forward/all.rb +0 -248
  113. data/controllers/forward/group_by_channel.rb +0 -89
  114. data/controllers/forward.rb +0 -34
  115. data/controllers/invoice/actions/create.rb +0 -88
  116. data/controllers/invoice/actions/pay.rb +0 -95
  117. data/controllers/invoice/actions/pay_through_route.rb +0 -71
  118. data/controllers/invoice/all.rb +0 -80
  119. data/controllers/invoice/decode.rb +0 -44
  120. data/controllers/invoice/find_by_code.rb +0 -70
  121. data/controllers/invoice/find_by_secret_hash.rb +0 -54
  122. data/controllers/invoice.rb +0 -62
  123. data/controllers/node/actions/apply_gossip.rb +0 -112
  124. data/controllers/node/actions/pay.rb +0 -115
  125. data/controllers/node/all.rb +0 -67
  126. data/controllers/node/find_by_public_key.rb +0 -53
  127. data/controllers/node/myself.rb +0 -34
  128. data/controllers/node.rb +0 -33
  129. data/controllers/payment/actions/pay.rb +0 -108
  130. data/controllers/payment/all.rb +0 -437
  131. data/controllers/payment.rb +0 -35
  132. data/controllers/secret/valid_proof.rb +0 -58
  133. data/controllers/transaction/all.rb +0 -61
  134. data/controllers/transaction.rb +0 -25
  135. data/models/activity.rb +0 -52
  136. data/models/connections/channel_node/accounting.rb +0 -25
  137. data/models/connections/channel_node/fee.rb +0 -80
  138. data/models/connections/channel_node/htlc/blocks/delta.rb +0 -39
  139. data/models/connections/channel_node/htlc.rb +0 -86
  140. data/models/connections/channel_node/policy.rb +0 -39
  141. data/models/connections/channel_node.rb +0 -84
  142. data/models/connections/forward_channel.rb +0 -29
  143. data/models/connections/payment_channel.rb +0 -56
  144. data/models/edges/channel/accounting.rb +0 -85
  145. data/models/edges/channel/hop.rb +0 -65
  146. data/models/edges/channel.rb +0 -195
  147. data/models/edges/forward.rb +0 -49
  148. data/models/edges/groups/channel_forwards/analysis.rb +0 -69
  149. data/models/edges/groups/channel_forwards.rb +0 -37
  150. data/models/edges/payment.rb +0 -102
  151. data/models/invoice.rb +0 -113
  152. data/models/nodes/node/lightning.rb +0 -31
  153. data/models/nodes/node/platform.rb +0 -48
  154. data/models/nodes/node.rb +0 -143
  155. data/models/rate.rb +0 -35
  156. data/models/secret.rb +0 -55
  157. data/models/transaction.rb +0 -39
  158. data/models/wallet.rb +0 -40
@@ -0,0 +1,115 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ require_relative '../satoshis'
6
+ require_relative '../../controllers/lightning/invoice/actions/create'
7
+ require_relative '../../controllers/lightning/invoice/actions/pay'
8
+ require_relative '../../controllers/lightning/invoice/actions/pay_through_route'
9
+
10
+ module Lighstorm
11
+ module Model
12
+ module Lightning
13
+ class Invoice
14
+ attr_reader :_key, :created_at, :expires_at, :settled_at, :state, :payable, :code
15
+
16
+ def initialize(data, components)
17
+ @data = data
18
+ @components = components
19
+
20
+ @_key = data[:_key]
21
+ @created_at = data[:created_at]
22
+ @expires_at = data[:expires_at]
23
+ @settled_at = data[:settled_at]
24
+ @state = data[:state]
25
+
26
+ @payable = data[:payable]
27
+
28
+ @code = data[:code]
29
+ end
30
+
31
+ def payment
32
+ if payable != 'once' || @data[:payments].size > 1
33
+ raise InvoiceMayHaveMultiplePaymentsError, "payable: #{payable}, payments: #{@data[:payments].size.size}"
34
+ end
35
+
36
+ @payment ||= payments.first
37
+ end
38
+
39
+ def payments
40
+ @payments ||= @data[:payments]&.map { |data| Payment.new(data, @components) }
41
+ end
42
+
43
+ def amount
44
+ @amount ||= @data[:amount] ? Satoshis.new(millisatoshis: @data[:amount][:millisatoshis]) : nil
45
+ end
46
+
47
+ def received
48
+ @received ||= @data[:received] ? Satoshis.new(millisatoshis: @data[:received][:millisatoshis]) : nil
49
+ end
50
+
51
+ def secret
52
+ @secret ||= Secret.new(@data[:secret], @components)
53
+ end
54
+
55
+ def description
56
+ @description ||= Struct.new(:data) do
57
+ def memo
58
+ data[:memo]
59
+ end
60
+
61
+ def hash
62
+ data[:hash]
63
+ end
64
+
65
+ def to_h
66
+ { memo: memo, hash: hash }
67
+ end
68
+ end.new(@data[:description] || {})
69
+ end
70
+
71
+ def to_h
72
+ result = {
73
+ _key: _key,
74
+ created_at: created_at,
75
+ expires_at: expires_at,
76
+ settled_at: settled_at,
77
+ payable: payable,
78
+ state: state,
79
+ code: code,
80
+ amount: amount&.to_h,
81
+ received: received&.to_h,
82
+ description: description.to_h,
83
+ secret: secret.to_h,
84
+ payments: payments&.map(&:to_h)
85
+ }
86
+ end
87
+
88
+ def pay(
89
+ amount: nil, message: nil, route: nil,
90
+ fee: nil,
91
+ times_out_in: { seconds: 5 },
92
+ preview: false
93
+ )
94
+ raise MissingComponentsError if @components.nil?
95
+
96
+ if route
97
+ Controller::Lightning::Invoice::PayThroughRoute.perform(
98
+ @components, self, route: route, preview: preview
99
+ )
100
+ else
101
+ Controller::Lightning::Invoice::Pay.perform(
102
+ @components,
103
+ code: code,
104
+ amount: amount,
105
+ fee: fee,
106
+ message: message,
107
+ times_out_in: times_out_in,
108
+ preview: preview
109
+ )
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lighstorm
4
+ module Model
5
+ module Lightning
6
+ class Lightning
7
+ IMPLEMENTATION = 'lnd'
8
+
9
+ attr_reader :implementation, :version
10
+
11
+ def initialize(node)
12
+ raise Errors::NotYourNodeError unless node.myself?
13
+
14
+ @implementation = IMPLEMENTATION
15
+ @version = node.data[:platform][:lightning][:version]
16
+ end
17
+
18
+ def to_h
19
+ {
20
+ implementation: implementation,
21
+ version: version
22
+ }
23
+ end
24
+
25
+ def dump
26
+ Marshal.load(
27
+ Marshal.dump({ implementation: implementation, version: version })
28
+ )
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lightning'
4
+
5
+ require_relative '../../../../ports/grpc'
6
+ require_relative '../../../../adapters/lightning/nodes/node'
7
+
8
+ module Lighstorm
9
+ module Model
10
+ module Lightning
11
+ class Platform
12
+ attr_reader :data
13
+
14
+ def initialize(node)
15
+ @node = node
16
+ @data = @node.data[:platform]
17
+ end
18
+
19
+ def blockchain
20
+ @blockchain ||= @data ? @data[:blockchain] : nil
21
+ end
22
+
23
+ def network
24
+ @network ||= @data ? @data[:network] : nil
25
+ end
26
+
27
+ def lightning
28
+ @lightning ||= Lightning.new(@node)
29
+ end
30
+
31
+ def to_h
32
+ response = {
33
+ blockchain: blockchain,
34
+ network: network
35
+ }
36
+
37
+ response[:lightning] = lightning.to_h if @node.myself?
38
+
39
+ response
40
+ end
41
+
42
+ def dump
43
+ data = Marshal.load(Marshal.dump(@data))
44
+ data.merge(lightning: lightning.dump) if @node.myself?
45
+ data
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,145 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../../controllers/lightning/node/actions/apply_gossip'
4
+ require_relative '../../../controllers/lightning/node/actions/pay'
5
+ require_relative '../../../controllers/lightning/channel'
6
+ require_relative '../../../adapters/lightning/nodes/node'
7
+ require_relative '../../concerns/protectable'
8
+ require_relative '../../errors'
9
+
10
+ require_relative 'node/platform'
11
+
12
+ module Lighstorm
13
+ module Model
14
+ module Lightning
15
+ class Node
16
+ include Protectable
17
+
18
+ attr_reader :data, :_key, :alias, :public_key, :color
19
+
20
+ def initialize(data, components)
21
+ @data = data
22
+ @components = components
23
+
24
+ @_key = @data[:_key]
25
+ @alias = @data[:alias]
26
+ @public_key = @data[:public_key]
27
+ @color = @data[:color]
28
+ end
29
+
30
+ def myself?
31
+ @data[:myself] == true
32
+ end
33
+
34
+ def platform
35
+ @platform ||= Platform.new(self)
36
+ end
37
+
38
+ def channels
39
+ raise Errors::NotYourNodeError unless myself?
40
+
41
+ raise MissingComponentsError if @components.nil?
42
+
43
+ Controller::Lightning::Channel.mine(@components)
44
+ end
45
+
46
+ def to_h
47
+ result = {
48
+ _key: _key,
49
+ public_key: public_key
50
+ }
51
+
52
+ result[:alias] = @alias unless self.alias.nil?
53
+ result[:color] = @color unless color.nil?
54
+
55
+ result[:platform] = platform.to_h if @data[:platform]
56
+
57
+ result
58
+ end
59
+
60
+ def dump
61
+ result = Marshal.load(Marshal.dump(@data))
62
+
63
+ result[:platform] = platform.dump if @data[:platform]
64
+
65
+ result
66
+ end
67
+
68
+ def alias=(value)
69
+ protect!(value)
70
+
71
+ @alias = value[:value]
72
+
73
+ @data[:alias] = @alias
74
+
75
+ self.alias
76
+ end
77
+
78
+ def color=(value)
79
+ protect!(value)
80
+
81
+ @color = value[:value]
82
+
83
+ @data[:color] = @color
84
+
85
+ color
86
+ end
87
+
88
+ def self.adapt(gossip: nil, dump: nil)
89
+ raise TooManyArgumentsError, 'you need to pass gossip: or dump:, not both' if !gossip.nil? && !dump.nil?
90
+
91
+ raise ArgumentError, 'missing gossip: or dump:' if gossip.nil? && dump.nil?
92
+
93
+ if !gossip.nil?
94
+ new(Adapter::Lightning::Node.subscribe_channel_graph(gossip), nil)
95
+ elsif !dump.nil?
96
+ new(dump, nil)
97
+ end
98
+ end
99
+
100
+ def apply!(gossip:)
101
+ Controller::Lightning::Node::ApplyGossip.perform(
102
+ self, gossip
103
+ )
104
+ end
105
+
106
+ def send_message(
107
+ message, amount:, fee: nil, secret: nil,
108
+ times_out_in: { seconds: 5 }, through: 'amp',
109
+ preview: false
110
+ )
111
+ pay(
112
+ message: message,
113
+ amount: amount,
114
+ fee: fee,
115
+ secret: secret,
116
+ times_out_in: times_out_in,
117
+ through: through,
118
+ preview: preview
119
+ )
120
+ end
121
+
122
+ def pay(
123
+ amount:, message: nil, secret: nil,
124
+ fee: nil,
125
+ times_out_in: { seconds: 5 }, through: 'amp',
126
+ preview: false
127
+ )
128
+ raise MissingComponentsError if @components.nil?
129
+
130
+ Controller::Lightning::Node::Pay.perform(
131
+ @components,
132
+ public_key: public_key,
133
+ amount: amount,
134
+ fee: fee,
135
+ through: through,
136
+ secret: secret,
137
+ message: message,
138
+ times_out_in: times_out_in,
139
+ preview: preview
140
+ )
141
+ end
142
+ end
143
+ end
144
+ end
145
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../ports/dsl/lighstorm/errors'
4
+
5
+ module Lighstorm
6
+ module Model
7
+ module Lightning
8
+ class Rate
9
+ attr_reader :parts_per_million
10
+
11
+ # https://en.wikipedia.org/wiki/Parts-per_notation
12
+ def initialize(parts_per_million: nil)
13
+ raise MissingPartsPerMillionError, 'missing parts_per_million' if parts_per_million.nil?
14
+
15
+ # TODO
16
+ @parts_per_million = parts_per_million
17
+ end
18
+
19
+ def ppm
20
+ @parts_per_million
21
+ end
22
+
23
+ def percentage
24
+ @percentage ||= @parts_per_million.to_f / 10_000
25
+ end
26
+
27
+ def to_h
28
+ {
29
+ parts_per_million: @parts_per_million
30
+ # satoshis: satoshis,
31
+ # bitcoins: bitcoins
32
+ }
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../../controllers/lightning/secret/valid_proof'
4
+
5
+ require 'digest'
6
+
7
+ module Lighstorm
8
+ module Model
9
+ module Lightning
10
+ class Secret
11
+ attr_reader :proof, :hash
12
+
13
+ def self.generate
14
+ data = { proof: SecureRandom.hex(32) }
15
+ data[:hash] = Digest::SHA256.hexdigest([data[:proof]].pack('H*'))
16
+ data
17
+ end
18
+
19
+ def self.create(components = nil, &vcr)
20
+ data = vcr.nil? ? generate : vcr.call(-> { generate })
21
+
22
+ Secret.new(data, components)
23
+ end
24
+
25
+ def initialize(data, components)
26
+ @data = data
27
+ @components = components
28
+
29
+ @proof = data[:proof]
30
+ @hash = data[:hash]
31
+ end
32
+
33
+ def preimage
34
+ @proof
35
+ end
36
+
37
+ def valid_proof?(candidate_proof, &vcr)
38
+ raise MissingComponentsError if @components.nil?
39
+
40
+ return true if proof && proof.size == 64 && candidate_proof == proof
41
+
42
+ Controller::Lightning::Secret::ValidProof.data(
43
+ @components,
44
+ @hash, candidate_proof, &vcr
45
+ )
46
+ end
47
+
48
+ def to_h
49
+ {
50
+ proof: proof,
51
+ hash: hash
52
+ }
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
data/models/satoshis.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  require_relative '../ports/dsl/lighstorm/errors'
4
4
 
5
5
  module Lighstorm
6
- module Models
6
+ module Model
7
7
  class Satoshis
8
8
  def initialize(millisatoshis: nil, bitcoins: nil)
9
9
  if [millisatoshis, bitcoins].compact.empty?
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../lightning/invoice'
4
+ require_relative '../bitcoin/transaction'
5
+
6
+ module Lighstorm
7
+ module Model
8
+ module Wallet
9
+ class Activity
10
+ attr_reader :direction, :at, :message, :layer, :how, :_key
11
+
12
+ def initialize(data)
13
+ @data = data
14
+
15
+ @_key = @data[:_key]
16
+ @at = @data[:at]
17
+ @direction = @data[:direction]
18
+ @layer = @data[:layer]
19
+ @how = @data[:how]
20
+ @message = @data[:message]
21
+ end
22
+
23
+ def amount
24
+ @amount ||= Satoshis.new(millisatoshis: @data[:amount][:millisatoshis])
25
+ end
26
+
27
+ def invoice
28
+ @invoice ||= @data[:data][:invoice].nil? ? nil : Lightning::Invoice.new(@data[:data][:invoice], nil)
29
+ end
30
+
31
+ def transaction
32
+ @transaction ||= @data[:data][:transaction].nil? ? nil : Bitcoin::Transaction.new(@data[:data][:transaction])
33
+ end
34
+
35
+ def to_h
36
+ output = {
37
+ _key: _key,
38
+ at: at,
39
+ direction: direction,
40
+ layer: layer,
41
+ how: how,
42
+ amount: amount.to_h,
43
+ message: message
44
+ }
45
+
46
+ output[:invoice] = invoice.to_h unless invoice.nil?
47
+ output[:transaction] = transaction.to_h unless transaction.nil?
48
+
49
+ output
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative '../satoshis'
4
+
5
+ module Lighstorm
6
+ module Model
7
+ module Wallet
8
+ class Balance
9
+ attr_reader :_key, :at
10
+
11
+ def initialize(data)
12
+ @data = data
13
+
14
+ @_key = @data[:_key]
15
+ @at = @data[:at]
16
+ end
17
+
18
+ def lightning
19
+ @lightning ||= Satoshis.new(millisatoshis: @data[:lightning][:millisatoshis])
20
+ end
21
+
22
+ def bitcoin
23
+ @bitcoin ||= Satoshis.new(millisatoshis: @data[:bitcoin][:millisatoshis])
24
+ end
25
+
26
+ def total
27
+ @total ||= Satoshis.new(millisatoshis: @data[:total][:millisatoshis])
28
+ end
29
+
30
+ def to_h
31
+ {
32
+ _key: _key,
33
+ at: at,
34
+ lightning: lightning.to_h,
35
+ bitcoin: bitcoin.to_h,
36
+ total: total.to_h
37
+ }
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -6,29 +6,42 @@ require_relative '../../static/spec'
6
6
 
7
7
  require_relative '../../models/satoshis'
8
8
 
9
- require_relative '../../controllers/node'
10
- require_relative '../../controllers/channel'
11
- require_relative '../../controllers/payment'
12
- require_relative '../../controllers/forward'
13
- require_relative '../../controllers/invoice'
14
- require_relative '../../controllers/activity'
15
9
  require_relative '../../controllers/connection'
10
+
16
11
  require_relative '../../controllers/wallet'
12
+ require_relative '../../controllers/wallet/activity'
13
+
14
+ require_relative '../../controllers/lightning/node'
15
+ require_relative '../../controllers/lightning/channel'
16
+ require_relative '../../controllers/lightning/payment'
17
+ require_relative '../../controllers/lightning/forward'
18
+ require_relative '../../controllers/lightning/invoice'
19
+
20
+ require_relative '../../controllers/bitcoin/transaction'
21
+ require_relative '../../controllers/bitcoin/address'
17
22
 
18
23
  module Lighstorm
19
- Node = Controllers::Node
20
- Channel = Controllers::Channel
21
- Payment = Controllers::Payment
22
- Forward = Controllers::Forward
23
- Invoice = Controllers::Invoice
24
- Activity = Controllers::Activity
25
- Connection = Controllers::Connection
26
- Wallet = Controllers::Wallet
24
+ Connection = Controller::Connection
25
+
26
+ Wallet = Controller::Wallet
27
27
 
28
- Satoshis = Models::Satoshis
28
+ Satoshis = Model::Satoshis
29
+
30
+ module Lightning
31
+ Node = Controller::Lightning::Node
32
+ Channel = Controller::Lightning::Channel
33
+ Invoice = Controller::Lightning::Invoice
34
+ Payment = Controller::Lightning::Payment
35
+ Forward = Controller::Lightning::Forward
36
+ end
37
+
38
+ module Bitcoin
39
+ Address = Controller::Bitcoin::Address
40
+ Transaction = Controller::Bitcoin::Transaction
41
+ end
29
42
 
30
43
  def self.connect!(...)
31
- Controllers::Connection.connect!(...)
44
+ Controller::Connection.connect!(...)
32
45
  end
33
46
 
34
47
  def self.inject_middleware!(middleware_lambda)
data/static/cache.rb CHANGED
@@ -3,6 +3,8 @@
3
3
  module Lighstorm
4
4
  module Static
5
5
  CACHE = {
6
+ lightning_send_coins: false,
7
+ lightning_new_address: false,
6
8
  lightning_channel_balance: false,
7
9
  lightning_wallet_balance: false,
8
10
  lightning_get_transactions: false,
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.14',
7
+ version: '0.0.16',
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.',