peer: send out a notification after the 1st conf, then wait for the rest

We wnt to add better handling, but not break any UIs or wallets. So
we'll continue to send out a notification after a single confirmation,
then send another after things are fully confirmed.
This commit is contained in:
Olaoluwa Osuntokun committed 2026-01-15 16:22:26 -08:00
1 parent c0f48d23b4
commit 6553b61aa4
1 file changed
+15 -6
+15 -6
View File
@@ -4471,14 +4471,22 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
localOut := chanCloser.LocalCloseOutput() localOut := chanCloser.LocalCloseOutput()
remoteOut := chanCloser.RemoteCloseOutput() remoteOut := chanCloser.RemoteCloseOutput()
auxOut := chanCloser.AuxOutputs() auxOut := chanCloser.AuxOutputs()
// Determine the number of confirmations to wait before
// signaling a successful cooperative close, scaled by
// channel capacity (see CloseConfsForCapacity).
numConfs := lnwallet.CloseConfsForCapacity(chanCloser.Channel().Capacity)
// Determine the number of confirmations to wait before signaling a
// successful cooperative close, scaled by channel capacity (see
// CloseConfsForCapacity). Check if we have a config override for
// testing purposes.
chanCapacity := chanCloser.Channel().Capacity
numConfs := p.cfg.ChannelCloseConfs.UnwrapOrFunc(func() uint32 {
// No override, use normal capacity-based scaling.
return lnwallet.CloseConfsForCapacity(chanCapacity)
})
// Register for full confirmation to send the final update.
closeScript := closingTx.TxOut[0].PkScript
go WaitForChanToClose( go WaitForChanToClose(
chanCloser.NegotiationHeight(), notifier, errChan, chanCloser.NegotiationHeight(), notifier, errChan,
&chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, numConfs, func() { &chanPoint, &closingTxid, closeScript, numConfs, func() {
// Respond to the local subsystem which requested the // Respond to the local subsystem which requested the
// channel closure. // channel closure.
if closeReq != nil { if closeReq != nil {
@@ -4501,7 +4509,8 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
// the function, then it will be sent over the errChan. // the function, then it will be sent over the errChan.
func WaitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier, func WaitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier,
errChan chan error, chanPoint *wire.OutPoint, errChan chan error, chanPoint *wire.OutPoint,
closingTxID *chainhash.Hash, closeScript []byte, numConfs uint32, cb func()) { closingTxID *chainhash.Hash, closeScript []byte, numConfs uint32,
cb func()) {
peerLog.Infof("Waiting for confirmation of close of ChannelPoint(%v) "+ peerLog.Infof("Waiting for confirmation of close of ChannelPoint(%v) "+
"with txid: %v", chanPoint, closingTxID) "with txid: %v", chanPoint, closingTxID)