Skip to content

Commit 2380c01

Browse files
authored
Merge pull request #172 from lightninglabs/lnd-12
Add lnd v0.12.0-beta compatibility, allow single macaroon
2 parents ac48994 + d01636a commit 2380c01

File tree

12 files changed

+2337
-69
lines changed

12 files changed

+2337
-69
lines changed

app/src/types/generated/lnd_pb.d.ts

Lines changed: 239 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/types/generated/lnd_pb.js

Lines changed: 1697 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/types/generated/lnd_pb_service.d.ts

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/types/generated/lnd_pb_service.js

Lines changed: 80 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/util/tests/sampleData.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ export const lndChannel: LND.Channel.AsObject = {
9797
amount: 498730,
9898
hashLock: 'pl8fmsyoSqEQFQCw6Zu9e1aIlFnMz5H+hW2mmh3kRlI=',
9999
expirationHeight: 285,
100+
htlcIndex: 0,
101+
forwardingChannel: 124244814004224,
102+
forwardingHtlcIndex: 0,
100103
},
101104
],
102105
csvDelay: 1802,

config.go

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"net"
99
"net/http"
1010
"os"
11+
"path"
1112
"path/filepath"
1213
"strings"
1314

@@ -171,7 +172,14 @@ type RemoteDaemonConfig struct {
171172

172173
// MacaroonDir is the directory that contains all the macaroon files
173174
// required for the remote connection.
174-
MacaroonDir string `long:"macaroondir" description:"The directory containing all lnd macaroons to use for the remote connection."`
175+
MacaroonDir string `long:"macaroondir" description:"DEPRECATED: Use macaroonpath. The directory containing all lnd macaroons to use for the remote connection."`
176+
177+
// MacaroonPath is the path to the single macaroon that should be used
178+
// instead of needing to specify the macaroon directory that contains
179+
// all of lnd's macaroons. The specified macaroon MUST have all
180+
// permissions that all the subservers use, otherwise permission errors
181+
// will occur.
182+
MacaroonPath string `long:"macaroonpath" description:"The full path to the single macaroon to use, either the admin.macaroon or a custom baked one. Cannot be specified at the same time as macaroondir. A custom macaroon must contain ALL permissions required for all subservers to work, otherwise permission errors will occur."`
175183

176184
// TLSCertPath is the path to the tls cert of the remote daemon that
177185
// should be used to verify the TLS identity of the remote RPC server.
@@ -186,10 +194,24 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string, string,
186194
// In remote lnd mode, we just pass along what was configured in the
187195
// remote section of the lnd config.
188196
if c.LndMode == ModeRemote {
197+
// Because we now have the option to specify a single, custom
198+
// macaroon to the lndclient, we either use the single macaroon
199+
// indicated by the user or the admin macaroon from the mac dir
200+
// that was specified.
201+
macPath := path.Join(
202+
lncfg.CleanAndExpandPath(c.Remote.Lnd.MacaroonDir),
203+
defaultLndMacaroon,
204+
)
205+
if c.Remote.Lnd.MacaroonPath != "" {
206+
macPath = lncfg.CleanAndExpandPath(
207+
c.Remote.Lnd.MacaroonPath,
208+
)
209+
}
210+
189211
return c.Remote.Lnd.RPCServer,
190212
lndclient.Network(c.network),
191213
lncfg.CleanAndExpandPath(c.Remote.Lnd.TLSCertPath),
192-
lncfg.CleanAndExpandPath(c.Remote.Lnd.MacaroonDir), nil
214+
macPath, nil
193215
}
194216

195217
// When we start lnd internally, we take the listen address as
@@ -211,7 +233,7 @@ func (c *Config) lndConnectParams() (string, lndclient.Network, string, string,
211233
}
212234

213235
return lndDialAddr, lndclient.Network(c.network),
214-
c.Lnd.TLSCertPath, filepath.Dir(c.Lnd.AdminMacPath), nil
236+
c.Lnd.TLSCertPath, c.Lnd.AdminMacPath, nil
215237
}
216238

217239
// defaultConfig returns a configuration struct with all default values set.
@@ -442,6 +464,15 @@ func validateRemoteModeConfig(cfg *Config) error {
442464
}
443465
cfg.network = r.Lnd.Network
444466

467+
// Users can either specify the macaroon directory or the custom
468+
// macaroon to use, but not both.
469+
if r.Lnd.MacaroonDir != defaultRemoteLndMacDir &&
470+
r.Lnd.MacaroonPath != "" {
471+
472+
return fmt.Errorf("cannot set both macaroon dir and macaroon " +
473+
"path")
474+
}
475+
445476
// If the remote lnd's network isn't the default, we also check if we
446477
// need to adjust the default macaroon directory so the user can only
447478
// specify --network=testnet for example if everything else is using

doc/config-lnd-remote.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,9 @@ directory on your remote machine to `/some/folder/with/lnd/data/` on your local
1919

2020
- tls.cert
2121
- admin.macaroon
22-
- chainnotifier.macaroon
23-
- invoices.macaroon
24-
- readonly.macaroon
25-
- router.macaroon
26-
- signer.macaroon
27-
- walletkit.macaroon
22+
23+
(Note that with LiT prior to `v0.3.5-alpha` all `*.macaroon` files need to be
24+
copied from the lnd machine.)
2825

2926
Create a `lit.conf` file. The default location LiT will look for the configuration file
3027
depends on your operating system:
@@ -38,7 +35,7 @@ creating `lit.conf` populate it with the following configuration settings:
3835

3936
```text
4037
remote.lnd.rpcserver=<externally-reachable-ip-address>:10009
41-
remote.lnd.macaroondir=/some/folder/with/lnd/data
38+
remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon
4239
remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert
4340
```
4441

@@ -95,7 +92,7 @@ and `faraday` (optional):
9592
--remote.lit-debuglevel=debug \
9693
--remote.lnd.network=testnet \
9794
--remote.lnd.rpcserver=some-other-host:10009 \
98-
--remote.lnd.macaroondir=/some/folder/with/lnd/data \
95+
--remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon \
9996
--remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert \
10097
--loop.loopoutmaxparts=5 \
10198
--pool.newnodesonly=true \
@@ -106,12 +103,6 @@ and `faraday` (optional):
106103
--faraday.bitcoin.password=testnetpw
107104
```
108105

109-
NOTE: Even though LiT itself only needs `lnd`'s `admin.macaroon`, the `loop`,
110-
`pool`, and `faraday` daemons will require other macaroons and will look for
111-
them in the folder specified with `--remote.lnd.macaroondir`. It is advised to
112-
copy all `*.macaroon` files and the `tls.cert` file from the remote host to the
113-
host that is running `litd`.
114-
115106
## Use a configuration file
116107

117108
You can also store the configuration in a persistent `~/.lit/lit.conf` file, so you do not
@@ -151,7 +142,7 @@ remote.lit-debuglevel=debug
151142
# Remote lnd options
152143
remote.lnd.network=testnet
153144
remote.lnd.rpcserver=some-other-host:10009
154-
remote.lnd.macaroondir=/some/folder/with/lnd/data
145+
remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon
155146
remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert
156147
157148
# Loop
@@ -192,7 +183,7 @@ lit-dir=~/.lit
192183
193184
remote.lnd.network=testnet
194185
remote.lnd.rpcserver=some-other-host:10009
195-
remote.lnd.macaroondir=/some/folder/with/lnd/data
186+
remote.lnd.macaroonpath=/some/folder/with/lnd/data/admin.macaroon
196187
remote.lnd.tlscertpath=/some/folder/with/lnd/data/tls.cert
197188
```
198189

go.mod

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ require (
77
github.com/grpc-ecosystem/grpc-gateway v1.14.6
88
github.com/improbable-eng/grpc-web v0.12.0
99
github.com/jessevdk/go-flags v1.4.0
10-
github.com/lightninglabs/aperture v0.1.3-beta
11-
github.com/lightninglabs/faraday v0.2.2-alpha
12-
github.com/lightninglabs/lndclient v0.11.0-3
13-
github.com/lightninglabs/loop v0.11.2-beta
14-
github.com/lightninglabs/pool v0.3.4-alpha
15-
github.com/lightningnetwork/lnd v0.11.1-beta
10+
github.com/lightninglabs/aperture v0.1.5-beta
11+
github.com/lightninglabs/faraday v0.2.3-alpha
12+
github.com/lightninglabs/lndclient v0.11.0-5
13+
github.com/lightninglabs/loop v0.11.2-beta.0.20210114072419-d85cc010b0d4
14+
github.com/lightninglabs/pool v0.4.2-alpha.0.20210125123142-33fcaed7a613
15+
github.com/lightningnetwork/lnd v0.12.0-beta.rc5
1616
github.com/lightningnetwork/lnd/cert v1.0.3
1717
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
1818
github.com/mwitkow/grpc-proxy v0.0.0-20181017164139-0f1106ef9c76

0 commit comments

Comments
 (0)