contractcourt: add aux chan closer to chain watcher

This commit is contained in:
George Tsagkarelis committed 2025-12-04 12:17:40 +01:00
1 parent e12008517e
commit fd772d45b8
2 files changed
+18

No files matched your search

+6
View File
@@ -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 {
+12
View File
@@ -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