diff --git a/assets/client.go b/assets/client.go index 88c23efe5..c224f3335 100644 --- a/assets/client.go +++ b/assets/client.go @@ -306,7 +306,7 @@ func getClientConn(config *TapdConfig) (*grpc.ClientConn, error) { } // Dial the gRPC server. - conn, err := grpc.Dial(config.Host, opts...) + conn, err := grpc.NewClient(config.Host, opts...) if err != nil { return nil, err } diff --git a/loopd/daemon.go b/loopd/daemon.go index 6cbed533e..8c8a97257 100644 --- a/loopd/daemon.go +++ b/loopd/daemon.go @@ -892,7 +892,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error { defer infof("Static address manager stopped") err := staticAddressManager.Run(d.mainCtx, initChan) - if err != nil && !errors.Is(context.Canceled, err) { + if err != nil && !errors.Is(err, context.Canceled) { d.internalErrChan <- err } }() @@ -924,7 +924,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error { defer infof("Static address deposit manager stopped") err := depositManager.Run(d.mainCtx, initChan) - if err != nil && !errors.Is(context.Canceled, err) { + if err != nil && !errors.Is(err, context.Canceled) { d.internalErrChan <- err } }() @@ -956,7 +956,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error { defer infof("Static address withdrawal manager stopped") err := withdrawalManager.Run(d.mainCtx, initChan) - if err != nil && !errors.Is(context.Canceled, err) { + if err != nil && !errors.Is(err, context.Canceled) { d.internalErrChan <- err } }() @@ -992,7 +992,7 @@ func (d *Daemon) initialize(withMacaroonService bool) error { infof("Starting static address loop-in manager...") defer infof("Static address loop-in manager stopped") err := staticLoopInManager.Run(d.mainCtx, initChan) - if err != nil && !errors.Is(context.Canceled, err) { + if err != nil && !errors.Is(err, context.Canceled) { d.internalErrChan <- err } }() diff --git a/loopdb/store.go b/loopdb/store.go index 2087c76c8..3dd5a6bde 100644 --- a/loopdb/store.go +++ b/loopdb/store.go @@ -194,7 +194,7 @@ func NewBoltSwapStore(dbPath string, chainParams *chaincfg.Params) ( bdb, err := bbolt.Open(path, 0600, &bbolt.Options{ Timeout: DefaultLoopDBTimeout, }) - if err == bbolt.ErrTimeout { + if errors.Is(err, bbolt.ErrTimeout) { return nil, fmt.Errorf("%w: couldn't obtain exclusive lock on "+ "%s, timed out after %v", bbolt.ErrTimeout, path, DefaultLoopDBTimeout) diff --git a/loopin_test.go b/loopin_test.go index d413cc83a..b073a0577 100644 --- a/loopin_test.go +++ b/loopin_test.go @@ -760,7 +760,7 @@ func advanceToPublishedHtlc(t *testing.T, ctx *loopInTestContext) SwapInfo { } func startNewLoopIn(t *testing.T, ctx *loopInTestContext, height int32) ( - *swapConfig, error, *loopInSwap) { + *swapConfig, *loopInSwap, error) { cfg := newSwapConfig(&ctx.lnd.LndServices, ctx.store, ctx.server, nil) @@ -783,5 +783,5 @@ func startNewLoopIn(t *testing.T, ctx *loopInTestContext, height int32) ( } ctx.errChan <- err }() - return cfg, err, inSwap + return cfg, inSwap, err } diff --git a/swap_server_client.go b/swap_server_client.go index dfe125d12..4f150ea9c 100644 --- a/swap_server_client.go +++ b/swap_server_client.go @@ -26,6 +26,7 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/credentials" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/status" ) @@ -896,7 +897,7 @@ func rpcRouteCancel(details *outCancelDetails) ( // getSwapServerConn returns a connection to the swap server. A non-empty // proxyAddr indicates that a SOCKS proxy found at the address should be used to // establish the connection. -func getSwapServerConn(address, proxyAddress string, insecure bool, +func getSwapServerConn(address, proxyAddress string, insec bool, tlsPath string, interceptor *l402.ClientInterceptor) (*grpc.ClientConn, error) { @@ -914,8 +915,11 @@ func getSwapServerConn(address, proxyAddress string, insecure bool, // using a self-signed certificate or with a certificate signed by a // public CA. switch { - case insecure: - opts = append(opts, grpc.WithInsecure()) + case insec: + opts = append(opts, grpc.WithTransportCredentials( + insecure.NewCredentials(), + ), + ) case tlsPath != "": // Load the specified TLS certificate and build @@ -945,7 +949,7 @@ func getSwapServerConn(address, proxyAddress string, insecure bool, opts = append(opts, grpc.WithContextDialer(torDialer)) } - conn, err := grpc.Dial(address, opts...) + conn, err := grpc.NewClient(address, opts...) if err != nil { return nil, fmt.Errorf("unable to connect to RPC server: %v", err) diff --git a/sweepbatcher/sweep_batcher_test.go b/sweepbatcher/sweep_batcher_test.go index 6a9c57c10..c7c48c249 100644 --- a/sweepbatcher/sweep_batcher_test.go +++ b/sweepbatcher/sweep_batcher_test.go @@ -638,7 +638,7 @@ type testTransactionPublisher struct { attempts int } -var testPublishError = errors.New("test publish error") +var errTestPublish = errors.New("test publish error") // PublishTransaction publishes the transaction or fails it's the first attempt. func (p *testTransactionPublisher) PublishTransaction(ctx context.Context, @@ -646,7 +646,7 @@ func (p *testTransactionPublisher) PublishTransaction(ctx context.Context, p.attempts++ if p.attempts == 1 { - return testPublishError + return errTestPublish } return p.WalletKitClient.PublishTransaction(ctx, tx, label) @@ -733,7 +733,7 @@ func testPublishErrorHandler(t *testing.T, store testStore, }, test.Timeout, eventuallyCheckFrequency) // The first attempt to publish the batch tx is expected to fail. - require.ErrorIs(t, <-publishErrorChan, testPublishError) + require.ErrorIs(t, <-publishErrorChan, errTestPublish) // Mine a block to trigger another publishing attempt. err = lnd.NotifyHeight(601) @@ -4072,8 +4072,8 @@ func testSweepBatcherHandleSweepRace(t *testing.T, store testStore, <-batcher.initDone const ( - sweepValue btcutil.Amount = 1_000_000 - confHeight = 605 + sweepValue = btcutil.Amount(1_000_000) + confHeight = 605 ) sweepOutpoint := wire.OutPoint{ @@ -4534,8 +4534,8 @@ func TestSweepBatcherConfirmedBatchIncompleteSweeps(t *testing.T) { swapStore := newLoopdbStore(t, sqlDB) const ( - sweepValue btcutil.Amount = 1_000_000 - confHeight = 777 + sweepValue = btcutil.Amount(1_000_000) + confHeight = 777 ) ctx := context.Background() diff --git a/uncharge_state.go b/uncharge_state.go deleted file mode 100644 index 2d09be7ac..000000000 --- a/uncharge_state.go +++ /dev/null @@ -1 +0,0 @@ -package loop