From 84bf30301f4a74a89e3df5de72ffd342e1b0cbc1 Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Wed, 24 May 2023 12:40:25 +0200 Subject: [PATCH] loop: client calls getInfo rpc --- cmd/loop/info.go | 36 ++++++++++++++++++++++++++++++++++++ cmd/loop/main.go | 1 + 2 files changed, 37 insertions(+) create mode 100644 cmd/loop/info.go diff --git a/cmd/loop/info.go b/cmd/loop/info.go new file mode 100644 index 0000000..1fbdae2 --- /dev/null +++ b/cmd/loop/info.go @@ -0,0 +1,36 @@ +package main + +import ( + "context" + + "github.com/lightninglabs/loop/looprpc" + "github.com/urfave/cli" +) + +var getInfoCommand = cli.Command{ + Name: "getinfo", + Usage: "show general information about the loop daemon", + Description: "Displays general information about the daemon like " + + "current version, connection parameters and basic swap " + + "information.", + Action: getInfo, +} + +func getInfo(ctx *cli.Context) error { + client, cleanup, err := getClient(ctx) + if err != nil { + return err + } + defer cleanup() + + cfg, err := client.GetInfo( + context.Background(), &looprpc.GetInfoRequest{}, + ) + if err != nil { + return err + } + + printRespJSON(cfg) + + return nil +} diff --git a/cmd/loop/main.go b/cmd/loop/main.go index 3fa2b30..73320f7 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -153,6 +153,7 @@ func main() { monitorCommand, quoteCommand, listAuthCommand, listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand, setLiquidityRuleCommand, suggestSwapCommand, setParamsCommand, + getInfoCommand, } err := app.Run(os.Args)