lightning-invoice 0.1.0 → 0.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af1b94aef372d8292e484d74ce290e23636133e8bc665c7c290db17115fb6bd5
4
- data.tar.gz: b38a7257c18a3967420c2014dfa4f6d4379be29210830cd564b64d9d42d0e877
3
+ metadata.gz: 375d36d83038fe6b7217886fdcfc6319ebec19e9d166f3f730bb8c77101f1540
4
+ data.tar.gz: f174bf5270d239dabffd270d7e9b432c9b38b6c5b535f17f639f6ca0a5534775
5
5
  SHA512:
6
- metadata.gz: ed96a93cce981352263d8d8391311471b6affebbc89e8b896c03beca15557039903b6f3b5d8744cf7197eb9a2c6d3ed99645277c45e33d9d0d08474d64a8f5f5
7
- data.tar.gz: cb4322f321c4d3d441e8979d086cbfffe352b64740a2fda5c77850ab8da08a977cb67b06ecf0a8e86955fca85cbf03ef7d1c600cebd9edb9f75f0c0f61ef1b7d
6
+ metadata.gz: aa04a1fbf65880f4b74888a37dc7a972343acc4482eaf479d4231cc763e2615f328edd493cb78a991fbc84338d1288226a77c3af591e859384fdcd37bbc18dd8
7
+ data.tar.gz: dfacafa8dd99a981463d19bc261f758281a1fc3941c854b2ce372827e8e8c396ee3ee93fc32c35bbad5e255fb657bbdc6f9000b29f5905a83ff46e2949b77bcb
data/README.md CHANGED
@@ -41,14 +41,14 @@ irb(main):004:0> message.multiplier = "u"
41
41
  => "u"
42
42
  irb(main):005:0> message.timestamp = Time.now.to_i
43
43
  => 1535552315
44
- irb(main):006:0> message.payment_hash = "0001020304050607080900010203040506070809000102030405060708090102".htb
45
- => "\x00\x01\x02\x03\x04\x05\x06\a\b\t\x00\x01\x02\x03\x04\x05\x06\a\b\t\x00\x01\x02\x03\x04\x05\x06\a\b\t\x01\x02"
44
+ irb(main):006:0> message.payment_hash = "0001020304050607080900010203040506070809000102030405060708090102"
45
+ => "0001020304050607080900010203040506070809000102030405060708090102"
46
46
  irb(main):007:0> message.description = "Please consider supporting this project"
47
47
  => "Please consider supporting this project"
48
48
  irb(main):008:0> message.expiry = 60
49
49
  => 60
50
- irb(main):009:0> message.signature = "38ec6891345e204145be8a3a99de38e98a39d6a569434e1845c8af7205afcfcc7f425fcd1463e93c32881ead0d6e356d467ec8c02553f9aab15e5738b11f127f00".htb
51
- => "8\xECh\x914^ AE\xBE\x8A:\x99\xDE8\xE9\x8A9\xD6\xA5iCN\x18E\xC8\xAFr\x05\xAF\xCF\xCC\x7FB_\xCD\x14c\xE9<2\x88\x1E\xAD\rn5mF~\xC8\xC0%S\xF9\xAA\xB1^W8\xB1\x1F\x12\x7F\x00"
50
+ irb(main):009:0> message.signature = "38ec6891345e204145be8a3a99de38e98a39d6a569434e1845c8af7205afcfcc7f425fcd1463e93c32881ead0d6e356d467ec8c02553f9aab15e5738b11f127f00"
51
+ => "38ec6891345e204145be8a3a99de38e98a39d6a569434e1845c8af7205afcfcc7f425fcd1463e93c32881ead0d6e356d467ec8c02553f9aab15e5738b11f127f00"
52
52
  irb(main):010:0> message.fallback_address = "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"
53
53
  => "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"
54
54
  irb(main):011:0> message.to_bech32
@@ -61,7 +61,7 @@ Decode Payment
61
61
  ```
62
62
 
63
63
  irb(main):012:0> Lightning::Invoice.parse("lnbc2500u1pdcd2empp5qqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqqqsyqcyq5rqwzqfqypqdpl2pkx2ctnv5sxxmmwwd5kgetjypeh2ursdae8g6twvus8g6rfwvs8qun0dfjkxaqxqzpufppqw508d6qejxtdg4y5r3zarvary0c5xw7k8rkx3yf5tcsyz3d73gafnh3cax9rn449d9p5uxz9ezhhypd0elx87sjle52x86fux2ypatgddc6k63n7erqz25le42c4u4ecky03ylcqgtxcst")
64
- => #<Lightning::Invoice::Message:0x007fd1eb2dc390 @amount=2500, @timestamp=1535552315, @expiry=60, @min_final_cltv_expiry=9, @routing_info=[], @prefix="lnbc", @multiplier="u", @payment_hash="\x00\x01\x02\x03\x04\x05\x06\a\b\t\x00\x01\x02\x03\x04\x05\x06\a\b\t\x00\x01\x02\x03\x04\x05\x06\a\b\t\x01\x02", @description="Please consider supporting this project", @signature="8\xECh\x914^ AE\xBE\x8A:\x99\xDE8\xE9\x8A9\xD6\xA5iCN\x18E\xC8\xAFr\x05\xAF\xCF\xCC\x7FB_\xCD\x14c\xE9<2\x88\x1E\xAD\rn5mF~\xC8\xC0%S\xF9\xAA\xB1^W8\xB1\x1F\x12\x7F\x00", @fallback_address="bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4">
64
+ => #<Lightning::Invoice::Message:0x00007f986c123b38 @amount=2500, @timestamp=1535552315, @expiry=60, @min_final_cltv_expiry=9, @routing_info=[], @prefix="lnbc", @multiplier="u", @payment_hash="0001020304050607080900010203040506070809000102030405060708090102", @description="Please consider supporting this project", @signature="38ec6891345e204145be8a3a99de38e98a39d6a569434e1845c8af7205afcfcc7f425fcd1463e93c32881ead0d6e356d467ec8c02553f9aab15e5738b11f127f00", @fallback_address="bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4">
65
65
 
66
66
  ```
67
67
 
@@ -71,6 +71,14 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
71
71
 
72
72
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
73
73
 
74
+ ## Demo
75
+
76
+ ### Online Lightning Invoice Encoder/Decoder
77
+ - repository
78
+ - https://github.com/Yamaguchi/lightning-invoice
79
+ - website
80
+ - https://lightning-invoice-rails.herokuapp.com/
81
+
74
82
  ## Contributing
75
83
 
76
84
  Bug reports and pull requests are welcome on GitHub at https://github.com/Yamaguchi/lightning-invoice. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
@@ -32,7 +32,7 @@ module Lightning
32
32
  if payment_hash
33
33
  data += [1]
34
34
  data += [1, 20]
35
- data += Invoice.buffer_to_word(payment_hash)
35
+ data += Invoice.buffer_to_word(payment_hash.htb)
36
36
  end
37
37
  if description
38
38
  data += [13]
@@ -43,12 +43,12 @@ module Lightning
43
43
  if pubkey
44
44
  data += [19]
45
45
  data += [1, 21]
46
- data += Invoice.buffer_to_word(pubkey)
46
+ data += Invoice.buffer_to_word(pubkey.htb)
47
47
  end
48
48
  if description_hash
49
49
  data += [23]
50
50
  data += [1, 20]
51
- data += Invoice.buffer_to_word(description_hash)
51
+ data += Invoice.buffer_to_word(description_hash.htb)
52
52
  end
53
53
  if expiry && expiry != 3600
54
54
  data += [6]
@@ -88,7 +88,7 @@ module Lightning
88
88
  end
89
89
  data += Invoice.buffer_to_word(tmp.pack("C*"))
90
90
  end
91
- data += Invoice.buffer_to_word(signature)
91
+ data += Invoice.buffer_to_word(signature.htb)
92
92
  Bech32.encode(human, data)
93
93
  end
94
94
 
@@ -131,13 +131,13 @@ module Lightning
131
131
  index += 3 + data_length
132
132
  case type
133
133
  when 1
134
- message.payment_hash = bytes[0...64].pack("C*")
134
+ message.payment_hash = bytes[0...64].pack("C*").bth
135
135
  when 13
136
136
  message.description = bytes.pack("C*").force_encoding('utf-8')
137
137
  when 19
138
- message.pubkey = bytes[0...66].pack("C*")
138
+ message.pubkey = bytes[0...66].pack("C*").bth
139
139
  when 23
140
- message.description_hash = bytes[0...64].pack("C*")
140
+ message.description_hash = bytes[0...64].pack("C*").bth
141
141
  when 6
142
142
  message.expiry = to_int(data)
143
143
  when 24
@@ -158,8 +158,8 @@ module Lightning
158
158
  offset = 0
159
159
  while offset < bytes.size
160
160
  message.routing_info << Lightning::Invoice::RoutingInfo.new(
161
- bytes[offset...offset + 33].pack("C*"),
162
- bytes[offset + 33...offset + 41].pack("C*"),
161
+ bytes[offset...offset + 33].pack("C*").bth,
162
+ bytes[offset + 33...offset + 41].pack("C*").bth,
163
163
  to_int(bytes[offset + 41...offset + 45]),
164
164
  to_int(bytes[offset + 45...offset + 49]),
165
165
  to_int(bytes[offset + 49...offset + 51])
@@ -169,7 +169,7 @@ module Lightning
169
169
  else
170
170
  end
171
171
  end
172
- message.signature = word_to_buffer(data_part[data_part.size - 104..-1], true)
172
+ message.signature = word_to_buffer(data_part[data_part.size - 104..-1], true).bth
173
173
  message
174
174
  end
175
175
 
@@ -2,7 +2,7 @@ module Lightning
2
2
  module Invoice
3
3
  class RoutingInfo
4
4
  attr_accessor :pubkey, :short_channel_id, :fee_base_msat, :fee_proportional_millionths, :cltv_expiry_delta
5
-
5
+
6
6
  def initialize(pubkey, short_channel_id, fee_base_msat, fee_proportional_millionths, cltv_expiry_delta)
7
7
  @pubkey = pubkey
8
8
  @short_channel_id = short_channel_id
@@ -10,10 +10,10 @@ module Lightning
10
10
  @fee_proportional_millionths = fee_proportional_millionths
11
11
  @cltv_expiry_delta = cltv_expiry_delta
12
12
  end
13
-
13
+
14
14
  def to_array
15
- pubkey.unpack("C*") +
16
- short_channel_id.unpack("C*") +
15
+ pubkey.htb.unpack("C*") +
16
+ short_channel_id.htb.unpack("C*") +
17
17
  Invoice.int_to_array(fee_base_msat, 5, 4) +
18
18
  Invoice.int_to_array(fee_proportional_millionths, 5, 4) +
19
19
  Invoice.int_to_array(cltv_expiry_delta)
@@ -1,5 +1,5 @@
1
1
  module Lightning
2
2
  module Invoice
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lightning-invoice
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hajime Yamaguchi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-30 00:00:00.000000000 Z
11
+ date: 2018-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler