Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
34d2574
lnwallet: add new helper functions to scale confirmations based on amt
Roasbeef Sep 4, 2025
ed0094c
server: use new FundingConfsForAmounts helper func
Roasbeef Sep 4, 2025
531cdd0
lnwallet: define helper func to coop close conf scaling
Roasbeef Sep 4, 2025
7c34188
lnwallet: add tests for new conf scaling helper funcs
Roasbeef Sep 4, 2025
33a26b5
peer+rpcserver: use new conf scaling for notifications
Roasbeef Sep 4, 2025
af7f343
lncfg: add new dev config option for scaling channel close confs
Roasbeef Oct 1, 2025
34db0ad
multi: add new ChannelCloseConfs param, thread thru as needed
Roasbeef Oct 1, 2025
11649bb
peer: send out a notification after the 1st conf, then wait for the rest
Roasbeef Oct 1, 2025
1354e8e
contractcourt: update close logic to handle re-orgs of depth n-1, whe…
Roasbeef Oct 1, 2025
86bd2ee
lntest: add new wait for conf helper method to ChainNotifier
Roasbeef Oct 1, 2025
5608bd5
contractcourt: add new chainWatcherTestHarness
Roasbeef Oct 1, 2025
f1a8a54
contractcourt: update existing chain watcher tests due to new logic
Roasbeef Oct 1, 2025
1b67863
contractcourt: add unit tests for rbf re-org cases
Roasbeef Oct 1, 2025
07c08bf
contractcourt: add generic close re-org tests
Roasbeef Oct 1, 2025
de3ed9c
itest: add new coop close rbf itest
Roasbeef Oct 1, 2025
80be53b
lnrpc/devrpc: add new TriggerSweep dev rpc command
Roasbeef Oct 11, 2025
1b95fdf
sweeper: implement TriggerSweep
Roasbeef Oct 11, 2025
b578431
lntest: add new utilities to wait for mempool/block inclusion, then t…
Roasbeef Oct 11, 2025
08ac7b6
itest: update itests to use new *WithSweep helper assertions
Roasbeef Oct 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions peer/brontide.go
Original file line number Diff line number Diff line change
Expand Up @@ -4444,14 +4444,19 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
localOut := chanCloser.LocalCloseOutput()
remoteOut := chanCloser.RemoteCloseOutput()
auxOut := chanCloser.AuxOutputs()
go WaitForChanToClose(
chanCloser.NegotiationHeight(), notifier, errChan,
&chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, func() {
// Respond to the local subsystem which requested the
// channel closure.
if closeReq != nil {
closeReq.Updates <- &ChannelCloseUpdate{
ClosingTxid: closingTxid[:],
// Determine the number of confirmations to wait before
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the formatting isn't quite right

// signaling a successful cooperative close, scaled by
// channel capacity (see CloseConfsForCapacity).
numConfs := lnwallet.CloseConfsForCapacity(chanCloser.Channel().Capacity)

go WaitForChanToClose(
chanCloser.NegotiationHeight(), notifier, errChan,
&chanPoint, &closingTxid, closingTx.TxOut[0].PkScript, numConfs, func() {
// Respond to the local subsystem which requested the
// channel closure.
if closeReq != nil {
closeReq.Updates <- &ChannelCloseUpdate{
ClosingTxid: closingTxid[:],
Success: true,
LocalCloseOutput: localOut,
RemoteCloseOutput: remoteOut,
Expand All @@ -4468,16 +4473,15 @@ func (p *Brontide) finalizeChanClosure(chanCloser *chancloser.ChanCloser) {
// finally the callback will be executed. If any error is encountered within
// 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, cb func()) {
errChan chan error, chanPoint *wire.OutPoint,
closingTxID *chainhash.Hash, closeScript []byte, numConfs uint32, cb func()) {

peerLog.Infof("Waiting for confirmation of close of ChannelPoint(%v) "+
"with txid: %v", chanPoint, closingTxID)

// TODO(roasbeef): add param for num needed confs
confNtfn, err := notifier.RegisterConfirmationsNtfn(
closingTxID, closeScript, 1, bestHeight,
)
confNtfn, err := notifier.RegisterConfirmationsNtfn(
closingTxID, closeScript, numConfs, bestHeight,
)
if err != nil {
if errChan != nil {
errChan <- err
Expand Down
16 changes: 8 additions & 8 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2800,14 +2800,14 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,

errChan = make(chan error, 1)
notifier := r.server.cc.ChainNotifier
go peer.WaitForChanToClose(
uint32(bestHeight), notifier, errChan, chanPoint,
&closingTxid, closingTx.TxOut[0].PkScript, func() {
// Respond to the local subsystem which
// requested the channel closure.
updateChan <- &peer.ChannelCloseUpdate{
ClosingTxid: closingTxid[:],
Success: true,
go peer.WaitForChanToClose(
uint32(bestHeight), notifier, errChan, chanPoint,
&closingTxid, closingTx.TxOut[0].PkScript, 1, func() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm should we also derive and pass the numConfs here?

// Respond to the local subsystem which
// requested the channel closure.
updateChan <- &peer.ChannelCloseUpdate{
ClosingTxid: closingTxid[:],
Success: true,
// Force closure transactions don't have
// additional local/remote outputs.
}
Expand Down