From 3ce7f72cd490e745eed7c247c3c3a9828f540ef4 Mon Sep 17 00:00:00 2001 From: Oliver Gugger Date: Fri, 4 Sep 2020 09:22:49 +0200 Subject: [PATCH] lncli: add new listpermissions command --- cmd/lncli/cmd_macaroon.go | 23 +++++++++++++++++++++++ cmd/lncli/main.go | 1 + 2 files changed, 24 insertions(+) diff --git a/cmd/lncli/cmd_macaroon.go b/cmd/lncli/cmd_macaroon.go index 86825ff2..da5e2eb7 100644 --- a/cmd/lncli/cmd_macaroon.go +++ b/cmd/lncli/cmd_macaroon.go @@ -282,3 +282,26 @@ func deleteMacaroonID(ctx *cli.Context) error { printRespJSON(resp) return nil } + +var listPermissionsCommand = cli.Command{ + Name: "listpermissions", + Category: "Macaroons", + Usage: "Lists all RPC method URIs and the macaroon permissions they " + + "require to be invoked.", + Action: actionDecorator(listPermissions), +} + +func listPermissions(ctx *cli.Context) error { + client, cleanUp := getClient(ctx) + defer cleanUp() + + request := &lnrpc.ListPermissionsRequest{} + response, err := client.ListPermissions(context.Background(), request) + if err != nil { + return err + } + + printRespJSON(response) + + return nil +} diff --git a/cmd/lncli/main.go b/cmd/lncli/main.go index 79611086..3287450a 100644 --- a/cmd/lncli/main.go +++ b/cmd/lncli/main.go @@ -303,6 +303,7 @@ func main() { bakeMacaroonCommand, listMacaroonIDsCommand, deleteMacaroonIDCommand, + listPermissionsCommand, trackPaymentCommand, versionCommand, }