lighstorm 0.0.7 → 0.0.9
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 +1 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +1 -0
- data/Gemfile +5 -3
- data/Gemfile.lock +15 -10
- data/README.md +4 -3
- data/Rakefile +11 -0
- data/adapters/edges/payment/purpose.rb +22 -11
- data/adapters/edges/payment.rb +51 -12
- data/adapters/invoice.rb +139 -17
- data/components/cache.rb +7 -2
- data/controllers/forward/group_by_channel.rb +1 -1
- data/controllers/invoice/actions/create.rb +22 -6
- data/controllers/invoice/actions/pay.rb +71 -13
- data/controllers/invoice/all.rb +16 -6
- data/controllers/invoice/decode.rb +44 -0
- data/controllers/invoice/find_by_secret_hash.rb +7 -1
- data/controllers/invoice.rb +17 -3
- data/controllers/node/actions/pay.rb +109 -0
- data/controllers/payment/actions/pay.rb +104 -0
- data/controllers/payment/all.rb +49 -16
- data/controllers/transaction/all.rb +54 -0
- data/controllers/transaction.rb +13 -0
- data/deleted.sh +1 -0
- data/docs/README.md +292 -49
- data/docs/_coverpage.md +1 -1
- data/docs/index.html +1 -1
- data/helpers/time_expression.rb +33 -0
- data/models/connections/payment_channel.rb +13 -8
- data/models/edges/channel.rb +1 -1
- data/models/edges/payment.rb +51 -20
- data/models/errors.rb +29 -1
- data/models/invoice.rb +67 -11
- data/models/nodes/node.rb +32 -0
- data/models/satoshis.rb +11 -3
- data/models/secret.rb +31 -0
- data/models/transaction.rb +42 -0
- data/ports/dsl/lighstorm.rb +2 -0
- data/static/cache.rb +14 -13
- data/static/spec.rb +1 -1
- metadata +12 -4
- data/adapters/payment_request.rb +0 -87
- data/models/payment_request.rb +0 -72
data/models/payment_request.rb
DELETED
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'digest'
|
4
|
-
require_relative 'satoshis'
|
5
|
-
|
6
|
-
module Lighstorm
|
7
|
-
module Models
|
8
|
-
class PaymentRequest
|
9
|
-
attr_reader :_key, :code, :address
|
10
|
-
|
11
|
-
def initialize(data)
|
12
|
-
@data = data
|
13
|
-
|
14
|
-
@_key = data[:_key] || Digest::SHA256.hexdigest(
|
15
|
-
data[:code] || "#{data[:code][:amount][:millisatoshis]}#{Time.now}"
|
16
|
-
)
|
17
|
-
|
18
|
-
@code = data[:code]
|
19
|
-
|
20
|
-
@address = data[:address]
|
21
|
-
end
|
22
|
-
|
23
|
-
def amount
|
24
|
-
@amount ||= Satoshis.new(millisatoshis: @data[:amount][:millisatoshis])
|
25
|
-
end
|
26
|
-
|
27
|
-
def description
|
28
|
-
@description ||= Struct.new(:data) do
|
29
|
-
def memo
|
30
|
-
data[:memo]
|
31
|
-
end
|
32
|
-
|
33
|
-
def hash
|
34
|
-
data[:hash]
|
35
|
-
end
|
36
|
-
|
37
|
-
def to_h
|
38
|
-
{ memo: memo, hash: hash }
|
39
|
-
end
|
40
|
-
end.new(@data[:description] || {})
|
41
|
-
end
|
42
|
-
|
43
|
-
def secret
|
44
|
-
@secret ||= Struct.new(:data) do
|
45
|
-
def preimage
|
46
|
-
data[:preimage]
|
47
|
-
end
|
48
|
-
|
49
|
-
def hash
|
50
|
-
data[:hash]
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_h
|
54
|
-
# Don't expose 'secret' by default: Security
|
55
|
-
{ hash: hash }
|
56
|
-
end
|
57
|
-
end.new(@data[:secret] || {})
|
58
|
-
end
|
59
|
-
|
60
|
-
def to_h
|
61
|
-
# Don't expose 'address' by default: Privacy
|
62
|
-
{
|
63
|
-
_key: _key,
|
64
|
-
code: code,
|
65
|
-
amount: amount.to_h,
|
66
|
-
description: description.to_h,
|
67
|
-
secret: secret.to_h
|
68
|
-
}
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|