contractcourt+lnd: watch for preimage reveal in mempool

This commit extends the current htlc timeout resolver to also watch for
preimage spend in mempool for a full node backend.

If mempool enabled, the resolver will watch the spend of the htlc output
in mempool and blocks **concurrently**, as if they are independent.

Ideally, a transaction will first appear in mempool then in a block.
However, there's no guarantee it will appear in **our** mempool since
there's no global mempool, thus we need to watch the spend in two places
in case it doesn't go through our mempool.

The current design favors the spend event found in blocks, that is, when
the tx is confirmed, we'd abort the monitoring and conitnue since the
outpoint cannot be double spent and re-appear in mempool again. This is
not true in the rare case of reorg, and we will handle reorg seperately.
This commit is contained in:
yyforyongyu
2023-04-06 03:40:26 +08:00
parent 7ef8072724
commit 556c38fefd
3 changed files with 182 additions and 2 deletions

View File

@ -1148,6 +1148,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
},
PreimageDB: s.witnessBeacon,
Notifier: cc.ChainNotifier,
Mempool: cc.MempoolNotifier,
Signer: cc.Wallet.Cfg.Signer,
FeeEstimator: cc.FeeEstimator,
ChainIO: cc.ChainIO,