Skip to content

Commit 0d3bae6

Browse files
committed
loop: add reservation cli commands
1 parent 48dac2c commit 0d3bae6

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

cmd/loop/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func main() {
147147
monitorCommand, quoteCommand, listAuthCommand,
148148
listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand,
149149
setLiquidityRuleCommand, suggestSwapCommand, setParamsCommand,
150-
getInfoCommand, abandonSwapCommand,
150+
getInfoCommand, abandonSwapCommand, reservationsCommands,
151151
}
152152

153153
err := app.Run(os.Args)

cmd/loop/reservations.go

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package main
2+
3+
import (
4+
"context"
5+
6+
"github.com/lightninglabs/loop/looprpc"
7+
"github.com/urfave/cli"
8+
)
9+
10+
var reservationsCommands = cli.Command{
11+
12+
Name: "reservations",
13+
ShortName: "r",
14+
Usage: "manage reservations",
15+
Description: `
16+
With loopd running, you can use this command to manage your
17+
reservations. Reservations are 2-of-2 multisig utxos that
18+
the loop server can open to clients. The reservations are used
19+
to enable instant swaps.
20+
`,
21+
Subcommands: []cli.Command{
22+
listReservationsCommand,
23+
},
24+
}
25+
26+
var (
27+
listReservationsCommand = cli.Command{
28+
Name: "list",
29+
ShortName: "l",
30+
Usage: "list all reservations",
31+
ArgsUsage: "",
32+
Description: `
33+
List all reservations.
34+
`,
35+
Action: listReservations,
36+
}
37+
)
38+
39+
func listReservations(ctx *cli.Context) error {
40+
client, cleanup, err := getClient(ctx)
41+
if err != nil {
42+
return err
43+
}
44+
defer cleanup()
45+
46+
resp, err := client.ListReservations(
47+
context.Background(), &looprpc.ListReservationsRequest{},
48+
)
49+
if err != nil {
50+
return err
51+
}
52+
53+
printRespJSON(resp)
54+
return nil
55+
}

0 commit comments

Comments
 (0)