cmd/lncli: implementing parsing+display for list channels

This commit is contained in:
Olaoluwa Osuntokun 2016-09-25 20:04:58 -07:00
parent 7a6905d697
commit 301a9fea38
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 29 additions and 0 deletions

@ -509,6 +509,34 @@ func pendingChannels(ctx *cli.Context) error {
return nil return nil
} }
var ListChannelsCommand = cli.Command{
Name: "listchannels",
Description: "list all open channels",
Usage: "listchannels --active_only",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "active_only, a",
Usage: "only list channels which are currently active",
},
},
Action: listChannels,
}
func listChannels(ctx *cli.Context) error {
ctxb := context.Background()
client := getClient(ctx)
req := &lnrpc.ListChannelsRequest{}
resp, err := client.ListChannels(ctxb, req)
if err != nil {
return err
}
printRespJson(resp)
return nil
}
var SendPaymentCommand = cli.Command{ var SendPaymentCommand = cli.Command{
Name: "sendpayment", Name: "sendpayment",
Description: "send a payment over lightning", Description: "send a payment over lightning",

@ -65,6 +65,7 @@ func main() {
LookupInvoiceCommand, LookupInvoiceCommand,
ListInvoicesCommand, ListInvoicesCommand,
ShowRoutingTableCommand, ShowRoutingTableCommand,
ListChannelsCommand,
} }
if err := app.Run(os.Args); err != nil { if err := app.Run(os.Args); err != nil {