config: fix empty default remote lnd admin mac path

Partially reverts c917e91f and fixes #195: The default remote lnd admin
macaroon path we added in c917e91f was a mistake since by default that
value isn't set until we call lnd.ValidateConfig() which we never do in
the remote mode.
We fix this by providing a sane default value for the admin macaroon
again.
This commit is contained in:
Oliver Gugger 2021-03-04 15:21:44 +01:00
parent 1724184744
commit cbe71ac19a
No known key found for this signature in database
GPG key ID: 8E4256593F177720

View file

@ -65,6 +65,7 @@ const (
defaultRemotePoolRpcServer = "localhost:12010"
defaultLndChainSubDir = "chain"
defaultLndChain = "bitcoin"
defaultLndMacaroon = "admin.macaroon"
)
var (
@ -104,6 +105,13 @@ var (
defaultLetsEncryptDir = filepath.Join(
defaultLitDir, defaultLetsEncryptSubDir,
)
// defaultRemoteLndMacaroonPath is the default path we assume for a
// local lnd node to store its admin.macaroon file at.
defaultRemoteLndMacaroonPath = filepath.Join(
lndDefaultConfig.DataDir, defaultLndChainSubDir,
defaultLndChain, defaultNetwork, defaultLndMacaroon,
)
)
// Config is the main configuration struct of lightning-terminal. It contains
@ -248,7 +256,7 @@ func defaultConfig() *Config {
LitMaxLogFileSize: defaultMaxLogFileSize,
Lnd: &RemoteDaemonConfig{
RPCServer: defaultRemoteLndRpcServer,
MacaroonPath: lndDefaultConfig.AdminMacPath,
MacaroonPath: defaultRemoteLndMacaroonPath,
TLSCertPath: lndDefaultConfig.TLSCertPath,
},
Faraday: &RemoteDaemonConfig{
@ -526,7 +534,7 @@ func validateRemoteModeConfig(cfg *Config) error {
// specify --network=testnet for example if everything else is using
// the defaults.
if cfg.Network != defaultNetwork &&
r.Lnd.MacaroonPath == defaultLndCfg.AdminMacPath {
r.Lnd.MacaroonPath == defaultRemoteLndMacaroonPath {
r.Lnd.MacaroonPath = filepath.Join(
defaultLndCfg.DataDir, defaultLndChainSubDir,