cmd/lncli: implement pendingchannels for the cli client

This commit is contained in:
Olaoluwa Osuntokun 2016-07-07 15:35:58 -07:00
parent a4e92fac8e
commit 40d9f0da31
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 50 additions and 0 deletions

@ -388,3 +388,52 @@ func getInfo(ctx *cli.Context) error {
printRespJson(resp)
return nil
}
var PendingChannelsCommand = cli.Command{
Name: "pendingchannels",
Description: "display information pertaining to pending channels",
Usage: "pendingchannels --status=[all|opening|closing]",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "open, o",
Usage: "display the status of new pending channels",
},
cli.BoolFlag{
Name: "close, c",
Usage: "display the status of channels being closed",
},
cli.BoolFlag{
Name: "all, a",
Usage: "display the status of channels in the " +
"process of being opened or closed",
},
},
Action: pendingChannels,
}
func pendingChannels(ctx *cli.Context) error {
ctxb := context.Background()
client := getClient(ctx)
var channelStatus lnrpc.ChannelStatus
switch {
case ctx.Bool("all"):
channelStatus = lnrpc.ChannelStatus_ALL
case ctx.Bool("open"):
channelStatus = lnrpc.ChannelStatus_OPENING
case ctx.Bool("close"):
channelStatus = lnrpc.ChannelStatus_CLOSING
default:
channelStatus = lnrpc.ChannelStatus_ALL
}
req := &lnrpc.PendingChannelRequest{channelStatus}
resp, err := client.PendingChannels(ctxb, req)
if err != nil {
return err
}
printRespJson(resp)
return nil
}

@ -58,6 +58,7 @@ func main() {
WalletBalanceCommand,
ShellCommand,
GetInfoCommand,
PendingChannelsCommand,
}
if err := app.Run(os.Args); err != nil {