cmd/lncli: add flags to listchannels to retrieve specific channels

This commit is contained in:
Wilmer Paulino 2018-03-13 15:11:25 -04:00
parent 85b03780f3
commit 7642bad54f
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F

@ -1385,9 +1385,21 @@ var listChannelsCommand = cli.Command{
Usage: "List all open channels", Usage: "List all open channels",
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "active_only, a", Name: "active_only",
Usage: "only list channels which are currently active", Usage: "only list channels which are currently active",
}, },
cli.BoolFlag{
Name: "inactive_only",
Usage: "only list channels which are currently inactive",
},
cli.BoolFlag{
Name: "public_only",
Usage: "only list channels which are currently public",
},
cli.BoolFlag{
Name: "private_only",
Usage: "only list channels which are currently private",
},
}, },
Action: actionDecorator(listChannels), Action: actionDecorator(listChannels),
} }
@ -1397,7 +1409,13 @@ func listChannels(ctx *cli.Context) error {
client, cleanUp := getClient(ctx) client, cleanUp := getClient(ctx)
defer cleanUp() defer cleanUp()
req := &lnrpc.ListChannelsRequest{} req := &lnrpc.ListChannelsRequest{
ActiveOnly: ctx.Bool("active_only"),
InactiveOnly: ctx.Bool("inactive_only"),
PublicOnly: ctx.Bool("public_only"),
PrivateOnly: ctx.Bool("private_only"),
}
resp, err := client.ListChannels(ctxb, req) resp, err := client.ListChannels(ctxb, req)
if err != nil { if err != nil {
return err return err