|
89 | 89 | listSwapsCommand, swapInfoCommand, getLiquidityParamsCommand, |
90 | 90 | setLiquidityRuleCommand, suggestSwapCommand, setParamsCommand, |
91 | 91 | getInfoCommand, abandonSwapCommand, reservationsCommands, |
92 | | - instantOutCommand, listInstantOutsCommand, |
| 92 | + instantOutCommand, listInstantOutsCommand, stopCommand, |
93 | 93 | printManCommand, printMarkdownCommand, |
94 | 94 | } |
95 | 95 | ) |
@@ -190,20 +190,37 @@ func main() { |
190 | 190 | } |
191 | 191 | } |
192 | 192 |
|
193 | | -func getClient(ctx context.Context, cmd *cli.Command) (looprpc.SwapClientClient, func(), error) { |
| 193 | +// getClient establishes a SwapClient RPC connection and returns the client and |
| 194 | +// a cleanup handler. |
| 195 | +func getClient(ctx context.Context, cmd *cli.Command) (looprpc.SwapClientClient, |
| 196 | + func(), error) { |
| 197 | + |
| 198 | + client, _, cleanup, err := getClientWithConn(ctx, cmd) |
| 199 | + if err != nil { |
| 200 | + return nil, nil, err |
| 201 | + } |
| 202 | + |
| 203 | + return client, cleanup, nil |
| 204 | +} |
| 205 | + |
| 206 | +// getClientWithConn returns both the SwapClient RPC client and the underlying |
| 207 | +// gRPC connection so callers can perform connection-aware actions. |
| 208 | +func getClientWithConn(ctx context.Context, cmd *cli.Command) ( |
| 209 | + looprpc.SwapClientClient, *grpc.ClientConn, func(), error) { |
| 210 | + |
194 | 211 | rpcServer := cmd.String("rpcserver") |
195 | 212 | tlsCertPath, macaroonPath, err := extractPathArgs(cmd) |
196 | 213 | if err != nil { |
197 | | - return nil, nil, err |
| 214 | + return nil, nil, nil, err |
198 | 215 | } |
199 | 216 | conn, err := getClientConn(ctx, rpcServer, tlsCertPath, macaroonPath) |
200 | 217 | if err != nil { |
201 | | - return nil, nil, err |
| 218 | + return nil, nil, nil, err |
202 | 219 | } |
203 | 220 | cleanup := func() { conn.Close() } |
204 | 221 |
|
205 | 222 | loopClient := looprpc.NewSwapClientClient(conn) |
206 | | - return loopClient, cleanup, nil |
| 223 | + return loopClient, conn, cleanup, nil |
207 | 224 | } |
208 | 225 |
|
209 | 226 | func getMaxRoutingFee(amt btcutil.Amount) btcutil.Amount { |
|
0 commit comments