Skip to content

Commit fee6f9c

Browse files
committed
cmd/loop: urfave/cli -> urfave/cli/v3
1 parent 2b3876e commit fee6f9c

File tree

17 files changed

+535
-538
lines changed

17 files changed

+535
-538
lines changed

cmd/loop/debug.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ import (
77
"context"
88

99
"github.com/lightninglabs/loop/looprpc"
10-
"github.com/urfave/cli"
10+
"github.com/urfave/cli/v3"
1111
)
1212

1313
func init() {
1414
// Register the debug command.
1515
commands = append(commands, forceAutoloopCmd)
1616
}
1717

18-
var forceAutoloopCmd = cli.Command{
18+
var forceAutoloopCmd = &cli.Command{
1919
Name: "forceautoloop",
2020
Usage: `
2121
Forces to trigger an autoloop step, regardless of the current internal
@@ -25,16 +25,14 @@ var forceAutoloopCmd = cli.Command{
2525
Hidden: true,
2626
}
2727

28-
func forceAutoloop(ctx *cli.Context) error {
29-
client, cleanup, err := getDebugClient(ctx)
28+
func forceAutoloop(ctx context.Context, cmd *cli.Command) error {
29+
client, cleanup, err := getDebugClient(ctx, cmd)
3030
if err != nil {
3131
return err
3232
}
3333
defer cleanup()
3434

35-
cfg, err := client.ForceAutoLoop(
36-
context.Background(), &looprpc.ForceAutoLoopRequest{},
37-
)
35+
cfg, err := client.ForceAutoLoop(ctx, &looprpc.ForceAutoLoopRequest{})
3836
if err != nil {
3937
return err
4038
}
@@ -44,13 +42,13 @@ func forceAutoloop(ctx *cli.Context) error {
4442
return nil
4543
}
4644

47-
func getDebugClient(ctx *cli.Context) (looprpc.DebugClient, func(), error) {
48-
rpcServer := ctx.GlobalString("rpcserver")
49-
tlsCertPath, macaroonPath, err := extractPathArgs(ctx)
45+
func getDebugClient(ctx context.Context, cmd *cli.Command) (looprpc.DebugClient, func(), error) {
46+
rpcServer := cmd.String("rpcserver")
47+
tlsCertPath, macaroonPath, err := extractPathArgs(cmd)
5048
if err != nil {
5149
return nil, nil, err
5250
}
53-
conn, err := getClientConn(rpcServer, tlsCertPath, macaroonPath)
51+
conn, err := getClientConn(ctx, rpcServer, tlsCertPath, macaroonPath)
5452
if err != nil {
5553
return nil, nil, err
5654
}

cmd/loop/info.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import (
44
"context"
55

66
"github.com/lightninglabs/loop/looprpc"
7-
"github.com/urfave/cli"
7+
"github.com/urfave/cli/v3"
88
)
99

10-
var getInfoCommand = cli.Command{
10+
var getInfoCommand = &cli.Command{
1111
Name: "getinfo",
1212
Usage: "show general information about the loop daemon",
1313
Description: "Displays general information about the daemon like " +
@@ -16,16 +16,14 @@ var getInfoCommand = cli.Command{
1616
Action: getInfo,
1717
}
1818

19-
func getInfo(ctx *cli.Context) error {
20-
client, cleanup, err := getClient(ctx)
19+
func getInfo(ctx context.Context, cmd *cli.Command) error {
20+
client, cleanup, err := getClient(ctx, cmd)
2121
if err != nil {
2222
return err
2323
}
2424
defer cleanup()
2525

26-
cfg, err := client.GetInfo(
27-
context.Background(), &looprpc.GetInfoRequest{},
28-
)
26+
cfg, err := client.GetInfo(ctx, &looprpc.GetInfoRequest{})
2927
if err != nil {
3028
return err
3129
}

cmd/loop/instantout.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,23 @@ import (
99

1010
"github.com/lightninglabs/loop/instantout/reservation"
1111
"github.com/lightninglabs/loop/looprpc"
12-
"github.com/urfave/cli"
12+
"github.com/urfave/cli/v3"
1313
)
1414

15-
var instantOutCommand = cli.Command{
15+
var instantOutCommand = &cli.Command{
1616
Name: "instantout",
1717
Usage: "perform an instant off-chain to on-chain swap (looping out)",
1818
Description: `
1919
Attempts to instantly loop out into the backing lnd's wallet. The amount
2020
will be chosen via the cli.
2121
`,
2222
Flags: []cli.Flag{
23-
cli.StringFlag{
23+
&cli.StringFlag{
2424
Name: "channel",
2525
Usage: "the comma-separated list of short " +
2626
"channel IDs of the channels to loop out",
2727
},
28-
cli.StringFlag{
28+
&cli.StringFlag{
2929
Name: "addr",
3030
Usage: "the optional address that the looped out funds " +
3131
"should be sent to, if let blank the funds " +
@@ -35,13 +35,13 @@ var instantOutCommand = cli.Command{
3535
Action: instantOut,
3636
}
3737

38-
func instantOut(ctx *cli.Context) error {
38+
func instantOut(ctx context.Context, cmd *cli.Command) error {
3939
// Parse outgoing channel set. Don't string split if the flag is empty.
4040
// Otherwise, strings.Split returns a slice of length one with an empty
4141
// element.
4242
var outgoingChanSet []uint64
43-
if ctx.IsSet("channel") {
44-
chanStrings := strings.Split(ctx.String("channel"), ",")
43+
if cmd.IsSet("channel") {
44+
chanStrings := strings.Split(cmd.String("channel"), ",")
4545
for _, chanString := range chanStrings {
4646
chanID, err := strconv.ParseUint(chanString, 10, 64)
4747
if err != nil {
@@ -53,15 +53,15 @@ func instantOut(ctx *cli.Context) error {
5353
}
5454

5555
// First set up the swap client itself.
56-
client, cleanup, err := getClient(ctx)
56+
client, cleanup, err := getClient(ctx, cmd)
5757
if err != nil {
5858
return err
5959
}
6060
defer cleanup()
6161

6262
// Now we fetch all the confirmed reservations.
6363
reservations, err := client.ListReservations(
64-
context.Background(), &looprpc.ListReservationsRequest{},
64+
ctx, &looprpc.ListReservationsRequest{},
6565
)
6666
if err != nil {
6767
return err
@@ -156,7 +156,7 @@ func instantOut(ctx *cli.Context) error {
156156
// Now that we have the selected reservations we can estimate the
157157
// fee-rates.
158158
quote, err := client.InstantOutQuote(
159-
context.Background(), &looprpc.InstantOutQuoteRequest{
159+
ctx, &looprpc.InstantOutQuoteRequest{
160160
Amt: selectedAmt,
161161
ReservationIds: selectedReservations,
162162
},
@@ -180,11 +180,11 @@ func instantOut(ctx *cli.Context) error {
180180

181181
// Now we can request the instant out swap.
182182
instantOutRes, err := client.InstantOut(
183-
context.Background(),
183+
ctx,
184184
&looprpc.InstantOutRequest{
185185
ReservationIds: selectedReservations,
186186
OutgoingChanSet: outgoingChanSet,
187-
DestAddr: ctx.String("addr"),
187+
DestAddr: cmd.String("addr"),
188188
},
189189
)
190190
if err != nil {
@@ -202,7 +202,7 @@ func instantOut(ctx *cli.Context) error {
202202
return nil
203203
}
204204

205-
var listInstantOutsCommand = cli.Command{
205+
var listInstantOutsCommand = &cli.Command{
206206
Name: "listinstantouts",
207207
Usage: "list all instant out swaps",
208208
Description: `
@@ -211,16 +211,16 @@ var listInstantOutsCommand = cli.Command{
211211
Action: listInstantOuts,
212212
}
213213

214-
func listInstantOuts(ctx *cli.Context) error {
214+
func listInstantOuts(ctx context.Context, cmd *cli.Command) error {
215215
// First set up the swap client itself.
216-
client, cleanup, err := getClient(ctx)
216+
client, cleanup, err := getClient(ctx, cmd)
217217
if err != nil {
218218
return err
219219
}
220220
defer cleanup()
221221

222222
resp, err := client.ListInstantOuts(
223-
context.Background(), &looprpc.ListInstantOutsRequest{},
223+
ctx, &looprpc.ListInstantOutsRequest{},
224224
)
225225
if err != nil {
226226
return err

cmd/loop/l402.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"time"
88

99
"github.com/lightninglabs/loop/looprpc"
10-
"github.com/urfave/cli"
10+
"github.com/urfave/cli/v3"
1111
"gopkg.in/macaroon.v2"
1212
)
1313

@@ -24,22 +24,22 @@ type printableToken struct {
2424
FileName string `json:"file_name"`
2525
}
2626

27-
var listAuthCommand = cli.Command{
27+
var listAuthCommand = &cli.Command{
2828
Name: "listauth",
2929
Usage: "list all L402 tokens",
3030
Description: "Shows a list of all L402 tokens that loopd has paid for",
3131
Action: listAuth,
3232
}
3333

34-
func listAuth(ctx *cli.Context) error {
35-
client, cleanup, err := getClient(ctx)
34+
func listAuth(ctx context.Context, cmd *cli.Command) error {
35+
client, cleanup, err := getClient(ctx, cmd)
3636
if err != nil {
3737
return err
3838
}
3939
defer cleanup()
4040

4141
resp, err := client.GetL402Tokens(
42-
context.Background(), &looprpc.TokensRequest{},
42+
ctx, &looprpc.TokensRequest{},
4343
)
4444
if err != nil {
4545
return err
@@ -74,7 +74,7 @@ func listAuth(ctx *cli.Context) error {
7474
return nil
7575
}
7676

77-
var fetchL402Command = cli.Command{
77+
var fetchL402Command = &cli.Command{
7878
Name: "fetchl402",
7979
Usage: "fetches a new L402 authentication token from the server",
8080
Description: "Fetches a new L402 authentication token from the server. " +
@@ -84,15 +84,15 @@ var fetchL402Command = cli.Command{
8484
Action: fetchL402,
8585
}
8686

87-
func fetchL402(ctx *cli.Context) error {
88-
client, cleanup, err := getClient(ctx)
87+
func fetchL402(ctx context.Context, cmd *cli.Command) error {
88+
client, cleanup, err := getClient(ctx, cmd)
8989
if err != nil {
9090
return err
9191
}
9292
defer cleanup()
9393

9494
res, err := client.FetchL402Token(
95-
context.Background(), &looprpc.FetchL402TokenRequest{},
95+
ctx, &looprpc.FetchL402TokenRequest{},
9696
)
9797
if err != nil {
9898
return err

0 commit comments

Comments
 (0)