staticaddr: simplify withdrawal fsm transition

previously upon recovery, a withdrawing deposit was
first transitioned into the Deposited state by the
deposit manager, and then again into the Withdrawing
state by the withdrawal manager. The first transition
is unnecessary, so we just remain in the Withdrawing
state upon recovery.
This commit is contained in:
Slyghtning 2025-07-02 15:05:51 +02:00
parent 1104e928ff
commit 412fe7ffd9
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF
2 changed files with 11 additions and 13 deletions

View file

@ -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

View file

@ -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