Skip to content

Commit 52087c8

Browse files
authored
Merge pull request #434 from arshbot/default-macaroon-locations
loopd: Consider network when making LND paths
2 parents b7ba193 + bf84aef commit 52087c8

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

loopd/config.go

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ var (
5151
// deprecated --lnd.macaroondir config option is used.
5252
defaultLndMacaroon = "admin.macaroon"
5353

54+
// DefaultLndMacaroonPath is the default mainnet admin macaroon path of
55+
// LND.
56+
DefaultLndMacaroonPath = filepath.Join(
57+
btcutil.AppDataDir("lnd", false),
58+
"data", "chain", "bitcoin", DefaultNetwork,
59+
defaultLndMacaroon,
60+
)
61+
5462
// DefaultTLSCertPath is the default full path of the autogenerated TLS
5563
// certificate.
5664
DefaultTLSCertPath = filepath.Join(
@@ -171,12 +179,8 @@ func DefaultConfig() Config {
171179
MaxLSATFee: lsat.DefaultMaxRoutingFeeSats,
172180
LoopOutMaxParts: defaultLoopOutMaxParts,
173181
Lnd: &lndConfig{
174-
Host: "localhost:10009",
175-
MacaroonPath: filepath.Join(
176-
btcutil.AppDataDir("lnd", false),
177-
"data", "chain", "bitcoin", DefaultNetwork,
178-
"admin.macaroon",
179-
),
182+
Host: "localhost:10009",
183+
MacaroonPath: DefaultLndMacaroonPath,
180184
},
181185
}
182186
}
@@ -252,6 +256,16 @@ func Validate(cfg *Config) error {
252256
)
253257
}
254258

259+
// If the user doesn't specify Lnd.MacaroonPath, we'll reassemble it
260+
// with the passed Network options.
261+
if cfg.Lnd.MacaroonPath == DefaultLndMacaroonPath {
262+
cfg.Lnd.MacaroonPath = filepath.Join(
263+
btcutil.AppDataDir("lnd", false),
264+
"data", "chain", "bitcoin", cfg.Network,
265+
defaultLndMacaroon,
266+
)
267+
}
268+
255269
// If either of these directories do not exist, create them.
256270
if err := os.MkdirAll(cfg.DataDir, os.ModePerm); err != nil {
257271
return err

release_notes.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@ This file tracks release notes for the loop client.
2929

3030
#### Bug Fixes
3131

32+
* Fixed issue where loop assumes the mainnet location for lnd.macaroonpath regardless of passed network parameters.
33+
3234
#### Maintenance

0 commit comments

Comments
 (0)