staticaddr/deposit: serialize deposit reconciliation

Guard reconcileDeposits with a dedicated mutex.

Polling and block-driven reconciliation can overlap, so serialize the
path before it updates confirmation data and active FSM state.
This commit is contained in:
Slyghtning 2026-07-01 12:06:25 +02:00
parent 38dce3685f
commit 77d9335da2
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF

View file

@ -68,6 +68,10 @@ type Manager struct {
// mu guards access to the activeDeposits map.
mu sync.Mutex
// reconcileMu serializes deposit reconciliation so new deposits are
// discovered and retained exactly once per outpoint.
reconcileMu sync.Mutex
// activeDeposits contains all the active static address outputs.
activeDeposits map[wire.OutPoint]*FSM
@ -250,6 +254,9 @@ func (m *Manager) pollDeposits(ctx context.Context) {
// far. It picks the newly identified deposits and starts a state machine per
// deposit to track its progress.
func (m *Manager) reconcileDeposits(ctx context.Context) error {
m.reconcileMu.Lock()
defer m.reconcileMu.Unlock()
log.Tracef("Reconciling new deposits...")
utxos, err := m.cfg.AddressManager.ListUnspent(