rack-lightning 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -0
- data/lib/rack/lightning.rb +4 -2
- data/lib/rack/lightning/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84093a3b28a33b94f9dcb0db2f1a85dab9d4000d
|
4
|
+
data.tar.gz: 55f1bf66848231e54a51a0d5c3d27b1a38783f25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38a9cf9d3bd3ebbc7c407e09605a949dea750572f43e7b9571c87c184a92a9c7188d613300f7a2c78c328bbf7e26b70a4eaa2686eae26122dbdc3de1682c2d9f
|
7
|
+
data.tar.gz: 3a83eee6a8e10b815b364f6a1ceda7050b92c4d4481e27515643fcdef912bb7ed7cd53a1a139ceb2a21d7767b158083ed6ac3762a19e09db4f08c234548e564c
|
data/README.md
CHANGED
@@ -51,6 +51,25 @@ The middleware accepts the following configuration options:
|
|
51
51
|
* `address`: the address of the lnd gRPC service( default: localhost:10009)
|
52
52
|
* `credentials_path`: path to the tls.cert (default: ~/.lnd/tls.cert)
|
53
53
|
* `macaroon_path`: path to the macaroon path (default: ~/.lnd/data/chain/bitcoin/testnet/admin.macaroon)
|
54
|
+
* `credentials`: instead of configuring a `credentials_path` you can pass the content of the tls.cert directly
|
55
|
+
* `macaroon`: instead of configuring a `macaroon_path` you can pass the hex content of the macaroon directly
|
56
|
+
|
57
|
+
### How to pass credentials or macaroon data from a variable like a environment varibale?
|
58
|
+
|
59
|
+
The tls.cert and the macaroon config can be loaded from a variable:
|
60
|
+
|
61
|
+
```ruby
|
62
|
+
ENV['LND_CREDENTIALS'] = "the content of your tls.cert file"
|
63
|
+
ENV['LND_MACAROON'] = "the hex encoded content of your macaroon file"
|
64
|
+
# you can get the macaroon content like this:
|
65
|
+
# ::File.read(::File.expand_path("/path/to/admin.macaroon")).each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join
|
66
|
+
|
67
|
+
Example = Rack::Builder.new {
|
68
|
+
use Rack::Lightning, { macaroon: ENV['LND_MACAROON'], credentials: ENV['LND_CREDENTIALS'] }
|
69
|
+
run Proc.new { |env| ['200', {'Content-Type' => 'text/html'}, ['get rack\'d']] }
|
70
|
+
}.to_app
|
71
|
+
```
|
72
|
+
|
54
73
|
|
55
74
|
## What is the Lightning Network?
|
56
75
|
|
data/lib/rack/lightning.rb
CHANGED
@@ -14,8 +14,10 @@ module Rack
|
|
14
14
|
@options[:address] ||= 'localhost:10009'
|
15
15
|
@options[:timeout] ||= 5
|
16
16
|
@options[:credentials] ||= ::File.read(::File.expand_path(@options[:credentials_path] || "~/.lnd/tls.cert"))
|
17
|
-
|
18
|
-
|
17
|
+
@options[:macaroon] ||= begin
|
18
|
+
macaroon_binary = ::File.read(::File.expand_path(@options[:macaroon_path] || "~/.lnd/data/chain/bitcoin/testnet/admin.macaroon"))
|
19
|
+
macaroon_binary.each_byte.map { |b| b.to_s(16).rjust(2,'0') }.join
|
20
|
+
end
|
19
21
|
@lnd_client = Lnrpc::Lightning::Stub.new(@options[:address], GRPC::Core::ChannelCredentials.new(@options[:credentials]))
|
20
22
|
end
|
21
23
|
|