From 8387092409a279dee6bb45aa0e12b45d10cf236c Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Fri, 3 Mar 2017 13:33:16 -0600 Subject: [PATCH] cmd/lncli: fix bug in openchannel cmd that made --push_amt mandatory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a minor bug that was introduced with the latest PR that made specifying the —push_amt flag when opening a channel mandatory. The fix is simple, turn the switch statement into an if/else, which makes the —push_amt flag optional once again. --- cmd/lncli/commands.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index a1e6e2380..daf69ac8a 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -297,6 +297,7 @@ func openChannel(ctx *cli.Context) error { ctxb := context.Background() client, cleanUp := getClient(ctx) defer cleanUp() + args := ctx.Args() var err error @@ -332,7 +333,7 @@ func openChannel(ctx *cli.Context) error { args = args.Tail() req.NodePubkey = nodePubHex default: - return fmt.Errorf("lightning id argument missing") + return fmt.Errorf("node id argument missing") } switch { @@ -348,16 +349,13 @@ func openChannel(ctx *cli.Context) error { return fmt.Errorf("local amt argument missing") } - switch { - case ctx.IsSet("push_amt"): + if ctx.IsSet("push_amt") { req.PushSat = int64(ctx.Int("push_amt")) - case args.Present(): + } else if args.Present() { req.PushSat, err = strconv.ParseInt(args.First(), 10, 64) if err != nil { return fmt.Errorf("unable to decode push amt: %v", err) } - default: - return fmt.Errorf("push amt argument missing") } stream, err := client.OpenChannel(ctxb, req)