cmd: add fetchl402 cli command

This commit adds a new command to the loop cli tool that fetches the
a l402 token from the swap server.
This commit is contained in:
sputn1ck 2024-10-30 14:26:29 +01:00
parent 830220af66
commit 7ca5dc81bc
No known key found for this signature in database
GPG key ID: 671103D881A5F0E4
2 changed files with 29 additions and 1 deletions

View file

@ -73,3 +73,31 @@ func listAuth(ctx *cli.Context) error {
printJSON(tokens)
return nil
}
var fetchL402Command = cli.Command{
Name: "fetchl402",
Usage: "fetches a new L402 authentication token from the server",
Description: "Fetches a new L402 authentication token from the server. " +
"This token is required to listen to notifications from the server, " +
"such as reservation notifications. If a L402 is already present in " +
"the store, this command is a no-op.",
Action: fetchL402,
}
func fetchL402(ctx *cli.Context) error {
client, cleanup, err := getClient(ctx)
if err != nil {
return err
}
defer cleanup()
res, err := client.FetchL402Token(
context.Background(), &looprpc.FetchL402TokenRequest{},
)
if err != nil {
return err
}
printRespJSON(res)
return nil
}

View file

@ -144,7 +144,7 @@ func main() {
}
app.Commands = []cli.Command{
loopOutCommand, loopInCommand, termsCommand,
monitorCommand, quoteCommand, listAuthCommand,
monitorCommand, quoteCommand, listAuthCommand, fetchL402Command,
listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand,
setLiquidityRuleCommand, suggestSwapCommand, setParamsCommand,
getInfoCommand, abandonSwapCommand, reservationsCommands,