From 5ec5875dd7d10edd4516808030fb5d62c68aefd8 Mon Sep 17 00:00:00 2001 From: Slyghtning Date: Fri, 19 Dec 2025 10:02:28 +0100 Subject: [PATCH] cmd: replace grpc.DialContext with grpc.NewClient --- cmd/loop/debug.go | 2 +- cmd/loop/info.go | 2 +- cmd/loop/instantout.go | 4 ++-- cmd/loop/l402.go | 4 ++-- cmd/loop/liquidity.go | 12 ++++++------ cmd/loop/loopin.go | 2 +- cmd/loop/loopout.go | 2 +- cmd/loop/main.go | 18 +++++++++--------- cmd/loop/monitor.go | 2 +- cmd/loop/quote.go | 4 ++-- cmd/loop/reservations.go | 2 +- cmd/loop/staticaddr.go | 16 ++++++++-------- cmd/loop/stop.go | 2 +- cmd/loop/swaps.go | 6 +++--- cmd/loop/terms.go | 2 +- 15 files changed, 40 insertions(+), 40 deletions(-) diff --git a/cmd/loop/debug.go b/cmd/loop/debug.go index b96423dd..9bb17106 100644 --- a/cmd/loop/debug.go +++ b/cmd/loop/debug.go @@ -48,7 +48,7 @@ func getDebugClient(ctx context.Context, cmd *cli.Command) (looprpc.DebugClient, if err != nil { return nil, nil, err } - conn, err := getClientConn(ctx, rpcServer, tlsCertPath, macaroonPath) + conn, err := getClientConn(rpcServer, tlsCertPath, macaroonPath) if err != nil { return nil, nil, err } diff --git a/cmd/loop/info.go b/cmd/loop/info.go index b2f3c118..489744d0 100644 --- a/cmd/loop/info.go +++ b/cmd/loop/info.go @@ -17,7 +17,7 @@ var getInfoCommand = &cli.Command{ } func getInfo(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/instantout.go b/cmd/loop/instantout.go index cffc094e..5a558f24 100644 --- a/cmd/loop/instantout.go +++ b/cmd/loop/instantout.go @@ -53,7 +53,7 @@ func instantOut(ctx context.Context, cmd *cli.Command) error { } // First set up the swap client itself. - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -213,7 +213,7 @@ var listInstantOutsCommand = &cli.Command{ func listInstantOuts(ctx context.Context, cmd *cli.Command) error { // First set up the swap client itself. - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/l402.go b/cmd/loop/l402.go index 106011cf..b859e1ba 100644 --- a/cmd/loop/l402.go +++ b/cmd/loop/l402.go @@ -32,7 +32,7 @@ var listAuthCommand = &cli.Command{ } func listAuth(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -85,7 +85,7 @@ var fetchL402Command = &cli.Command{ } func fetchL402(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/liquidity.go b/cmd/loop/liquidity.go index e6c575f7..5492f204 100644 --- a/cmd/loop/liquidity.go +++ b/cmd/loop/liquidity.go @@ -25,7 +25,7 @@ var getLiquidityParamsCommand = &cli.Command{ } func getParams(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -98,7 +98,7 @@ func setRule(ctx context.Context, cmd *cli.Command) error { pubkeyRule = true } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -106,7 +106,7 @@ func setRule(ctx context.Context, cmd *cli.Command) error { // We need to set the full set of current parameters every time we call // SetParameters. To allow users to set only individual fields on the - // cli, we lookup our current params, then update individual values. + // cli, we look up our current params, then update individual values. params, err := client.GetLiquidityParams( ctx, &looprpc.GetLiquidityParamsRequest{}, ) @@ -395,7 +395,7 @@ var setParamsCommand = &cli.Command{ } func setParams(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -403,7 +403,7 @@ func setParams(ctx context.Context, cmd *cli.Command) error { // We need to set the full set of current parameters every time we call // SetParameters. To allow users to set only individual fields on the - // cli, we lookup our current params, then update individual values. + // cli, we look up our current params, then update individual values. params, err := client.GetLiquidityParams( ctx, &looprpc.GetLiquidityParamsRequest{}, ) @@ -693,7 +693,7 @@ var suggestSwapCommand = &cli.Command{ } func suggestSwap(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/loopin.go b/cmd/loop/loopin.go index 177cd0aa..0f1401d2 100644 --- a/cmd/loop/loopin.go +++ b/cmd/loop/loopin.go @@ -108,7 +108,7 @@ func loopIn(ctx context.Context, cmd *cli.Command) error { return err } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/loopout.go b/cmd/loop/loopout.go index 2831afd0..9e7a992a 100644 --- a/cmd/loop/loopout.go +++ b/cmd/loop/loopout.go @@ -237,7 +237,7 @@ func loopOut(ctx context.Context, cmd *cli.Command) error { } } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/main.go b/cmd/loop/main.go index fa60e712..14db1c58 100644 --- a/cmd/loop/main.go +++ b/cmd/loop/main.go @@ -192,10 +192,10 @@ func main() { // getClient establishes a SwapClient RPC connection and returns the client and // a cleanup handler. -func getClient(ctx context.Context, cmd *cli.Command) (looprpc.SwapClientClient, +func getClient(cmd *cli.Command) (looprpc.SwapClientClient, func(), error) { - client, _, cleanup, err := getClientWithConn(ctx, cmd) + client, _, cleanup, err := getClientWithConn(cmd) if err != nil { return nil, nil, err } @@ -205,15 +205,15 @@ func getClient(ctx context.Context, cmd *cli.Command) (looprpc.SwapClientClient, // getClientWithConn returns both the SwapClient RPC client and the underlying // gRPC connection so callers can perform connection-aware actions. -func getClientWithConn(ctx context.Context, cmd *cli.Command) ( - looprpc.SwapClientClient, *grpc.ClientConn, func(), error) { +func getClientWithConn(cmd *cli.Command) (looprpc.SwapClientClient, + *grpc.ClientConn, func(), error) { rpcServer := cmd.String("rpcserver") tlsCertPath, macaroonPath, err := extractPathArgs(cmd) if err != nil { return nil, nil, nil, err } - conn, err := getClientConn(ctx, rpcServer, tlsCertPath, macaroonPath) + conn, err := getClientConn(rpcServer, tlsCertPath, macaroonPath) if err != nil { return nil, nil, nil, err } @@ -432,7 +432,7 @@ func logSwap(swap *looprpc.SwapStatus) { fmt.Println() } -func getClientConn(ctx context.Context, address, tlsCertPath, macaroonPath string) (*grpc.ClientConn, +func getClientConn(address, tlsCertPath, macaroonPath string) (*grpc.ClientConn, error) { // We always need to send a macaroon. @@ -446,7 +446,7 @@ func getClientConn(ctx context.Context, address, tlsCertPath, macaroonPath strin macOption, } - // TLS cannot be disabled, we'll always have a cert file to read. + // Since TLS cannot be disabled, we'll always have a cert file to read. creds, err := credentials.NewClientTLSFromFile(tlsCertPath, "") if err != nil { return nil, err @@ -454,9 +454,9 @@ func getClientConn(ctx context.Context, address, tlsCertPath, macaroonPath strin opts = append(opts, grpc.WithTransportCredentials(creds)) - conn, err := grpc.DialContext(ctx, address, opts...) + conn, err := grpc.NewClient(address, opts...) if err != nil { - return nil, fmt.Errorf("unable to connect to RPC server: %v", + return nil, fmt.Errorf("unable to create RPC client: %v", err) } diff --git a/cmd/loop/monitor.go b/cmd/loop/monitor.go index 28794edb..92afa0f5 100644 --- a/cmd/loop/monitor.go +++ b/cmd/loop/monitor.go @@ -16,7 +16,7 @@ var monitorCommand = &cli.Command{ } func monitor(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/quote.go b/cmd/loop/quote.go index b467e5ce..d6e7b6c2 100644 --- a/cmd/loop/quote.go +++ b/cmd/loop/quote.go @@ -72,7 +72,7 @@ func quoteIn(ctx context.Context, cmd *cli.Command) error { } } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -199,7 +199,7 @@ func quoteOut(ctx context.Context, cmd *cli.Command) error { return err } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/reservations.go b/cmd/loop/reservations.go index 4e26fc04..122eda12 100644 --- a/cmd/loop/reservations.go +++ b/cmd/loop/reservations.go @@ -37,7 +37,7 @@ var ( ) func listReservations(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/staticaddr.go b/cmd/loop/staticaddr.go index f68febb3..3c0fe7d3 100644 --- a/cmd/loop/staticaddr.go +++ b/cmd/loop/staticaddr.go @@ -62,7 +62,7 @@ func newStaticAddress(ctx context.Context, cmd *cli.Command) error { return err } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -107,7 +107,7 @@ func listUnspent(ctx context.Context, cmd *cli.Command) error { return showCommandHelp(ctx, cmd) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -173,7 +173,7 @@ func withdraw(ctx context.Context, cmd *cli.Command) error { return showCommandHelp(ctx, cmd) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -251,7 +251,7 @@ func listDeposits(ctx context.Context, cmd *cli.Command) error { return showCommandHelp(ctx, cmd) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -323,7 +323,7 @@ func listWithdrawals(ctx context.Context, cmd *cli.Command) error { return showCommandHelp(ctx, cmd) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -354,7 +354,7 @@ func listStaticAddressSwaps(ctx context.Context, cmd *cli.Command) error { return showCommandHelp(ctx, cmd) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -388,7 +388,7 @@ func summary(ctx context.Context, cmd *cli.Command) error { return showCommandHelp(ctx, cmd) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -519,7 +519,7 @@ func staticAddressLoopIn(ctx context.Context, cmd *cli.Command) error { selectedAmount = int64(cmd.Uint64("amt")) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/stop.go b/cmd/loop/stop.go index d0196492..293c8c6b 100644 --- a/cmd/loop/stop.go +++ b/cmd/loop/stop.go @@ -29,7 +29,7 @@ func stopDaemon(ctx context.Context, cmd *cli.Command) error { waitForShutdown := cmd.Bool("wait") // Establish a client connection to loopd. - client, conn, cleanup, err := getClientWithConn(ctx, cmd) + client, conn, cleanup, err := getClientWithConn(cmd) if err != nil { return err } diff --git a/cmd/loop/swaps.go b/cmd/loop/swaps.go index 899925e9..fae25c3c 100644 --- a/cmd/loop/swaps.go +++ b/cmd/loop/swaps.go @@ -48,7 +48,7 @@ var listSwapsCommand = &cli.Command{ } func listSwaps(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -164,7 +164,7 @@ func swapInfo(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("cannot hex decode id: %v", err) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } @@ -226,7 +226,7 @@ func abandonSwap(ctx context.Context, cmd *cli.Command) error { return fmt.Errorf("cannot hex decode id: %v", err) } - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err } diff --git a/cmd/loop/terms.go b/cmd/loop/terms.go index c7230ada..fd87c6b3 100644 --- a/cmd/loop/terms.go +++ b/cmd/loop/terms.go @@ -16,7 +16,7 @@ var termsCommand = &cli.Command{ } func terms(ctx context.Context, cmd *cli.Command) error { - client, cleanup, err := getClient(ctx, cmd) + client, cleanup, err := getClient(cmd) if err != nil { return err }