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

View File

@@ -297,6 +297,7 @@ func openChannel(ctx *cli.Context) error {
ctxb := context.Background() ctxb := context.Background()
client, cleanUp := getClient(ctx) client, cleanUp := getClient(ctx)
defer cleanUp() defer cleanUp()
args := ctx.Args() args := ctx.Args()
var err error var err error
@@ -332,7 +333,7 @@ func openChannel(ctx *cli.Context) error {
args = args.Tail() args = args.Tail()
req.NodePubkey = nodePubHex req.NodePubkey = nodePubHex
default: default:
return fmt.Errorf("lightning id argument missing") return fmt.Errorf("node id argument missing")
} }
switch { switch {
@@ -348,16 +349,13 @@ func openChannel(ctx *cli.Context) error {
return fmt.Errorf("local amt argument missing") return fmt.Errorf("local amt argument missing")
} }
switch { if ctx.IsSet("push_amt") {
case ctx.IsSet("push_amt"):
req.PushSat = int64(ctx.Int("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) req.PushSat, err = strconv.ParseInt(args.First(), 10, 64)
if err != nil { if err != nil {
return fmt.Errorf("unable to decode push amt: %v", err) return fmt.Errorf("unable to decode push amt: %v", err)
} }
default:
return fmt.Errorf("push amt argument missing")
} }
stream, err := client.OpenChannel(ctxb, req) stream, err := client.OpenChannel(ctxb, req)