diff --git a/loopd/daemon.go b/loopd/daemon.go index 786baf4e..529a2eb8 100644 --- a/loopd/daemon.go +++ b/loopd/daemon.go @@ -610,12 +610,9 @@ func (d *Daemon) initialize(withMacaroonService bool) error { // Static address deposit manager setup. depositStore := deposit.NewSqlStore(baseDb) depoCfg := &deposit.ManagerConfig{ - AddressClient: staticAddressClient, AddressManager: staticAddressManager, - SwapClient: swapClient, Store: depositStore, WalletKit: d.lnd.WalletKit, - ChainParams: d.lnd.ChainParams, ChainNotifier: d.lnd.ChainNotifier, Signer: d.lnd.Signer, } @@ -646,14 +643,10 @@ func (d *Daemon) initialize(withMacaroonService bool) error { // Static address deposit open channel manager setup. openChannelCfg := &openchannel.Config{ - Server: staticAddressClient, - AddressManager: staticAddressManager, DepositManager: depositManager, WithdrawalManager: withdrawalManager, WalletKit: d.lnd.WalletKit, ChainParams: d.lnd.ChainParams, - ChainNotifier: d.lnd.ChainNotifier, - Signer: d.lnd.Signer, LightningClient: d.lnd.Client, } openChannelManager = openchannel.NewManager(openChannelCfg) diff --git a/staticaddr/address/interface.go b/staticaddr/address/interface.go index 14cae7fe..6f626b00 100644 --- a/staticaddr/address/interface.go +++ b/staticaddr/address/interface.go @@ -15,11 +15,6 @@ type Store interface { // into the store. CreateStaticAddress(ctx context.Context, addrParams *Parameters) error - // GetStaticAddress fetches static address parameters for a given - // address ID. - GetStaticAddress(ctx context.Context, pkScript []byte) (*Parameters, - error) - // GetAllStaticAddresses retrieves all static addresses from the store. GetAllStaticAddresses(ctx context.Context) ([]*Parameters, error) diff --git a/staticaddr/address/sql_store.go b/staticaddr/address/sql_store.go index 9f47db02..8d78e03c 100644 --- a/staticaddr/address/sql_store.go +++ b/staticaddr/address/sql_store.go @@ -41,18 +41,6 @@ func (s *SqlStore) CreateStaticAddress(ctx context.Context, return s.baseDB.Queries.CreateStaticAddress(ctx, createArgs) } -// GetStaticAddress retrieves static address parameters for a given pkScript. -func (s *SqlStore) GetStaticAddress(ctx context.Context, - pkScript []byte) (*Parameters, error) { - - staticAddress, err := s.baseDB.Queries.GetStaticAddress(ctx, pkScript) - if err != nil { - return nil, err - } - - return s.toAddressParameters(staticAddress) -} - // GetAllStaticAddresses returns all address known to the server. func (s *SqlStore) GetAllStaticAddresses(ctx context.Context) ([]*Parameters, error) { @@ -75,11 +63,6 @@ func (s *SqlStore) GetAllStaticAddresses(ctx context.Context) ([]*Parameters, return result, nil } -// Close closes the database connection. -func (s *SqlStore) Close() { - s.baseDB.DB.Close() -} - // toAddressParameters transforms a database representation of a static address // to an AddressParameters struct. func (s *SqlStore) toAddressParameters(row sqlc.StaticAddress) ( diff --git a/staticaddr/deposit/manager.go b/staticaddr/deposit/manager.go index c2d02083..af882030 100644 --- a/staticaddr/deposit/manager.go +++ b/staticaddr/deposit/manager.go @@ -8,13 +8,10 @@ import ( "sync" "time" - "github.com/btcsuite/btcd/chaincfg" "github.com/btcsuite/btcd/txscript" "github.com/btcsuite/btcd/wire" "github.com/lightninglabs/lndclient" - "github.com/lightninglabs/loop" "github.com/lightninglabs/loop/fsm" - staticaddressrpc "github.com/lightninglabs/loop/swapserverrpc" "github.com/lightningnetwork/lnd/lnrpc/walletrpc" "github.com/lightningnetwork/lnd/lnwallet" ) @@ -40,17 +37,10 @@ const ( // ManagerConfig holds the configuration for the address manager. type ManagerConfig struct { - // AddressClient is the client that communicates with the loop server - // to manage static addresses. - AddressClient staticaddressrpc.StaticAddressServerClient - // AddressManager is the address manager that is used to fetch static // address parameters. AddressManager AddressManager - // SwapClient provides loop rpc functionality. - SwapClient *loop.Client - // Store is the database store that is used to store static address // related records. Store Store @@ -59,10 +49,6 @@ type ManagerConfig struct { // lnd's wallet. WalletKit lndclient.WalletKitClient - // ChainParams is the chain configuration(mainnet, testnet...) this - // manager uses. - ChainParams *chaincfg.Params - // ChainNotifier is the chain notifier that is used to listen for new // blocks. ChainNotifier lndclient.ChainNotifierClient diff --git a/staticaddr/deposit/manager_test.go b/staticaddr/deposit/manager_test.go index 61079142..659238ac 100644 --- a/staticaddr/deposit/manager_test.go +++ b/staticaddr/deposit/manager_test.go @@ -345,11 +345,9 @@ func newManagerTestContext(t *testing.T) *ManagerTestContext { ) cfg := &ManagerConfig{ - AddressClient: mockStaticAddressClient, AddressManager: mockAddressManager, Store: mockStore, WalletKit: mockLnd.WalletKit, - ChainParams: mockLnd.ChainParams, ChainNotifier: mockChainNotifier, Signer: mockLnd.Signer, } diff --git a/staticaddr/loopin/manager.go b/staticaddr/loopin/manager.go index 410eaba2..fcae218c 100644 --- a/staticaddr/loopin/manager.go +++ b/staticaddr/loopin/manager.go @@ -134,13 +134,8 @@ type Manager struct { // has been canceled. exitChan chan struct{} - // errChan forwards errors from the loop-in manager to the server. - errChan chan error - // currentHeight stores the currently best known block height. currentHeight atomic.Uint32 - - activeLoopIns map[lntypes.Hash]*FSM } // NewManager creates a new deposit withdrawal manager. @@ -154,8 +149,6 @@ func NewManager(cfg *Config, currentHeight uint32) (*Manager, error) { cfg: cfg, newLoopInChan: make(chan *newSwapRequest), exitChan: make(chan struct{}), - errChan: make(chan error), - activeLoopIns: make(map[lntypes.Hash]*FSM), } m.currentHeight.Store(currentHeight) @@ -566,19 +559,12 @@ func (m *Manager) recoverLoopIns(ctx context.Context) error { } // Create a state machine for a given loop-in. - var ( - recovery = true - fsm *FSM - ) - fsm, err = NewFSM(ctx, loopIn, m.cfg, recovery) + recovery := true + fsm, err := NewFSM(ctx, loopIn, m.cfg, recovery) if err != nil { return err } - // Add the FSM to the active loop-ins map before sending - // the recover event to avoid a data race. - m.activeLoopIns[loopIn.SwapHash] = fsm - // Send the OnRecover event to the state machine. go func() { err := fsm.SendEvent(ctx, OnRecover, nil) @@ -825,8 +811,6 @@ func (m *Manager) startLoopInFsm(ctx context.Context, return nil, err } - m.activeLoopIns[loopIn.SwapHash] = loopInFsm - return loopIn, nil } diff --git a/staticaddr/openchannel/interface.go b/staticaddr/openchannel/interface.go index e8e20691..73010a2b 100644 --- a/staticaddr/openchannel/interface.go +++ b/staticaddr/openchannel/interface.go @@ -6,24 +6,11 @@ import ( "github.com/btcsuite/btcd/btcutil" "github.com/btcsuite/btcd/wire" "github.com/lightninglabs/loop/fsm" - "github.com/lightninglabs/loop/staticaddr/address" "github.com/lightninglabs/loop/staticaddr/deposit" - "github.com/lightninglabs/loop/staticaddr/script" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnwallet/chainfee" ) -// AddressManager handles fetching of address parameters. -type AddressManager interface { - // GetStaticAddressParameters returns the static address parameters. - GetStaticAddressParameters(ctx context.Context) (*address.Parameters, - error) - - // GetStaticAddress returns the deposit address for the given - // client and server public keys. - GetStaticAddress(ctx context.Context) (*script.StaticAddress, error) -} - type DepositManager interface { // AllOutpointsActiveDeposits returns all deposits that are in the // given state. If the state filter is fsm.StateTypeNone, all deposits diff --git a/staticaddr/openchannel/manager.go b/staticaddr/openchannel/manager.go index a9d4255f..cb276cfc 100644 --- a/staticaddr/openchannel/manager.go +++ b/staticaddr/openchannel/manager.go @@ -19,7 +19,6 @@ import ( "github.com/lightninglabs/loop/staticaddr/deposit" "github.com/lightninglabs/loop/staticaddr/staticutil" "github.com/lightninglabs/loop/staticaddr/withdraw" - serverrpc "github.com/lightninglabs/loop/swapserverrpc" "github.com/lightningnetwork/lnd/lnrpc" "github.com/lightningnetwork/lnd/lnwallet/chainfee" "github.com/lightningnetwork/lnd/lnwallet/chanfunding" @@ -48,14 +47,6 @@ var ( // Config is the configuration struct for the open channel manager. type Config struct { - // Server is the client that calls the swap server rpcs to negotiate - // static address withdrawals. - Server serverrpc.StaticAddressServerClient - - // AddressManager gives the withdrawal manager access to static address - // parameters. - AddressManager AddressManager - // DepositManager gives the withdrawal manager access to the deposits // enabling it to create and manage withdrawals. DepositManager DepositManager @@ -72,13 +63,6 @@ type Config struct { // manager uses. ChainParams *chaincfg.Params - // ChainNotifier is the chain notifier that is used to listen for new - // blocks. - ChainNotifier lndclient.ChainNotifierClient - - // Signer is the signer client that is used to sign transactions. - Signer lndclient.SignerClient - // LightningClient is the lnd client that is used to open channels. LightningClient lndclient.LightningClient } @@ -104,9 +88,6 @@ type Manager struct { // exitChan signals subroutines that the open channel is exiting. exitChan chan struct{} - - // errChan forwards errors from the open channel to the server. - errChan chan error } // NewManager creates a new manager instance. @@ -115,7 +96,6 @@ func NewManager(cfg *Config) *Manager { cfg: cfg, exitChan: make(chan struct{}), newOpenChannelRequestChan: make(chan newOpenChannelRequest), - errChan: make(chan error), } return m diff --git a/staticaddr/withdraw/interface.go b/staticaddr/withdraw/interface.go index 065a6f8d..da79cf5a 100644 --- a/staticaddr/withdraw/interface.go +++ b/staticaddr/withdraw/interface.go @@ -10,18 +10,6 @@ import ( "github.com/lightninglabs/loop/staticaddr/script" ) -// Store is the database interface that is used to store and retrieve -// static address withdrawals. -type Store interface { - // CreateWithdrawal inserts a withdrawal into the store. - CreateWithdrawal(ctx context.Context, tx *wire.MsgTx, - confirmationHeight uint32, deposits []*deposit.Deposit, - changePkScript []byte) error - - // GetAllWithdrawals retrieves all withdrawals. - GetAllWithdrawals(ctx context.Context) ([]Withdrawal, error) -} - // AddressManager handles fetching of address parameters. type AddressManager interface { // GetStaticAddressParameters returns the static address parameters. diff --git a/staticaddr/withdraw/manager.go b/staticaddr/withdraw/manager.go index c5b36430..c9f8ab98 100644 --- a/staticaddr/withdraw/manager.go +++ b/staticaddr/withdraw/manager.go @@ -129,9 +129,6 @@ type Manager struct { // exitChan signals subroutines that the withdrawal manager is exiting. exitChan chan struct{} - // errChan forwards errors from the withdrawal manager to the server. - errChan chan error - // initiationHeight stores the currently best known block height. initiationHeight atomic.Uint32 @@ -152,7 +149,6 @@ func NewManager(cfg *ManagerConfig, currentHeight uint32) (*Manager, error) { finalizedWithdrawalTxns: make(map[chainhash.Hash]*wire.MsgTx), exitChan: make(chan struct{}), newWithdrawalRequestChan: make(chan newWithdrawalRequest), - errChan: make(chan error), } m.initiationHeight.Store(currentHeight)