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
@@ -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(
@@ -172,11 +180,7 @@ func DefaultConfig() Config {
LoopOutMaxParts: defaultLoopOutMaxParts,
Lnd: &lndConfig{
Host: "localhost:10009",
- MacaroonPath: filepath.Join(
- btcutil.AppDataDir("lnd", false),
- "data", "chain", "bitcoin", DefaultNetwork,
- "admin.macaroon",
- ),
+ 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
