diff --git a/staticaddr/deposit/fsm.go b/staticaddr/deposit/fsm.go index 1fad4dc20..0a78b86ca 100644 --- a/staticaddr/deposit/fsm.go +++ b/staticaddr/deposit/fsm.go @@ -300,11 +300,11 @@ func (f *FSM) DepositStatesV0() fsm.States { // OnWithdrawInitiated is sent if a fee bump was // requested and the withdrawal was republished. OnWithdrawInitiated: Withdrawing, - // Upon recovery, we go back to the Deposited - // state. The deposit by then has a withdrawal - // address stamped to it which will cause it to - // transition into the Withdrawing state again. - OnRecover: Deposited, + + // Upon recovery, we remain in the Withdrawing + // state so that the withdrawal manager can + // reinstate the withdrawal. + OnRecover: Withdrawing, // A precondition for the Withdrawing state is // that the withdrawal transaction has been diff --git a/staticaddr/withdraw/manager.go b/staticaddr/withdraw/manager.go index 408d0338e..1ffae0284 100644 --- a/staticaddr/withdraw/manager.go +++ b/staticaddr/withdraw/manager.go @@ -214,13 +214,11 @@ func (m *Manager) Run(ctx context.Context, initChan chan struct{}) error { } func (m *Manager) recoverWithdrawals(ctx context.Context) error { - // To recover withdrawals we skim through all active deposits and check - // if they have a withdrawal address set. For the ones that do we - // cluster those with equal withdrawal addresses and kick-off - // their withdrawal. Each cluster represents a separate withdrawal - // intent by the user. - activeDeposits, err := m.cfg.DepositManager.GetActiveDepositsInState( - deposit.Deposited, + // To recover withdrawals we cluster those with equal withdrawal + // addresses and publish their withdrawal tx. Each cluster represents a + // separate withdrawal intent by the user. + withdrawingDeposits, err := m.cfg.DepositManager.GetActiveDepositsInState( + deposit.Withdrawing, ) if err != nil { return err @@ -229,7 +227,7 @@ func (m *Manager) recoverWithdrawals(ctx context.Context) error { // Group the deposits by their finalized withdrawal transaction. depositsByWithdrawalTx := make(map[chainhash.Hash][]*deposit.Deposit) hash2tx := make(map[chainhash.Hash]*wire.MsgTx) - for _, d := range activeDeposits { + for _, d := range withdrawingDeposits { withdrawalTx := d.FinalizedWithdrawalTx if withdrawalTx == nil { continue