From 023ac009c0499edd755d8cd44cec3271a3ea6c74 Mon Sep 17 00:00:00 2001 From: Boris Nagaev Date: Fri, 4 Apr 2025 17:45:12 -0300 Subject: [PATCH] cmd/loop: crash if unknown flags are provided Verify the number of positional arguments if they were provided to crash in such scenarios: $ loop out 250000 --xxx $ loop in 250000 1000 These commands used to work ignoring the last argument. --- cmd/loop/liquidity.go | 2 +- cmd/loop/loopin.go | 2 +- cmd/loop/loopout.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/loop/liquidity.go b/cmd/loop/liquidity.go index e3dab6b11..28b64e15b 100644 --- a/cmd/loop/liquidity.go +++ b/cmd/loop/liquidity.go @@ -46,7 +46,7 @@ var setLiquidityRuleCommand = cli.Command{ Name: "setrule", Usage: "set liquidity manager rule for a channel/peer", Description: "Update or remove the liquidity rule for a channel/peer.", - ArgsUsage: "{shortchanid | peerpubkey}", + ArgsUsage: "{shortchanid | peerpubkey}", Flags: []cli.Flag{ cli.StringFlag{ Name: "type", diff --git a/cmd/loop/loopin.go b/cmd/loop/loopin.go index 52e889009..dcbdc168c 100644 --- a/cmd/loop/loopin.go +++ b/cmd/loop/loopin.go @@ -95,7 +95,7 @@ func loopIn(ctx *cli.Context) error { switch { case ctx.IsSet("amt"): amtStr = ctx.String("amt") - case ctx.NArg() > 0: + case ctx.NArg() == 1: amtStr = args[0] default: // Show command help if no arguments and flags were provided. diff --git a/cmd/loop/loopout.go b/cmd/loop/loopout.go index 32cb3f638..76d561170 100644 --- a/cmd/loop/loopout.go +++ b/cmd/loop/loopout.go @@ -131,7 +131,7 @@ func loopOut(ctx *cli.Context) error { switch { case ctx.IsSet("amt"): amtStr = ctx.String("amt") - case ctx.NArg() > 0: + case ctx.NArg() == 1 || ctx.NArg() == 2: amtStr = args[0] args = args.Tail() default: