cmd/lncli: fix bug in openchannel cmd that made --push_amt mandatory

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.
This commit is contained in:
Olaoluwa Osuntokun 2017-03-03 13:33:16 -06:00
parent 355c88f5a4
commit 8387092409
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2

@ -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)