Commit e33e525
committed
staticaddr/withdraw: add retry and reorg handling for withdrawals
This commit fixes three related issues in the withdrawal manager:
1. No retry when RegisterSpendNtfn/RegisterConfirmationsNtfn fails
2. No handling for reorgs (tx confirmed then reorged out)
3. State not persisted before handleWithdrawal, causing recovery failures
Changes:
- Reorder state persistence to happen BEFORE handleWithdrawal so
recoverWithdrawals can find deposits in Withdrawing state on restart
- Add retry-on-next-block for registration failures using block
notifications
- Add reorg detection via lndclient.WithReOrgChan for both spend and
confirmation notifications
- On reorg after spend detection, return to spend watching (not just
re-register for confirmations) since the spend tx may be invalidated
- Make handleWithdrawal async/best-effort since tx is already published
- Added appropriate tests in manager_test.go
Fixes issue #1087
Signed-off-by: kaldun-tech <tsmereka@protonmail.com>1 parent 62177f9 commit e33e525
3 files changed
Lines changed: 807 additions & 97 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
23 | 32 | | |
0 commit comments