From 56ccf6026762d7e8dea55371eb81af68fb6ad4e9 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Tue, 6 May 2025 09:48:20 +0200 Subject: [PATCH 1/5] lncli: correct docs for loadmc --- cmd/commands/cmd_import_mission_control.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cmd/commands/cmd_import_mission_control.go b/cmd/commands/cmd_import_mission_control.go index 8bc69729b..7f0f656f7 100644 --- a/cmd/commands/cmd_import_mission_control.go +++ b/cmd/commands/cmd_import_mission_control.go @@ -106,7 +106,7 @@ var loadMissionControlCommand = cli.Command{ Name: "loadmc", Category: "Mission Control", Usage: "Load mission control results to the internal mission " + - "control state from a file produced by querymc with the " + + "control state from a file produced by `querymc` with the " + "option to shift timestamps. Note that this data is not " + "persisted across restarts.", Action: actionDecorator(loadMissionControl), @@ -122,12 +122,12 @@ var loadMissionControlCommand = cli.Command{ cli.StringFlag{ Name: "timeoffset", Usage: "Time offset to add to all timestamps. " + - "Format: 1m for a minute, 1h for an hour, 1d " + - "for one day. This can be used to let " + - "mission control data appear to be more " + - "recent, to trick pathfinding's in-built " + - "information decay mechanism. Additionally " + - "by setting 0m, this will report the most " + + "Follows a format like 72h3m0.5s. " + + "This can be used to make mission control " + + "data appear more recent, to trick " + + "pathfinding's in-built information decay " + + "mechanism. Additionally, " + + "by setting 0s, this will report the most " + "recent result timestamp, which can be used " + "to find out how old this data is.", }, @@ -222,7 +222,7 @@ func loadMissionControl(ctx *cli.Context) error { } } - fmt.Printf("Adding time offset %v to all timestamps. "+ + fmt.Printf("Added a time offset %v to all timestamps. "+ "New max timestamp: %v\n", offset, maxTimestamp) } From 452022ee75e09f8091688aaaace5898854ae9c53 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Tue, 6 May 2025 09:49:32 +0200 Subject: [PATCH 2/5] 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. --- cmd/commands/cmd_import_mission_control.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmd/commands/cmd_import_mission_control.go b/cmd/commands/cmd_import_mission_control.go index 7f0f656f7..13cffe1ef 100644 --- a/cmd/commands/cmd_import_mission_control.go +++ b/cmd/commands/cmd_import_mission_control.go @@ -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 " + From 725a80a3b75687e178b8a2351e1d4540da494729 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Tue, 6 May 2025 10:17:42 +0200 Subject: [PATCH 3/5] lncli: remove possibility to discard mission control from loadmc This can already be done with resetmc and was only included here because loadmc was used in a different context. --- cmd/commands/cmd_import_mission_control.go | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/cmd/commands/cmd_import_mission_control.go b/cmd/commands/cmd_import_mission_control.go index 13cffe1ef..3159d551f 100644 --- a/cmd/commands/cmd_import_mission_control.go +++ b/cmd/commands/cmd_import_mission_control.go @@ -115,10 +115,6 @@ var loadMissionControlCommand = cli.Command{ Name: "mcdatapath", Usage: "The path to the querymc output file (json).", }, - cli.BoolFlag{ - Name: "discard", - Usage: "Discards current mission control data.", - }, cli.StringFlag{ Name: "timeoffset", Usage: "Time offset to add to all timestamps. " + @@ -171,22 +167,6 @@ func loadMissionControl(ctx *cli.Context) error { client := routerrpc.NewRouterClient(conn) - // We discard mission control data if requested. - if ctx.Bool("discard") { - if !promptForConfirmation("This will discard all current " + - "mission control data in the database (yes/no): ") { - - return nil - } - - _, err = client.ResetMissionControl( - rpcCtx, &routerrpc.ResetMissionControlRequest{}, - ) - if err != nil { - return err - } - } - // Add a time offset to all timestamps if requested. timeOffset := ctx.String("timeoffset") if timeOffset != "" { From d33c92bd19c742870c342f256e71e6e316eed356 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Tue, 6 May 2025 10:18:39 +0200 Subject: [PATCH 4/5] lncli: option to skip prompts for loadmc This makes the command scriptable. --- cmd/commands/cmd_import_mission_control.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/commands/cmd_import_mission_control.go b/cmd/commands/cmd_import_mission_control.go index 3159d551f..1fb63c859 100644 --- a/cmd/commands/cmd_import_mission_control.go +++ b/cmd/commands/cmd_import_mission_control.go @@ -133,6 +133,11 @@ var loadMissionControlCommand = cli.Command{ "results in the database with older results " + "from the file.", }, + cli.BoolFlag{ + Name: "skip_confirmation", + Usage: "Skip the confirmation prompt and import " + + "immediately", + }, }, } @@ -209,7 +214,11 @@ func loadMissionControl(ctx *cli.Context) error { sanitizeMCData(mc.Pairs) fmt.Printf("Mission control file contains %v pairs.\n", len(mc.Pairs)) - if !promptForConfirmation("Import mission control data (yes/no): ") { + if !ctx.Bool("skip_confirmation") && + !promptForConfirmation( + "Import mission control data (yes/no): ", + ) { + return nil } From 306df7048f27d4c7d12b823bf49731c88cdae8f7 Mon Sep 17 00:00:00 2001 From: bitromortac Date: Tue, 6 May 2025 11:16:36 +0200 Subject: [PATCH 5/5] docs: update release notes --- docs/release-notes/release-notes-0.19.0.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release-notes/release-notes-0.19.0.md b/docs/release-notes/release-notes-0.19.0.md index 5893fc11f..2a9f9e325 100644 --- a/docs/release-notes/release-notes-0.19.0.md +++ b/docs/release-notes/release-notes-0.19.0.md @@ -251,7 +251,9 @@ when running LND with an aux component injected (custom channels). specific IPs could be allowed or denied. * A [command was created](https://github.com/lightningnetwork/lnd/pull/9781) to - load mission control data generated by `lncli querymc`. + load mission control data generated by `lncli querymc`. `loadmc` [also + accepts](https://github.com/lightningnetwork/lnd/pull/9783) a flag + `skip_confirmation` to make the command scriptable. # Improvements ## Functional Updates