Skip to content

Commit 58fae7d

Browse files
committed
contractcourt: add aux chan closer to chain watcher
Due to a circular dependency issue, we cannot directly import these definitions from lnwallet/chancloser. So we'll redefine the types we need and define a slim interface around the aux closer, which contains exactly the functionality that we'll want to use here.
1 parent f1cac8e commit 58fae7d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

contractcourt/chain_arbitrator.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ type ChainArbitratorConfig struct {
230230
// AuxResolver is an optional interface that can be used to modify the
231231
// way contracts are resolved.
232232
AuxResolver fn.Option[lnwallet.AuxContractResolver]
233+
234+
// AuxCloser is an optional interface that can be used to finalize
235+
// cooperative channel closes.
236+
AuxCloser fn.Option[AuxChanCloser]
233237
}
234238

235239
// 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
11381142
extractStateNumHint: lnwallet.GetStateNumHint,
11391143
auxLeafStore: c.cfg.AuxLeafStore,
11401144
auxResolver: c.cfg.AuxResolver,
1145+
auxCloser: c.cfg.AuxCloser,
11411146
},
11421147
)
11431148
if err != nil {
@@ -1315,6 +1320,7 @@ func (c *ChainArbitrator) loadOpenChannels() error {
13151320
extractStateNumHint: lnwallet.GetStateNumHint,
13161321
auxLeafStore: c.cfg.AuxLeafStore,
13171322
auxResolver: c.cfg.AuxResolver,
1323+
auxCloser: c.cfg.AuxCloser,
13181324
},
13191325
)
13201326
if err != nil {

contractcourt/chain_watcher.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/lightningnetwork/lnd/lntypes"
2525
"github.com/lightningnetwork/lnd/lnutils"
2626
"github.com/lightningnetwork/lnd/lnwallet"
27+
"github.com/lightningnetwork/lnd/lnwallet/types"
2728
"github.com/lightningnetwork/lnd/lnwire"
2829
)
2930

@@ -37,6 +38,14 @@ const (
3738
maxCommitPointPollTimeout = 10 * time.Minute
3839
)
3940

41+
// AuxChanCloser is used to allow an external caller to finalize a cooperative
42+
// channel close.
43+
type AuxChanCloser interface {
44+
// FinalizeClose is called after the close transaction has been agreed
45+
// upon and confirmed.
46+
FinalizeClose(desc types.AuxCloseDesc, closeTx *wire.MsgTx) error
47+
}
48+
4049
// LocalUnilateralCloseInfo encapsulates all the information we need to act on
4150
// a local force close that gets confirmed.
4251
type LocalUnilateralCloseInfo struct {
@@ -229,6 +238,9 @@ type chainWatcherConfig struct {
229238

230239
// auxResolver is used to supplement contract resolution.
231240
auxResolver fn.Option[lnwallet.AuxContractResolver]
241+
242+
// auxCloser is used to finalize cooperative closes.
243+
auxCloser fn.Option[AuxChanCloser]
232244
}
233245

234246
// chainWatcher is a system that's assigned to every active channel. The duty

0 commit comments

Comments
 (0)