contractcourt: add aux chan closer to chain watcher
This commit is contained in:
2 files changed
+18
No files matched your search
@@ -230,6 +230,10 @@ type ChainArbitratorConfig struct {
|
|||||||
// AuxResolver is an optional interface that can be used to modify the
|
// AuxResolver is an optional interface that can be used to modify the
|
||||||
// way contracts are resolved.
|
// way contracts are resolved.
|
||||||
AuxResolver fn.Option[lnwallet.AuxContractResolver]
|
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
|
// 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,
|
extractStateNumHint: lnwallet.GetStateNumHint,
|
||||||
auxLeafStore: c.cfg.AuxLeafStore,
|
auxLeafStore: c.cfg.AuxLeafStore,
|
||||||
auxResolver: c.cfg.AuxResolver,
|
auxResolver: c.cfg.AuxResolver,
|
||||||
|
auxCloser: c.cfg.AuxCloser,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -1315,6 +1320,7 @@ func (c *ChainArbitrator) loadOpenChannels() error {
|
|||||||
extractStateNumHint: lnwallet.GetStateNumHint,
|
extractStateNumHint: lnwallet.GetStateNumHint,
|
||||||
auxLeafStore: c.cfg.AuxLeafStore,
|
auxLeafStore: c.cfg.AuxLeafStore,
|
||||||
auxResolver: c.cfg.AuxResolver,
|
auxResolver: c.cfg.AuxResolver,
|
||||||
|
auxCloser: c.cfg.AuxCloser,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lntypes"
|
"github.com/lightningnetwork/lnd/lntypes"
|
||||||
"github.com/lightningnetwork/lnd/lnutils"
|
"github.com/lightningnetwork/lnd/lnutils"
|
||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
|
"github.com/lightningnetwork/lnd/lnwallet/types"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -37,6 +38,14 @@ const (
|
|||||||
maxCommitPointPollTimeout = 10 * time.Minute
|
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
|
// LocalUnilateralCloseInfo encapsulates all the information we need to act on
|
||||||
// a local force close that gets confirmed.
|
// a local force close that gets confirmed.
|
||||||
type LocalUnilateralCloseInfo struct {
|
type LocalUnilateralCloseInfo struct {
|
||||||
@@ -229,6 +238,9 @@ type chainWatcherConfig struct {
|
|||||||
|
|
||||||
// auxResolver is used to supplement contract resolution.
|
// auxResolver is used to supplement contract resolution.
|
||||||
auxResolver fn.Option[lnwallet.AuxContractResolver]
|
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
|
// chainWatcher is a system that's assigned to every active channel. The duty
|
||||||
|
|||||||
Reference in new issue
Block a user