diff --git a/cmd/lncli/wtclient.go b/cmd/lncli/wtclient.go index 5f887fc9..f831403a 100644 --- a/cmd/lncli/wtclient.go +++ b/cmd/lncli/wtclient.go @@ -250,19 +250,44 @@ var policyCommand = cli.Command{ Name: "policy", Usage: "Display the active watchtower client policy configuration.", Action: actionDecorator(policy), + Flags: []cli.Flag{ + cli.BoolFlag{ + Name: "legacy", + Usage: "Retrieve the legacy tower client's current " + + "policy. (default)", + }, + cli.BoolFlag{ + Name: "anchor", + Usage: "Retrieve the anchor tower client's current policy.", + }, + }, } func policy(ctx *cli.Context) error { // Display the command's help message if the number of arguments/flags // is not what we expect. - if ctx.NArg() > 0 || ctx.NumFlags() > 0 { + if ctx.NArg() > 0 || ctx.NumFlags() > 1 { return cli.ShowCommandHelp(ctx, "policy") } + var policyType wtclientrpc.PolicyType + switch { + case ctx.Bool("anchor"): + policyType = wtclientrpc.PolicyType_ANCHOR + case ctx.Bool("legacy"): + policyType = wtclientrpc.PolicyType_LEGACY + + // For backwards compatibility with original rpc behavior. + default: + policyType = wtclientrpc.PolicyType_LEGACY + } + client, cleanUp := getWtclient(ctx) defer cleanUp() - req := &wtclientrpc.PolicyRequest{} + req := &wtclientrpc.PolicyRequest{ + PolicyType: policyType, + } resp, err := client.Policy(context.Background(), req) if err != nil { return err