From 3fb75131ea1a7b8c0478169e67f9d4267fa4f391 Mon Sep 17 00:00:00 2001 From: Harsha Goli Date: Tue, 16 Nov 2021 12:05:40 -0500 Subject: [PATCH 1/2] loopd: Consider network when making LND paths In this commit we consider the passed network options when assuming the LND macaroon path if not passed by user --- loopd/config.go | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/loopd/config.go b/loopd/config.go index d7f7482..a528e30 100644 --- a/loopd/config.go +++ b/loopd/config.go @@ -51,6 +51,14 @@ var ( // deprecated --lnd.macaroondir config option is used. defaultLndMacaroon = "admin.macaroon" + // DefaultLndMacaroonPath is the default mainnet admin macaroon path of + // LND. + DefaultLndMacaroonPath = filepath.Join( + btcutil.AppDataDir("lnd", false), + "data", "chain", "bitcoin", DefaultNetwork, + defaultLndMacaroon, + ) + // DefaultTLSCertPath is the default full path of the autogenerated TLS // certificate. DefaultTLSCertPath = filepath.Join( @@ -171,12 +179,8 @@ func DefaultConfig() Config { MaxLSATFee: lsat.DefaultMaxRoutingFeeSats, LoopOutMaxParts: defaultLoopOutMaxParts, Lnd: &lndConfig{ - Host: "localhost:10009", - MacaroonPath: filepath.Join( - btcutil.AppDataDir("lnd", false), - "data", "chain", "bitcoin", DefaultNetwork, - "admin.macaroon", - ), + Host: "localhost:10009", + MacaroonPath: DefaultLndMacaroonPath, }, } } @@ -252,6 +256,16 @@ func Validate(cfg *Config) error { ) } + // If the user doesn't specify Lnd.MacaroonPath, we'll reassemble it + // with the passed Network options. + if cfg.Lnd.MacaroonPath == DefaultLndMacaroonPath { + cfg.Lnd.MacaroonPath = filepath.Join( + btcutil.AppDataDir("lnd", false), + "data", "chain", "bitcoin", cfg.Network, + defaultLndMacaroon, + ) + } + // If either of these directories do not exist, create them. if err := os.MkdirAll(cfg.DataDir, os.ModePerm); err != nil { return err From bf84aef4be9fceb7664a92fd239bd89b90f41ef5 Mon Sep 17 00:00:00 2001 From: Harsha Goli Date: Mon, 6 Dec 2021 13:39:33 -0500 Subject: [PATCH 2/2] release_notes: add release notes for bugfix --- release_notes.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/release_notes.md b/release_notes.md index c71d135..e818b1f 100644 --- a/release_notes.md +++ b/release_notes.md @@ -20,4 +20,6 @@ This file tracks release notes for the loop client. #### Bug Fixes +* Fixed issue where loop assumes the mainnet location for lnd.macaroonpath regardless of passed network parameters. + #### Maintenance