lncli: establish connection after mc parsing for loadmc

It can take some time to unmarshal large mission control data sets such
that the macaroon can expire during that phase. We postpone the
connection establishment to give the user more time to answer the
prompt.
This commit is contained in:
bitromortac
2025-05-06 09:49:32 +02:00
parent 56ccf60267
commit 452022ee75

View File

@@ -153,11 +153,6 @@ func loadMissionControl(ctx *cli.Context) error {
return fmt.Errorf("%v does not exist", mcDataPath)
}
conn := getClientConn(ctx, false)
defer conn.Close()
client := routerrpc.NewRouterClient(conn)
// Load and unmarshal the querymc output file.
mcRaw, err := os.ReadFile(mcDataPath)
if err != nil {
@@ -171,6 +166,11 @@ func loadMissionControl(ctx *cli.Context) error {
err)
}
conn := getClientConn(ctx, false)
defer conn.Close()
client := routerrpc.NewRouterClient(conn)
// We discard mission control data if requested.
if ctx.Bool("discard") {
if !promptForConfirmation("This will discard all current " +