contractcourt: add aux chan closer to chain watcher
What changed, and why it matters
This commit adds a new optional hook (AuxChanCloser) that lets external code finalize cooperative channel closes. It is purely an infrastructure/plumbing change: it defines an interface, adds a config field, and passes that field into the chain watcher. There is no actual implementation of the closer logic, no change to existing security behavior, and no bug fix or vulnerability patch visible in the diff.
No security action required. Review the eventual AuxChanCloser implementation when it lands to ensure FinalizeClose handles the close transaction and auxiliary close description safely.
Security signals we found
No security-relevant behavior change in the diff
New optional interface only; no implementation provided
No input validation, cryptography, or state-machine logic altered
No references to CVEs, security issues, or bug fixes in commit message
Evidence from the diff
The patch introduces an AuxChanCloser interface with a FinalizeClose method, adds it to ChainArbitratorConfig and chainWatcherConfig, and wires it through WatchNewChannel and loadOpenChannels. It is an extension point for future cooperative-close finalization, not a functional change to close handling. No logic is modified; no existing code path behavior changes.
Changed components
contractcourt/chain_arbitrator.gocontractcourt/chain_watcher.goInspect captured patch +18 / −0
diff --git a/contractcourt/chain_arbitrator.go b/contractcourt/chain_arbitrator.go
index 05eb46a..2e5f542 100644
--- a/contractcourt/chain_arbitrator.go
+++ b/contractcourt/chain_arbitrator.go
@@ -230,6 +230,10 @@ type ChainArbitratorConfig struct {
// AuxResolver is an optional interface that can be used to modify the
// way contracts are resolved.
AuxResolver fn.Option[lnwallet.AuxContractResolver]
+
+ // AuxCloser is an optional interface that can be used to finalize
+ // cooperative channel closes.
+ AuxCloser fn.Option[AuxChanCloser]
}
// ChainArbitrator is a sub-system that oversees the on-chain resolution of all
@@ -1138,6 +1142,7 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error
extractStateNumHint: lnwallet.GetStateNumHint,
auxLeafStore: c.cfg.AuxLeafStore,
auxResolver: c.cfg.AuxResolver,
+ auxCloser: c.cfg.AuxCloser,
},
)
if err != nil {
@@ -1315,6 +1320,7 @@ func (c *ChainArbitrator) loadOpenChannels() error {
extractStateNumHint: lnwallet.GetStateNumHint,
auxLeafStore: c.cfg.AuxLeafStore,
auxResolver: c.cfg.AuxResolver,
+ auxCloser: c.cfg.AuxCloser,
},
)
if err != nil {
diff --git a/contractcourt/chain_watcher.go b/contractcourt/chain_watcher.go
index 082b472..6f33c0f 100644
--- a/contractcourt/chain_watcher.go
+++ b/contractcourt/chain_watcher.go
@@ -24,6 +24,7 @@ import (
"github.com/lightningnetwork/lnd/lntypes"
"github.com/lightningnetwork/lnd/lnutils"
"github.com/lightningnetwork/lnd/lnwallet"
+ "github.com/lightningnetwork/lnd/lnwallet/types"
"github.com/lightningnetwork/lnd/lnwire"
)
@@ -37,6 +38,14 @@ const (
maxCommitPointPollTimeout = 10 * time.Minute
)
+// AuxChanCloser is used to allow an external caller to finalize a cooperative
+// channel close.
+type AuxChanCloser interface {
+ // FinalizeClose is called after the close transaction has been agreed
+ // upon and confirmed.
+ FinalizeClose(desc types.AuxCloseDesc, closeTx *wire.MsgTx) error
+}
+
// LocalUnilateralCloseInfo encapsulates all the information we need to act on
// a local force close that gets confirmed.
type LocalUnilateralCloseInfo struct {
@@ -229,6 +238,9 @@ type chainWatcherConfig struct {
// auxResolver is used to supplement contract resolution.
auxResolver fn.Option[lnwallet.AuxContractResolver]
+
+ // auxCloser is used to finalize cooperative closes.
+ auxCloser fn.Option[AuxChanCloser]
}
// chainWatcher is a system that's assigned to every active channel. The duty
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.