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:
1 parent
c0f48d23b4
commit
6553b61aa4
1 file changed
+15
-6
+15
-6
@@ -4471,14 +4471,22 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
|
||||
localOut := chanCloser.LocalCloseOutput()
|
||||
remoteOut := chanCloser.RemoteCloseOutput()
|
||||
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(
|
||||
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
|
||||
// channel closure.
|
||||
if closeReq != nil {
|
||||
@@ -4501,7 +4509,8 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
|
||||
// the function, then it will be sent over the errChan.
|
||||
func WaitForChanToClose(bestHeight uint32, notifier chainntnfs.ChainNotifier,
|
||||
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) "+
|
||||
"with txid: %v", chanPoint, closingTxID)
|
||||
|
||||
Reference in new issue
Block a user