staticaddr: add nil checks for withdrawals

This commit is contained in:
Slyghtning 2025-09-08 17:22:45 +02:00
parent 1f8f282b00
commit d0670f109b
No known key found for this signature in database
GPG key ID: F82D456EA023C9BF

View file

@ -46,6 +46,11 @@ var (
ErrMissingPreviousWithdrawn = errors.New("can't bump fee for subset " +
"of clustered deposits")
// ErrMissingFinalizedTx is returned if previously withdrawn deposits
// don't have a finalized withdrawal tx attached.
ErrMissingFinalizedTx = errors.New("deposit does not have a " +
"finalized withdrawal tx, can't bump fee")
// MinConfs is the minimum number of confirmations we require for a
// deposit to be considered withdrawn.
MinConfs int32 = 3
@ -330,6 +335,14 @@ func (m *Manager) WithdrawDeposits(ctx context.Context,
return "", "", ErrWithdrawingMixedDeposits
}
// Ensure that all previously withdrawn deposits reference their
// finalized withdrawal tx.
for _, d := range deposits {
if d.FinalizedWithdrawalTx == nil {
return "", "", ErrMissingFinalizedTx
}
}
// If republishing of an existing withdrawal is requested we
// ensure that all deposits remain clustered in the context of
// the same withdrawal tx. We do this by checking that they have