diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index 20e5e8ab..76922859 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -509,6 +509,34 @@ func pendingChannels(ctx *cli.Context) error { 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{ Name: "sendpayment", Description: "send a payment over lightning", diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index 1e8c3fe5..5a6a855a 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -65,6 +65,7 @@ func main() { LookupInvoiceCommand, ListInvoicesCommand, ShowRoutingTableCommand, + ListChannelsCommand, } if err := app.Run(os.Args); err != nil {