Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assets/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions loopd/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}()
Expand Down Expand Up @@ -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
}
}()
Expand Down Expand Up @@ -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
}
}()
Expand Down Expand Up @@ -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
}
}()
Expand Down
2 changes: 1 addition & 1 deletion loopdb/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions loopin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ func TestAbandonPublishedHtlcState(t *testing.T) {

height := int32(600)

cfg, err, inSwap := startNewLoopIn(t, ctx, height)
cfg, inSwap, err := startNewLoopIn(t, ctx, height)
require.NoError(t, err)

advanceToPublishedHtlc(t, ctx)
Expand Down Expand Up @@ -663,7 +663,7 @@ func TestAbandonSettledInvoiceState(t *testing.T) {

height := int32(600)

cfg, err, inSwap := startNewLoopIn(t, ctx, height)
cfg, inSwap, err := startNewLoopIn(t, ctx, height)
require.NoError(t, err)

advanceToPublishedHtlc(t, ctx)
Expand Down Expand Up @@ -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)

Expand All @@ -783,5 +783,5 @@ func startNewLoopIn(t *testing.T, ctx *loopInTestContext, height int32) (
}
ctx.errChan <- err
}()
return cfg, err, inSwap
return cfg, inSwap, err
}
12 changes: 8 additions & 4 deletions swap_server_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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) {

Expand All @@ -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(),
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting.

)

case tlsPath != "":
// Load the specified TLS certificate and build
Expand Down Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions sweepbatcher/sweep_batcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -638,15 +638,15 @@ 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,
tx *wire.MsgTx, label string) error {

p.attempts++
if p.attempts == 1 {
return testPublishError
return errTestPublish
}

return p.WalletKitClient.PublishTransaction(ctx, tx, label)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion uncharge_state.go

This file was deleted.

Loading