lighstorm 0.0.8 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/.env.example +1 -0
  3. data/.gitignore +1 -0
  4. data/.rubocop.yml +1 -0
  5. data/Gemfile +5 -3
  6. data/Gemfile.lock +13 -8
  7. data/README.md +11 -3
  8. data/Rakefile +11 -0
  9. data/adapters/edges/payment/purpose.rb +22 -11
  10. data/adapters/edges/payment.rb +51 -12
  11. data/adapters/invoice.rb +133 -31
  12. data/components/cache.rb +7 -2
  13. data/controllers/forward/group_by_channel.rb +1 -1
  14. data/controllers/invoice/actions/create.rb +22 -6
  15. data/controllers/invoice/actions/pay.rb +79 -13
  16. data/controllers/invoice/all.rb +16 -6
  17. data/controllers/invoice/decode.rb +6 -6
  18. data/controllers/invoice/find_by_secret_hash.rb +7 -1
  19. data/controllers/invoice.rb +15 -6
  20. data/controllers/node/actions/pay.rb +114 -0
  21. data/controllers/payment/actions/pay.rb +104 -0
  22. data/controllers/payment/all.rb +79 -28
  23. data/controllers/transaction/all.rb +54 -0
  24. data/controllers/transaction.rb +13 -0
  25. data/deleted.sh +1 -0
  26. data/docs/README.md +307 -51
  27. data/docs/_coverpage.md +1 -1
  28. data/docs/index.html +1 -1
  29. data/helpers/time_expression.rb +33 -0
  30. data/models/connections/payment_channel.rb +13 -8
  31. data/models/edges/channel.rb +1 -1
  32. data/models/edges/payment.rb +51 -20
  33. data/models/errors.rb +29 -1
  34. data/models/invoice.rb +69 -11
  35. data/models/nodes/node.rb +35 -0
  36. data/models/satoshis.rb +11 -3
  37. data/models/secret.rb +37 -0
  38. data/models/transaction.rb +42 -0
  39. data/ports/dsl/lighstorm.rb +2 -0
  40. data/static/cache.rb +14 -13
  41. data/static/spec.rb +1 -1
  42. metadata +11 -4
  43. data/adapters/payment_request.rb +0 -87
  44. data/models/payment_request.rb +0 -72
@@ -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[: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