chainntnfs: retry failed historical rescans in the backends
When a historical conf or spend rescan fails, all three chain notifier backends log the error and return without ever reporting back to the TxNotifier (bitcoindnotify/bitcoind.go, btcdnotify/btcd.go, neutrinonotify/neutrino.go, several of which still carry a TODO(wilmer): add retry logic if rescan fails?). Neutrino's GetUtxo path does the same for spends, and bitcoind's outpoint spend path returns early when the funding tx is found but unconfirmed.
Since #11183, a request set counts its in-flight scans, so a scan that never reports keeps the set in rescanPending for the life of the process. That's fail safe: the hint can't advance past the range that was never verified, and since the persisted hint's origin sits above that range, the next restart scans it again. Details found by any other scan, or at tip, are still dispatched. What we lose is the event itself for this run: a subscriber whose confirmation or spend only lies in the failed range won't be notified until lnd restarts.
In this issue, we want the backends to retry failed historical scans rather than dropping them. Roughly:
- Retry the scan with backoff until it succeeds or the notifier quits, so
UpdateConfDetails/UpdateSpendDetailsis always eventually called and the pending count always unwinds. - Distinguish errors that won't resolve on retry (e.g. a pruned block bitcoind can't fetch) from transient RPC or peer errors, and log loudly for the former instead of spinning.
- Cover the early-return paths that never report at all (bitcoind's unconfirmed funding tx case, btcd's
RescanAsyncspends, Neutrino's script spend rewind), since those also leave a pending scan behind.
The async state machine model added in #11183 (TestTxNotifierAsyncModelProperty) already has a FailScan action. Once retries exist, the model can treat a failed scan as delayed instead of lost, and drop the carve-out in its liveness check for requests with a failed scan.
Source: lightningnetwork/lnd