mirror of
https://github.com/lightninglabs/loop.git
synced 2026-08-13 12:33:03 +02:00
linter: fix lint issues after linter v2 update
This commit is contained in:
parent
bd6271e633
commit
e98f733ef8
29 changed files with 65 additions and 59 deletions
|
|
@ -93,6 +93,8 @@ var (
|
||||||
// Client performs the client side part of swaps. This interface exists to be
|
// Client performs the client side part of swaps. This interface exists to be
|
||||||
// able to implement a stub.
|
// able to implement a stub.
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
clientConfig
|
||||||
|
|
||||||
started uint32 // To be used atomically.
|
started uint32 // To be used atomically.
|
||||||
errChan chan error
|
errChan chan error
|
||||||
|
|
||||||
|
|
@ -107,8 +109,6 @@ type Client struct {
|
||||||
|
|
||||||
resumeReady chan struct{}
|
resumeReady chan struct{}
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
||||||
clientConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClientConfig is the exported configuration structure that is required to
|
// ClientConfig is the exported configuration structure that is required to
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,6 @@ func instantOut(ctx *cli.Context) error {
|
||||||
DestAddr: ctx.String("addr"),
|
DestAddr: ctx.String("addr"),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
@ -228,5 +227,6 @@ func listInstantOuts(ctx *cli.Context) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
printRespJSON(resp)
|
printRespJSON(resp)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -207,6 +207,7 @@ func loopIn(ctx *cli.Context) error {
|
||||||
|
|
||||||
fmt.Printf("Swap initiated\n")
|
fmt.Printf("Swap initiated\n")
|
||||||
fmt.Printf("ID: %v\n", resp.Id)
|
fmt.Printf("ID: %v\n", resp.Id)
|
||||||
|
|
||||||
if resp.HtlcAddressP2Tr != "" {
|
if resp.HtlcAddressP2Tr != "" {
|
||||||
fmt.Printf("HTLC address (P2TR): %v\n", resp.HtlcAddressP2Tr)
|
fmt.Printf("HTLC address (P2TR): %v\n", resp.HtlcAddressP2Tr)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -176,8 +176,10 @@ func loopOut(ctx *cli.Context) error {
|
||||||
"address to sweep the loop amount to")
|
"address to sweep the loop amount to")
|
||||||
}
|
}
|
||||||
|
|
||||||
var destAddr string
|
var (
|
||||||
var account string
|
destAddr string
|
||||||
|
account string
|
||||||
|
)
|
||||||
switch {
|
switch {
|
||||||
case ctx.IsSet("addr"):
|
case ctx.IsSet("addr"):
|
||||||
destAddr = ctx.String("addr")
|
destAddr = ctx.String("addr")
|
||||||
|
|
|
||||||
|
|
@ -417,6 +417,7 @@ func utxosToOutpoints(utxos []string) ([]*looprpc.OutPoint, error) {
|
||||||
if len(utxos) == 0 {
|
if len(utxos) == 0 {
|
||||||
return nil, fmt.Errorf("no utxos specified")
|
return nil, fmt.Errorf("no utxos specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, utxo := range utxos {
|
for _, utxo := range utxos {
|
||||||
outpoint, err := NewProtoOutPoint(utxo)
|
outpoint, err := NewProtoOutPoint(utxo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
|
||||||
paymentFees map[lntypes.Hash]lnwire.MilliSatoshi) (loopdb.SwapCost,
|
paymentFees map[lntypes.Hash]lnwire.MilliSatoshi) (loopdb.SwapCost,
|
||||||
error) {
|
error) {
|
||||||
|
|
||||||
// First make sure that this swap is actually finished.
|
// First, make sure that this swap is actually finished.
|
||||||
if loopOutSwap.State().State.IsPending() {
|
if loopOutSwap.State().State.IsPending() {
|
||||||
return loopdb.SwapCost{}, fmt.Errorf("swap is not yet finished")
|
return loopdb.SwapCost{}, fmt.Errorf("swap is not yet finished")
|
||||||
}
|
}
|
||||||
|
|
@ -41,8 +41,8 @@ func CalculateLoopOutCost(params *chaincfg.Params, loopOutSwap *loopdb.LoopOut,
|
||||||
}
|
}
|
||||||
|
|
||||||
// The swap hash is given and we don't need to get it from the
|
// The swap hash is given and we don't need to get it from the
|
||||||
// swap invoice, however we'll decode it anyway to get the invoice amount
|
// swap invoice, however we'll decode it anyway to get the invoice
|
||||||
// that was paid in case we don't have the payment anymore.
|
// amount that was paid in case we don't have the payment anymore.
|
||||||
_, _, swapHash, swapPaymentAmount, err := swap.DecodeInvoice(
|
_, _, swapHash, swapPaymentAmount, err := swap.DecodeInvoice(
|
||||||
params, loopOutSwap.Contract.SwapInvoice,
|
params, loopOutSwap.Contract.SwapInvoice,
|
||||||
)
|
)
|
||||||
|
|
@ -195,6 +195,6 @@ func MigrateLoopOutCosts(ctx context.Context, lnd lndclient.LndServices,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally mark the migration as done.
|
// Finally, mark the migration as done.
|
||||||
return db.SetMigration(ctx, costMigrationID)
|
return db.SetMigration(ctx, costMigrationID)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
executor.go
10
executor.go
|
|
@ -42,17 +42,14 @@ type executorConfig struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// executor is responsible for executing swaps.
|
// executor is responsible for executing swaps.
|
||||||
//
|
|
||||||
// TODO(roasbeef): rename to SubSwapper.
|
|
||||||
type executor struct {
|
type executor struct {
|
||||||
|
sync.Mutex
|
||||||
|
executorConfig
|
||||||
|
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
newSwaps chan genericSwap
|
newSwaps chan genericSwap
|
||||||
currentHeight uint32
|
currentHeight uint32
|
||||||
ready chan struct{}
|
ready chan struct{}
|
||||||
|
|
||||||
sync.Mutex
|
|
||||||
|
|
||||||
executorConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// newExecutor returns a new swap executor instance.
|
// newExecutor returns a new swap executor instance.
|
||||||
|
|
@ -80,7 +77,6 @@ func (s *executor) run(mainCtx context.Context,
|
||||||
for {
|
for {
|
||||||
blockEpochChan, blockErrorChan, err =
|
blockEpochChan, blockErrorChan, err =
|
||||||
s.lnd.ChainNotifier.RegisterBlockEpochNtfn(mainCtx)
|
s.lnd.ChainNotifier.RegisterBlockEpochNtfn(mainCtx)
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,7 +138,7 @@ func NewStateMachine(states States, observerSize int) *StateMachine {
|
||||||
func NewStateMachineWithState(states States, current StateType,
|
func NewStateMachineWithState(states States, current StateType,
|
||||||
observerSize int) *StateMachine {
|
observerSize int) *StateMachine {
|
||||||
|
|
||||||
observers := []Observer{}
|
var observers []Observer
|
||||||
var defaultObserver *CachedObserver
|
var defaultObserver *CachedObserver
|
||||||
|
|
||||||
if observerSize > 0 {
|
if observerSize > 0 {
|
||||||
|
|
|
||||||
|
|
@ -194,10 +194,10 @@ func (c *CachedObserver) WaitForStateAsync(ctx context.Context, state StateType,
|
||||||
|
|
||||||
// FixedSizeSlice is a slice with a fixed size.
|
// FixedSizeSlice is a slice with a fixed size.
|
||||||
type FixedSizeSlice[T any] struct {
|
type FixedSizeSlice[T any] struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
data []T
|
data []T
|
||||||
maxLen int
|
maxLen int
|
||||||
|
|
||||||
sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewFixedSizeSlice initializes a new FixedSlice with a given maximum length.
|
// NewFixedSizeSlice initializes a new FixedSlice with a given maximum length.
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ var (
|
||||||
|
|
||||||
// Manager manages the instantout state machines.
|
// Manager manages the instantout state machines.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
// cfg contains all the services that the reservation manager needs to
|
// cfg contains all the services that the reservation manager needs to
|
||||||
// operate.
|
// operate.
|
||||||
cfg *Config
|
cfg *Config
|
||||||
|
|
@ -36,8 +38,6 @@ type Manager struct {
|
||||||
blockEpochChan chan int32
|
blockEpochChan chan int32
|
||||||
|
|
||||||
runCtx context.Context
|
runCtx context.Context
|
||||||
|
|
||||||
sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewInstantOutManager creates a new instantout manager.
|
// NewInstantOutManager creates a new instantout manager.
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@ import (
|
||||||
|
|
||||||
// Manager manages the reservation state machines.
|
// Manager manages the reservation state machines.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
// cfg contains all the services that the reservation manager needs to
|
// cfg contains all the services that the reservation manager needs to
|
||||||
// operate.
|
// operate.
|
||||||
cfg *Config
|
cfg *Config
|
||||||
|
|
||||||
// activeReservations contains all the active reservationsFSMs.
|
// activeReservations contains all the active reservationsFSMs.
|
||||||
activeReservations map[ID]*FSM
|
activeReservations map[ID]*FSM
|
||||||
|
|
||||||
sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewManager creates a new reservation manager.
|
// NewManager creates a new reservation manager.
|
||||||
|
|
|
||||||
10
interface.go
10
interface.go
|
|
@ -115,18 +115,18 @@ type OutRequest struct {
|
||||||
|
|
||||||
// Out contains the full details of a loop out request. This includes things
|
// Out contains the full details of a loop out request. This includes things
|
||||||
// like the payment hash, the total value, and the final CTLV delay of the
|
// like the payment hash, the total value, and the final CTLV delay of the
|
||||||
// swap. We'll use this to track an active swap throughout that various swap
|
// swap. We'll use this to track an active swap throughout those various swap
|
||||||
// stages.
|
// stages.
|
||||||
type Out struct {
|
type Out struct {
|
||||||
|
// SwapInfoKit contains shared data amongst all swap types.
|
||||||
|
SwapInfoKit
|
||||||
|
|
||||||
// LoopOutContract describes the details of this loop.Out. Using these
|
// LoopOutContract describes the details of this loop.Out. Using these
|
||||||
// details,the full swap can be executed.
|
// details, the full swap can be executed.
|
||||||
loopdb.LoopOutContract
|
loopdb.LoopOutContract
|
||||||
|
|
||||||
// State is the current state of the target swap.
|
// State is the current state of the target swap.
|
||||||
State loopdb.SwapState
|
State loopdb.SwapState
|
||||||
|
|
||||||
// SwapInfoKit contains shared data amongst all swap types.
|
|
||||||
SwapInfoKit
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoopOutQuoteRequest specifies the swap parameters for which a quote is
|
// LoopOutQuoteRequest specifies the swap parameters for which a quote is
|
||||||
|
|
|
||||||
|
|
@ -271,8 +271,8 @@ type Manager struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run periodically checks whether we should automatically dispatch a loop out.
|
// Run periodically checks whether we should automatically dispatch a loop out.
|
||||||
// We run this loop even if automated swaps are not currently enabled rather
|
// We run this loop even if automated swaps are not currently enabled, instead
|
||||||
// than managing starting and stopping the ticker as our parameters are updated.
|
// of starting and stopping the ticker whenever our parameters are updated.
|
||||||
func (m *Manager) Run(ctx context.Context) error {
|
func (m *Manager) Run(ctx context.Context) error {
|
||||||
m.cfg.AutoloopTicker.Resume()
|
m.cfg.AutoloopTicker.Resume()
|
||||||
defer m.cfg.AutoloopTicker.Stop()
|
defer m.cfg.AutoloopTicker.Stop()
|
||||||
|
|
|
||||||
|
|
@ -59,9 +59,9 @@ func (s *PostgresConfig) DSN(hidePassword bool) string {
|
||||||
// PostgresStore is a database store implementation that uses a Postgres
|
// PostgresStore is a database store implementation that uses a Postgres
|
||||||
// backend.
|
// backend.
|
||||||
type PostgresStore struct {
|
type PostgresStore struct {
|
||||||
cfg *PostgresConfig
|
|
||||||
|
|
||||||
*BaseDB
|
*BaseDB
|
||||||
|
|
||||||
|
cfg *PostgresConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// In migration of sweeps table from outpoint_txid and outpoint_index to
|
// In migration of sweeps table from outpoint_txid and outpoint_index to
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ func TestProtocolVersionSanity(t *testing.T) {
|
||||||
require.Equal(t, uint32(version), uint32(rpcVersions[i]))
|
require.Equal(t, uint32(version), uint32(rpcVersions[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally test that the current version contants are up to date
|
// Finally, test that the current version constants are up to date
|
||||||
require.Equal(t,
|
require.Equal(t,
|
||||||
CurrentProtocolVersion(),
|
CurrentProtocolVersion(),
|
||||||
versions[len(versions)-1],
|
versions[len(versions)-1],
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,9 @@ type SqliteConfig struct {
|
||||||
|
|
||||||
// SqliteSwapStore is a sqlite3 based database for the loop daemon.
|
// SqliteSwapStore is a sqlite3 based database for the loop daemon.
|
||||||
type SqliteSwapStore struct {
|
type SqliteSwapStore struct {
|
||||||
cfg *SqliteConfig
|
|
||||||
|
|
||||||
*BaseDB
|
*BaseDB
|
||||||
|
|
||||||
|
cfg *SqliteConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewSqliteStore attempts to open a new sqlite database based on the passed
|
// NewSqliteStore attempts to open a new sqlite database based on the passed
|
||||||
|
|
@ -174,11 +174,11 @@ func NewTestSqliteDB(t *testing.T) *SqliteSwapStore {
|
||||||
// BaseDB is the base database struct that each implementation can embed to
|
// BaseDB is the base database struct that each implementation can embed to
|
||||||
// gain some common functionality.
|
// gain some common functionality.
|
||||||
type BaseDB struct {
|
type BaseDB struct {
|
||||||
network *chaincfg.Params
|
|
||||||
|
|
||||||
*sql.DB
|
*sql.DB
|
||||||
|
|
||||||
*sqlc.Queries
|
*sqlc.Queries
|
||||||
|
|
||||||
|
network *chaincfg.Params
|
||||||
}
|
}
|
||||||
|
|
||||||
// BeginTx wraps the normal sql specific BeginTx method with the TxOptions
|
// BeginTx wraps the normal sql specific BeginTx method with the TxOptions
|
||||||
|
|
|
||||||
|
|
@ -240,6 +240,7 @@ func newLoopInSwap(globalCtx context.Context, cfg *swapConfig,
|
||||||
request.Amount, senderKey, senderInternalPubKey, swapInvoice,
|
request.Amount, senderKey, senderInternalPubKey, swapInvoice,
|
||||||
probeInvoice, request.LastHop, request.Initiator,
|
probeInvoice, request.LastHop, request.Initiator,
|
||||||
)
|
)
|
||||||
|
|
||||||
probeWaitCancel()
|
probeWaitCancel()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, wrapGrpcError("cannot initiate swap", err)
|
return nil, wrapGrpcError("cannot initiate swap", err)
|
||||||
|
|
@ -352,6 +353,7 @@ func awaitProbe(ctx context.Context, lnd lndclient.LndServices,
|
||||||
switch update.State {
|
switch update.State {
|
||||||
case invpkg.ContractAccepted:
|
case invpkg.ContractAccepted:
|
||||||
log.Infof("Server probe successful")
|
log.Infof("Server probe successful")
|
||||||
|
|
||||||
probeResult <- nil
|
probeResult <- nil
|
||||||
|
|
||||||
// Cancel probe invoice so that the
|
// Cancel probe invoice so that the
|
||||||
|
|
|
||||||
|
|
@ -538,7 +538,7 @@ func (s *loopOutSwap) handlePaymentResult(ctx context.Context,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// executeSwap executes the swap, but returns as soon as the swap outcome is
|
// executeSwap executes the swap but returns as soon as the swap outcome is
|
||||||
// final. At that point, there may still be pending off-chain payment(s).
|
// final. At that point, there may still be pending off-chain payment(s).
|
||||||
func (s *loopOutSwap) executeSwap(globalCtx context.Context) error {
|
func (s *loopOutSwap) executeSwap(globalCtx context.Context) error {
|
||||||
// Decode the prepay invoice so we can ensure that we account for the
|
// Decode the prepay invoice so we can ensure that we account for the
|
||||||
|
|
@ -1192,7 +1192,7 @@ func (s *loopOutSwap) waitForHtlcSpendConfirmedV2(globalCtx context.Context,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// paymentComplete tracks whether our payment is complete, and
|
// paymentComplete tracks whether our payment is complete and
|
||||||
// is used to decide whether we need to push our preimage to
|
// is used to decide whether we need to push our preimage to
|
||||||
// the server.
|
// the server.
|
||||||
paymentComplete bool
|
paymentComplete bool
|
||||||
|
|
|
||||||
|
|
@ -62,12 +62,13 @@ type Config struct {
|
||||||
// Manager is a manager for notifications that the swap server sends to the
|
// Manager is a manager for notifications that the swap server sends to the
|
||||||
// client.
|
// client.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
cfg *Config
|
cfg *Config
|
||||||
|
|
||||||
hasL402 bool
|
hasL402 bool
|
||||||
|
|
||||||
subscribers map[NotificationType][]subscriber
|
subscribers map[NotificationType][]subscriber
|
||||||
sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewManager creates a new notification manager.
|
// NewManager creates a new notification manager.
|
||||||
|
|
|
||||||
|
|
@ -23,11 +23,12 @@ var (
|
||||||
|
|
||||||
// mockNotificationsClient implements the NotificationsClient interface for testing.
|
// mockNotificationsClient implements the NotificationsClient interface for testing.
|
||||||
type mockNotificationsClient struct {
|
type mockNotificationsClient struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
mockStream swapserverrpc.SwapServer_SubscribeNotificationsClient
|
mockStream swapserverrpc.SwapServer_SubscribeNotificationsClient
|
||||||
subscribeErr error
|
subscribeErr error
|
||||||
attemptTimes []time.Time
|
attemptTimes []time.Time
|
||||||
timesCalled int
|
timesCalled int
|
||||||
sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *mockNotificationsClient) SubscribeNotifications(ctx context.Context,
|
func (m *mockNotificationsClient) SubscribeNotifications(ctx context.Context,
|
||||||
|
|
@ -49,6 +50,7 @@ func (m *mockNotificationsClient) SubscribeNotifications(ctx context.Context,
|
||||||
// mockSubscribeNotificationsClient simulates the server stream.
|
// mockSubscribeNotificationsClient simulates the server stream.
|
||||||
type mockSubscribeNotificationsClient struct {
|
type mockSubscribeNotificationsClient struct {
|
||||||
grpc.ClientStream
|
grpc.ClientStream
|
||||||
|
|
||||||
recvChan chan *swapserverrpc.SubscribeNotificationsResponse
|
recvChan chan *swapserverrpc.SubscribeNotificationsResponse
|
||||||
recvErrChan chan error
|
recvErrChan chan error
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package loop
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
@ -92,7 +93,7 @@ func AcquireRoutingPlugin(ctx context.Context, pluginType RoutingPluginType,
|
||||||
// Initialize the plugin with the passed parameters.
|
// Initialize the plugin with the passed parameters.
|
||||||
err := routingPluginInstance.Init(ctx, target, routeHints, amt)
|
err := routingPluginInstance.Init(ctx, target, routeHints, amt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err == ErrRoutingPluginNotApplicable {
|
if errors.Is(err, ErrRoutingPluginNotApplicable) {
|
||||||
// Since the routing plugin is not applicable for this
|
// Since the routing plugin is not applicable for this
|
||||||
// payment, we can immediately destruct it.
|
// payment, we can immediately destruct it.
|
||||||
if err := routingPluginInstance.Done(ctx); err != nil {
|
if err := routingPluginInstance.Done(ctx); err != nil {
|
||||||
|
|
@ -100,7 +101,7 @@ func AcquireRoutingPlugin(ctx context.Context, pluginType RoutingPluginType,
|
||||||
"plugin: %v", err)
|
"plugin: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrRoutingPluginNotApplicable is non critical, so
|
// ErrRoutingPluginNotApplicable is non-critical, so
|
||||||
// we're masking this error as we can continue the swap
|
// we're masking this error as we can continue the swap
|
||||||
// flow without the routing plugin.
|
// flow without the routing plugin.
|
||||||
err = nil
|
err = nil
|
||||||
|
|
|
||||||
|
|
@ -49,10 +49,10 @@ type ManagerConfig struct {
|
||||||
|
|
||||||
// Manager manages the address state machines.
|
// Manager manages the address state machines.
|
||||||
type Manager struct {
|
type Manager struct {
|
||||||
cfg *ManagerConfig
|
|
||||||
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
||||||
|
cfg *ManagerConfig
|
||||||
|
|
||||||
currentHeight atomic.Int32
|
currentHeight atomic.Int32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,15 +29,17 @@ func (r *ID) FromByteSlice(b []byte) error {
|
||||||
// Deposit bundles an utxo at a static address together with manager-relevant
|
// Deposit bundles an utxo at a static address together with manager-relevant
|
||||||
// data.
|
// data.
|
||||||
type Deposit struct {
|
type Deposit struct {
|
||||||
|
sync.Mutex
|
||||||
|
|
||||||
|
// Outpoint of the deposit.
|
||||||
|
wire.OutPoint
|
||||||
|
|
||||||
// ID is the unique identifier of the deposit.
|
// ID is the unique identifier of the deposit.
|
||||||
ID ID
|
ID ID
|
||||||
|
|
||||||
// state is the current state of the deposit.
|
// state is the current state of the deposit.
|
||||||
state fsm.StateType
|
state fsm.StateType
|
||||||
|
|
||||||
// Outpoint of the deposit.
|
|
||||||
wire.OutPoint
|
|
||||||
|
|
||||||
// Value is the amount of the deposit.
|
// Value is the amount of the deposit.
|
||||||
Value btcutil.Amount
|
Value btcutil.Amount
|
||||||
|
|
||||||
|
|
@ -52,11 +54,9 @@ type Deposit struct {
|
||||||
// ExpirySweepTxid is the transaction id of the expiry sweep.
|
// ExpirySweepTxid is the transaction id of the expiry sweep.
|
||||||
ExpirySweepTxid chainhash.Hash
|
ExpirySweepTxid chainhash.Hash
|
||||||
|
|
||||||
// FinalizedWithdrawalTx is the coop signed withdrawal transaction. It
|
// FinalizedWithdrawalTx is the coop-signed withdrawal transaction. It
|
||||||
// is republished on new block arrivals and on client restarts.
|
// is republished on new block arrivals and on client restarts.
|
||||||
FinalizedWithdrawalTx *wire.MsgTx
|
FinalizedWithdrawalTx *wire.MsgTx
|
||||||
|
|
||||||
sync.Mutex
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsInFinalState returns true if the deposit is final.
|
// IsInFinalState returns true if the deposit is final.
|
||||||
|
|
|
||||||
|
|
@ -689,7 +689,7 @@ func (f *FSM) SweepHtlcTimeoutAction(ctx context.Context,
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
f.Errorf(ctx.Err().Error())
|
f.Errorf("%v", ctx.Err())
|
||||||
|
|
||||||
default:
|
default:
|
||||||
<-time.After(1 * time.Hour)
|
<-time.After(1 * time.Hour)
|
||||||
|
|
|
||||||
4
swap.go
4
swap.go
|
|
@ -13,6 +13,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type swapKit struct {
|
type swapKit struct {
|
||||||
|
swapConfig
|
||||||
|
|
||||||
hash lntypes.Hash
|
hash lntypes.Hash
|
||||||
|
|
||||||
height int32 //nolint:structcheck
|
height int32 //nolint:structcheck
|
||||||
|
|
@ -28,8 +30,6 @@ type swapKit struct {
|
||||||
contract *loopdb.SwapContract
|
contract *loopdb.SwapContract
|
||||||
|
|
||||||
swapType swap.Type
|
swapType swap.Type
|
||||||
|
|
||||||
swapConfig
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newSwapKit(hash lntypes.Hash, swapType swap.Type, cfg *swapConfig,
|
func newSwapKit(hash lntypes.Hash, swapType swap.Type, cfg *swapConfig,
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ import (
|
||||||
|
|
||||||
type mockChainNotifier struct {
|
type mockChainNotifier struct {
|
||||||
lndclient.ChainNotifierClient
|
lndclient.ChainNotifierClient
|
||||||
|
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
|
|
||||||
lnd *LndMockServices
|
lnd *LndMockServices
|
||||||
confRegistrations []*ConfRegistration
|
confRegistrations []*ConfRegistration
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type mockLightningClient struct {
|
type mockLightningClient struct {
|
||||||
lnd *LndMockServices
|
|
||||||
wg sync.WaitGroup
|
|
||||||
|
|
||||||
// Embed lndclient's interface so that lndclient can be expanded
|
// Embed lndclient's interface so that lndclient can be expanded
|
||||||
// without the need to implement unused functions on the mock.
|
// without the need to implement unused functions on the mock.
|
||||||
lndclient.LightningClient
|
lndclient.LightningClient
|
||||||
|
|
||||||
|
lnd *LndMockServices
|
||||||
|
wg sync.WaitGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayInvoice pays an invoice.
|
// PayInvoice pays an invoice.
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
type mockRouter struct {
|
type mockRouter struct {
|
||||||
lndclient.RouterClient
|
lndclient.RouterClient
|
||||||
|
|
||||||
lnd *LndMockServices
|
lnd *LndMockServices
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
1
utils.go
1
utils.go
|
|
@ -36,7 +36,6 @@ func isPublicNode(ctx context.Context, lndClient lndclient.LightningClient,
|
||||||
// GetNodeInfo doesn't report our private channels with the queried node
|
// GetNodeInfo doesn't report our private channels with the queried node
|
||||||
// so, we can use it to determine if the node is considered public.
|
// so, we can use it to determine if the node is considered public.
|
||||||
nodeInfo, err := lndClient.GetNodeInfo(ctx, pubKey, true)
|
nodeInfo, err := lndClient.GetNodeInfo(ctx, pubKey, true)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue