From 3c495a2a5c0323a6d9485ec6a320f18d4369dd47 Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Mon, 11 May 2026 16:04:23 +0200 Subject: [PATCH] cmd/loop: require explicit 'y' confirmation on reservation new The reservation new command printed the prepay cost and asked the user to confirm with 'y/n'. The implementation read the answer with fmt.Scanln(&answer) and treated only the literal 'n' as a 'no'. The return value was discarded, so: - On EOF / closed stdin (CI pipelines, automated wrappers, terminal disconnect) Scanln returned an error and answer remained the empty string, which is not 'n', so the command proceeded and paid the LN prepayment with no user confirmation. - The case-sensitive 'n' check also accepted 'N', 'no', 'yes', 'Y', or any other string as a 'yes'. Match the convention used by the rest of the loop CLI: only continue when the user typed exactly 'y' (or 'Y'), and treat any read error as 'no'. --- cmd/loop/reservations.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/loop/reservations.go b/cmd/loop/reservations.go index 196610f7..12563ac3 100644 --- a/cmd/loop/reservations.go +++ b/cmd/loop/reservations.go @@ -4,6 +4,7 @@ import ( "context" "errors" "fmt" + "strings" "github.com/lightninglabs/loop/looprpc" "github.com/urfave/cli/v3" @@ -97,8 +98,9 @@ func newReservation(ctx context.Context, cmd *cli.Command) error { fmt.Printf("CONTINUE RESERVATION? (y/n): ") var answer string - fmt.Scanln(&answer) - if answer == "n" { + if _, err := fmt.Scanln(&answer); err != nil || + !strings.EqualFold(answer, "y") { + return nil }