Skip to content

Commit 92ae54d

Browse files
committed
cmd/lncli: add confirmation promt to closeallchannels
To make sure users don't accidentally close all channels, we ask before running this potentially very destructive command.
1 parent 5f89a8b commit 92ae54d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

cmd/lncli/commands.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -994,6 +994,11 @@ var closeAllChannelsCommand = cli.Command{
994994
"sat/vbyte that should be used when crafting " +
995995
"the closing transactions",
996996
},
997+
cli.BoolFlag{
998+
Name: "s, skip_confirmation",
999+
Usage: "Skip the confirmation prompt and close all " +
1000+
"channels immediately",
1001+
},
9971002
},
9981003
Action: actionDecorator(closeAllChannels),
9991004
}
@@ -1012,6 +1017,11 @@ func closeAllChannels(ctx *cli.Context) error {
10121017
return err
10131018
}
10141019

1020+
prompt := "Do you really want to close ALL channels? (yes/no): "
1021+
if !ctx.Bool("skip_confirmation") && !promptForConfirmation(prompt) {
1022+
return errors.New("action aborted by user")
1023+
}
1024+
10151025
listReq := &lnrpc.ListChannelsRequest{}
10161026
openChannels, err := client.ListChannels(ctxc, listReq)
10171027
if err != nil {

0 commit comments

Comments
 (0)