peer+rpcserver: use new conf scaling for notifications

This commit is contained in:
Olaoluwa Osuntokun committed 2026-01-15 16:22:26 -08:00
1 parent 4f43717d4f
commit 931b54e848
2 files changed
+16 -5

No files matched your search

+8 -4
View File
@@ -4465,9 +4465,14 @@ 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)
go WaitForChanToClose( go WaitForChanToClose(
chanCloser.NegotiationHeight(), notifier, errChan, chanCloser.NegotiationHeight(), notifier, errChan,
&chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, func() { &chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, 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 {
@@ -4490,14 +4495,13 @@ 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, 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)
// TODO(roasbeef): add param for num needed confs
confNtfn, err := notifier.RegisterConfirmationsNtfn( confNtfn, err := notifier.RegisterConfirmationsNtfn(
closingTxID, closeScript, 1, bestHeight, closingTxID, closeScript, numConfs, bestHeight,
) )
if err != nil { if err != nil {
if errChan != nil { if errChan != nil {
+8 -1
View File
@@ -2845,9 +2845,16 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
errChan = make(chan error, 1) errChan = make(chan error, 1)
notifier := r.server.cc.ChainNotifier notifier := r.server.cc.ChainNotifier
// For force closes, we notify the RPC client immediately after
// 1 confirmation. The actual security-critical confirmation
// waiting is handled by the channel arbitrator.
numConfs := uint32(1)
go peer.WaitForChanToClose( go peer.WaitForChanToClose(
uint32(bestHeight), notifier, errChan, chanPoint, uint32(bestHeight), notifier, errChan, chanPoint,
&closingTxid, closingTx.TxOut[0].PkScript, func() { &closingTxid, closingTx.TxOut[0].PkScript, numConfs,
func() {
// Respond to the local subsystem which // Respond to the local subsystem which
// requested the channel closure. // requested the channel closure.
updateChan <- &peer.ChannelCloseUpdate{ updateChan <- &peer.ChannelCloseUpdate{