-
Notifications
You must be signed in to change notification settings - Fork 92
/
config-lnd-remote.md
318 lines (240 loc) · 11 KB
/
config-lnd-remote.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
# Connecting LiT to a standalone LND process
By default LiT assumes that `lnd` is running as a standalone process locally. However
`litd` can connect to `lnd` running on a remote host.
## Quickstart
To connect Lightning Terminal to a remote LND instance first make sure your `lnd.conf`
file contains the following additional configuration settings:
```text
tlsextraip=<externally-reachable-ip-address>
rpclisten=0.0.0.0:10009
rpcmiddleware.enable=true
```
Copy the following files that are located in your `~/.lnd/data/chain/bitcoin/mainnet`
directory on your remote machine to `/some/folder/with/lnd/data/` on your local machine
(where you’ll be running LiT):
- tls.cert
- admin.macaroon
(Note that with LiT prior to `v0.3.5-alpha` all `*.macaroon` files need to be
copied from the lnd machine.)
Create a `lit.conf` file. The default location LiT will look for the configuration file
depends on your operating system:
- MacOS: `~/Library/Application Support/Lit/lit.conf`
- Linux: `~/.lit/lit.conf`
- Windows: `~/AppData/Roaming/Lit/lit.conf`
Alternatively you can specify a different location by passing `--lit-dir=~/.lit`. After
creating `lit.conf` populate it with the following configuration settings:
```text
remote.lnd.rpcserver=<externally-reachable-ip-address>:10009
remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon
remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert
```
> NOTE: It is highly recommended to not place the LND connection credentials
inside the terminal home directory (`~/.lit/`) as `litd` may overwrite some of
these files.
Run LiT:
```shell
⛰ ./litd --uipassword=UP48lm4VjqxmOxB9X9stry6VTKBRQI
```
Visit https://localhost:8443 to access LiT.
## Additional Configuration
The default "remote" mode means that `lnd` is started as a standalone process, possibly on another
host, and `litd` connects to it, right after starting its UI server. Once the connection
to the remote `lnd` node has been established, `litd` then goes ahead and starts
`faraday`, `pool` and `loop` and connects them to that `lnd` node as well.
### Connecting LiT to a remote faraday node
To instruct LiT to not start its own integrated `faraday` daemon but instead
connect to an existing node, use the following configuration options:
```text
faraday-mode=remote
remote.faraday.rpcserver=<externally-reachable-ip-address>:8465
remote.faraday.macaroonpath=/some/folder/with/faraday/data/faraday.macaroon
remote.faraday.tlscertpath=/some/folder/with/faraday/data/tls.cert
```
### Connecting LiT to a remote loopd node
To instruct LiT to not start its own integrated `loopd` daemon but instead
connect to an existing node, use the following configuration options:
```text
loop-mode=remote
remote.loop.rpcserver=<externally-reachable-ip-address>:11010
remote.loop.macaroonpath=/some/folder/with/loop/data/loop.macaroon
remote.loop.tlscertpath=/some/folder/with/loop/data/tls.cert
```
### Connecting LiT to a remote poold node
To instruct LiT to not start its own integrated `poold` daemon but instead
connect to an existing node, use the following configuration options:
```text
pool-mode=remote
remote.pool.rpcserver=<externally-reachable-ip-address>:12010
remote.pool.macaroonpath=/some/folder/with/pool/data/pool.macaroon
remote.pool.tlscertpath=/some/folder/with/pool/data/tls.cert
```
## Use command line parameters only
In addition to the LiT specific and remote `lnd` parameters, you must also provide
configuration to the `loop`, `pool`, and `faraday` daemons. For the remote `lnd` node, all
`remote.lnd` flags must be specified. Note that `loopd` and `faraday` will automatically
connect to the same remote `lnd` node, so you do not need to provide them with any
additional parameters unless you want to override them. If you do override them, be sure
to add the `loop.`, `pool.`, and `faraday.` prefixes.
To see all available command line options, run `litd --help`.
The most minimal example command to start `litd` and connect it to a local `lnd`
node that is running with default configuration settings is:
```shell
⛰ litd --uipassword=My$trongP@ssword
```
All other command line flags are only needed to overwrite the default behavior.
Here is an example command to start `litd` connected to a testnet `lnd` that is
running on another host and overwrites a few default settings in `loop`, `pool`,
and `faraday` (optional):
```shell
⛰ litd \
--httpslisten=0.0.0.0:8443 \
--uipassword=My$trongP@ssword \
--letsencrypt \
--letsencrypthost=loop.merchant.com \
--lit-dir=~/.lit \
--network=testnet \
--remote.lit-debuglevel=debug \
--remote.lnd.rpcserver=some-other-host:10009 \
--remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon \
--remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert \
--loop.loopoutmaxparts=5 \
--pool.newnodesonly=true \
--faraday.min_monitored=48h \
--faraday.connect_bitcoin \
--faraday.bitcoin.host=some-other-host \
--faraday.bitcoin.user=testnetuser \
--faraday.bitcoin.password=testnetpw
```
## Use a configuration file
You can also store the configuration in a persistent `~/.lit/lit.conf` file, so you do not
need to type in the command line arguments every time you start the server. Just remember
to use the appropriate prefixes as necessary.
Make sure you don't add any section headers (the lines starting with `[` and ending with
`]`, for example `[Application Options]`) as these don't work with the additional levels
of sub configurations. You can replace them with a comment (starting with the `#`
character) to get the same grouping effect as before.
The most minimal example of a `~/.lit/lit.conf` file that connects to a local `lnd` node
that is running with default configuration settings is:
```text
# Application Options
uipassword=My$trongP@ssword
```
All other configuration settings are only needed to overwrite the default behavior.
Here is an example `~/.lit/lit.conf` file that connects LiT to a testnet `lnd` node
running on another host and overwrites a few default settings in `loop`, `pool`,
and `faraday` (optional):
```text
# Application Options
httpslisten=0.0.0.0:8443
uipassword=My$trongP@ssword
letsencrypt=true
letsencrypthost=loop.merchant.com
lit-dir=~/.lit
network=testnet
# Remote options
remote.lit-debuglevel=debug
# Remote lnd options
remote.lnd.rpcserver=some-other-host:10009
remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon
remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert
# Loop
loop.loopoutmaxparts=5
# Pool
pool.newnodesonly=true
# Faraday
faraday.min_monitored=48h
# Faraday - bitcoin
faraday.connect_bitcoin=true
faraday.bitcoin.host=localhost
faraday.bitcoin.user=testnetuser
faraday.bitcoin.password=testnetpw
```
The default location for the `lit.conf` file will depend on your operating system:
- **On MacOS**: `~/Library/Application Support/Lit/lit.conf`
- **On Linux**: `~/.lit/lit.conf`
- **On Windows**: `~/AppData/Roaming/Lit/lit.conf`
## Example commands for interacting with the command line
Because not all functionality of `lnd` (or `loop`/`faraday` for that matter) is available
through the web UI, it will still be necessary to interact with those daemons through the
command line.
We are going through an example for each of the command line tools and will explain the
reasons for the extra flags. The examples assume that LiT is started with the following
configuration (only relevant parts shown here):
```text
httpslisten=0.0.0.0:8443
lit-dir=~/.lit
network=testnet
remote.lnd.rpcserver=some-other-host:10009
remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon
remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert
```
Because in the remote `lnd` mode all other LiT components (`loop`, `pool`,
`faraday` and the UI server) listen on the same port (`8443` in this example) and
use the same TLS certificate (`~/.lit/tls.cert` in this example), some command
line calls now need some extra options that weren't necessary before.
**NOTE**: All mentioned command line tools have the following behavior in common: You
either specify the `--network` flag and the `--tlscertpath` and `--macaroonpath` are
implied by looking inside the default directories for that network. Or you specify the
`--tlscertpath` and `--macaroonpath` flags explicitly, then you **must not** set the
`--network` flag. Otherwise, you will get an error like
`[lncli] could not load global options: unable to read macaroon path (check the network setting!): open /home/<user>/.lnd/data/chain/bitcoin/testnet/admin.macaroon: no such file or directory`.
### Example `lncli` command
The `lncli` commands in the "remote" mode are the same as if `lnd` was running standalone
on a remote host. We need to specify all flags explicitly.
```shell
⛰ lncli --rpcserver=some-other-host:10009 \
--tlscertpath=/some/folder/with/lnd/data/tls.cert \
--macaroonpath=/some/folder/with/lnd/data/admin.macaroon \
getinfo
```
### Example `loop` command
This is where things get a bit tricky. Because as mentioned above, `loopd` also runs on
the same port as the UI server. That's why we have to both specify the `host:port` as well
as the TLS certificate of LiT. But `loopd` verifies its own macaroon, so we have to
specify that one from the `.loop` directory.
```shell
⛰ loop --rpcserver=localhost:8443 --tlscertpath=~/.lit/tls.cert \
--macaroonpath=~/.loop/testnet/loop.macaroon \
quote out 500000
```
You can easily create an alias for this by adding the following line to your `~/.bashrc`
file:
```shell
⛰ alias lit-loop="loop --rpcserver=localhost:8443 --tlscertpath=~/.lit/tls.cert --macaroonpath=~/.loop/testnet/loop.macaroon"
```
### Example `pool` command
Again, `poold` also runs on the same port as the UI server and we have to
specify the `host:port` and the TLS certificate of LiT but use the macaroon from
the `.pool` directory.
```shell
⛰ pool --rpcserver=localhost:8443 --tlscertpath=~/.lit/tls.cert \
--macaroonpath=~/.pool/testnet/pool.macaroon \
accounts list
```
You can easily create an alias for this by adding the following line to your
`~/.bashrc` file:
```shell
⛰ alias lit-pool="pool --rpcserver=localhost:8443 --tlscertpath=~/.lit/tls.cert --macaroonpath=~/.pool/testnet/pool.macaroon"
```
### Example `frcli` command
Faraday's command line tool follows the same pattern as loop. We also have to specify the
server and TLS flags for `lnd` but use `faraday`'s macaroon:
```shell
⛰ frcli --rpcserver=localhost:8443 --tlscertpath=~/.lit/tls.cert \
--macaroonpath=~/.faraday/testnet/faraday.macaroon \
audit
```
You can easily create an alias for this by adding the following line to your `~/.bashrc`
file:
```shell
⛰ alias lit-frcli="frcli --rpcserver=localhost:8443 --tlscertpath=~/.lit/tls.cert --macaroonpath=~/.faraday/testnet/faraday.macaroon"
```
## Shutting down LiT
In the remote mode, there is no explicit command for stopping LiT yet. But a
clean shutdown can be achieved by either pressing `<Ctrl> + c` in the terminal
where LiT is running. Or, if LiT is running in the background, the following
command can be used to send an interrupt signal which will trigger the clean
shutdown:
```shell
⛰ kill -s INT $(pidof litd)
```