lightning-invoice 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +1 -1
- data/lib/lightning/invoice.rb +44 -21
- data/lib/lightning/invoice/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5fb7e66b69c9bfb71f10cc6527f34a2ef00ca59960256cea84e6fe7359ba5ef
|
4
|
+
data.tar.gz: 592564e048824ac484286f191126c5d10c1c8d1f2bd75eb203882463d6c0c2ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4533da37df5d1148c5ee9fc223be627bf116bb51f152194fec37dab1a57ace59e689f600151f30b3984bab4a753e8a3f1992cb1a1241341cc9c735d7421866b7
|
7
|
+
data.tar.gz: dfcfbe3d8059b6779362d7fb73d138e69066b6544d75583c915348ef3bac41e94e081dd258a3ec1a15f7d14084d18f2d44f82b077ea87dfbad592a948065c2cb
|
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at gen.yamaguchi0@gmail.com. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/lib/lightning/invoice.rb
CHANGED
@@ -19,10 +19,53 @@ module Lightning
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def to_bech32
|
22
|
+
human = to_human_string
|
23
|
+
data = to_data_array
|
24
|
+
data += Invoice.buffer_to_word(signature.htb)
|
25
|
+
Bech32.encode(human, data)
|
26
|
+
end
|
27
|
+
|
28
|
+
def fallback_address_type(fallback_address)
|
29
|
+
address_types = {
|
30
|
+
'lnbc' => [0, 5],
|
31
|
+
'lntb' => [111, 196]
|
32
|
+
}
|
33
|
+
|
34
|
+
hrp, data = Bech32.decode(fallback_address)
|
35
|
+
if hrp
|
36
|
+
0
|
37
|
+
else
|
38
|
+
decoded = [Bitcoin::Base58.decode(fallback_address)].pack("H*").unpack("C*")
|
39
|
+
if decoded[0] == address_types[prefix][0]
|
40
|
+
17
|
41
|
+
elsif decoded[0] == address_types[prefix][1]
|
42
|
+
18
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def sign(key, recovery: '00')
|
48
|
+
human = to_human_string
|
49
|
+
data = to_data_array
|
50
|
+
sig_data = human.bth + Invoice.word_to_buffer(data).bth
|
51
|
+
sig_as_der = key.sign(Bitcoin.sha256(sig_data.htb))
|
52
|
+
sig = ECDSA::Format::SignatureDerString.decode(sig_as_der)
|
53
|
+
self.signature = sig.r.to_s(16).rjust(64, '0') + sig.s.to_s(16).rjust(64, '0')
|
54
|
+
self.signature += recovery
|
55
|
+
self
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def to_human_string
|
22
61
|
human = +''
|
23
62
|
human << prefix
|
24
63
|
human << amount.to_s if amount && amount > 0
|
25
64
|
human << multiplier if multiplier
|
65
|
+
human
|
66
|
+
end
|
67
|
+
|
68
|
+
def to_data_array
|
26
69
|
data = []
|
27
70
|
data += Invoice.int_to_array(timestamp)
|
28
71
|
if payment_hash && !payment_hash.empty?
|
@@ -84,27 +127,7 @@ module Lightning
|
|
84
127
|
end
|
85
128
|
data += Invoice.buffer_to_word(tmp.pack("C*"))
|
86
129
|
end
|
87
|
-
data
|
88
|
-
Bech32.encode(human, data)
|
89
|
-
end
|
90
|
-
|
91
|
-
def fallback_address_type(fallback_address)
|
92
|
-
address_types = {
|
93
|
-
'lnbc' => [0, 5],
|
94
|
-
'lntb' => [111, 196]
|
95
|
-
}
|
96
|
-
|
97
|
-
hrp, data = Bech32.decode(fallback_address)
|
98
|
-
if hrp
|
99
|
-
0
|
100
|
-
else
|
101
|
-
decoded = [Bitcoin::Base58.decode(fallback_address)].pack("H*").unpack("C*")
|
102
|
-
if decoded[0] == address_types[prefix][0]
|
103
|
-
17
|
104
|
-
elsif decoded[0] == address_types[prefix][1]
|
105
|
-
18
|
106
|
-
end
|
107
|
-
end
|
130
|
+
data
|
108
131
|
end
|
109
132
|
end
|
110
133
|
|
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.
|
4
|
+
version: 0.1.4
|
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-
|
11
|
+
date: 2018-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|