Skip to content

Commit bcf8006

Browse files
committed
cmd/litcli: fix tls cert path
Currently, if in lnd-remote mode, the tls cert path will be constructed to be in the network directory which it should not be.
1 parent 6630f46 commit bcf8006

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

cmd/litcli/main.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,9 @@ func extractPathArgs(ctx *cli.Context) (string, error) {
151151
return "", err
152152
}
153153

154-
// We'll now fetch the basedir so we can make a decision on how to
155-
// properly read the cert. This will either be the default,
156-
// or will have been overwritten by the end user.
157-
baseDir := lncfg.CleanAndExpandPath(ctx.GlobalString(baseDirFlag.Name))
154+
// Get the LND mode. If Lit is in integrated LND mode, then LND's tls
155+
// cert is used directly. Otherwise, Lit's own tls cert is used.
158156
lndmode := strings.ToLower(ctx.GlobalString(lndMode.Name))
159-
160157
if lndmode == terminal.ModeIntegrated {
161158
tlsCertPath := lncfg.CleanAndExpandPath(ctx.GlobalString(
162159
lndTlsCertFlag.Name,
@@ -165,18 +162,25 @@ func extractPathArgs(ctx *cli.Context) (string, error) {
165162
return tlsCertPath, nil
166163
}
167164

165+
// Lit is in remote LND mode. So we need Lit's tls cert.
168166
tlsCertPath := lncfg.CleanAndExpandPath(ctx.GlobalString(
169167
tlsCertFlag.Name,
170168
))
171169

170+
// If a custom TLS path was set, use it as is.
171+
if tlsCertPath != terminal.DefaultTLSCertPath {
172+
return tlsCertPath, nil
173+
}
174+
172175
// If a custom base directory was set, we'll also check if custom paths
173176
// for the TLS cert file was set as well. If not, we'll override the
174177
// paths so they can be found within the custom base directory set.
175178
// This allows us to set a custom base directory, along with custom
176179
// paths to the TLS cert file.
177-
if baseDir != terminal.DefaultLitDir || networkStr != terminal.DefaultNetwork {
180+
baseDir := lncfg.CleanAndExpandPath(ctx.GlobalString(baseDirFlag.Name))
181+
if baseDir != terminal.DefaultLitDir {
178182
tlsCertPath = filepath.Join(
179-
baseDir, networkStr, terminal.DefaultTLSCertFilename,
183+
baseDir, terminal.DefaultTLSCertFilename,
180184
)
181185
}
182186

0 commit comments

Comments
 (0)