github.com/decred/dcrlnd@v0.7.6/cmd/dcrlncli/watchtower_active.go (about) 1 //go:build !no_watchtowerrpc 2 // +build !no_watchtowerrpc 3 4 package main 5 6 import ( 7 "github.com/decred/dcrlnd/lnrpc/watchtowerrpc" 8 "github.com/urfave/cli" 9 ) 10 11 func watchtowerCommands() []cli.Command { 12 return []cli.Command{ 13 { 14 Name: "tower", 15 Usage: "Interact with the watchtower.", 16 Category: "Watchtower", 17 Subcommands: []cli.Command{ 18 towerInfoCommand, 19 }, 20 }, 21 } 22 } 23 24 func getWatchtowerClient(ctx *cli.Context) (watchtowerrpc.WatchtowerClient, func()) { 25 conn := getClientConn(ctx, false) 26 cleanup := func() { 27 conn.Close() 28 } 29 return watchtowerrpc.NewWatchtowerClient(conn), cleanup 30 } 31 32 var towerInfoCommand = cli.Command{ 33 Name: "info", 34 Usage: "Returns basic information related to the active watchtower.", 35 Action: actionDecorator(towerInfo), 36 } 37 38 func towerInfo(ctx *cli.Context) error { 39 ctxc := getContext() 40 if ctx.NArg() != 0 || ctx.NumFlags() > 0 { 41 return cli.ShowCommandHelp(ctx, "info") 42 } 43 44 client, cleanup := getWatchtowerClient(ctx) 45 defer cleanup() 46 47 req := &watchtowerrpc.GetInfoRequest{} 48 resp, err := client.GetInfo(ctxc, req) 49 if err != nil { 50 return err 51 } 52 53 printRespJSON(resp) 54 55 return nil 56 }