lightning-invoice 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lightning/invoice.rb +18 -0
- 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: 7d9ee675efd28bb1aaa0419de6305b000fc0f9ac24f6e5b53af91c95f541f0e9
|
4
|
+
data.tar.gz: b714ce6c8d41d34854aacd30f2954a13aeb83871a335336899f49029545df850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36a04d62fb52bc2efd3069054f026d32b55b6fe453bd7c3d20f5ed4e563b6a57872a7825ffce081b0beab1bae36cfc721f6bfb6b07c0f050fdcd303b68bb0844
|
7
|
+
data.tar.gz: 84b1a06fc319b39433948ce8b2d1c960034006cfd3a055f8203511c68815524c44abca69a73f37fc928759c9439fac8aadfbbb36ef1cffde68203bbec7388075
|
data/lib/lightning/invoice.rb
CHANGED
@@ -174,6 +174,24 @@ module Lightning
|
|
174
174
|
message
|
175
175
|
end
|
176
176
|
|
177
|
+
def self.msat_to_readable(msat)
|
178
|
+
if msat >= 100_000_000_000
|
179
|
+
[(msat / 100_000_000_000).to_i, '']
|
180
|
+
elsif msat >= 100_000_000
|
181
|
+
[(msat / 100_000_000).to_i, 'm']
|
182
|
+
elsif msat >= 100_000
|
183
|
+
[(msat / 100_000).to_i, 'u']
|
184
|
+
elsif msat >= 100
|
185
|
+
[(msat / 100).to_i, 'n']
|
186
|
+
elsif msat > 0
|
187
|
+
[(msat * 10).to_i, 'p']
|
188
|
+
elsif msat == 0
|
189
|
+
[0, '']
|
190
|
+
else
|
191
|
+
raise 'amount_msat should be greater than or equal to 0'
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
177
195
|
def self.parse_human_readable(human)
|
178
196
|
human.scan(/^([a-zA-Z]+)(\d*)([munp]?)$/)&.first
|
179
197
|
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.
|
4
|
+
version: 0.1.3
|
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-10-
|
11
|
+
date: 2018-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|