mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
cmd: replace grpc.DialContext with grpc.NewClient
This commit is contained in:
parent
175b7d601b
commit
5ec5875dd7
15 changed files with 40 additions and 40 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue