Skip to content

Commit 29209d5

Browse files
Roasbeefguggero
authored andcommitted
multi: hook up new aux interfaces
1 parent 21264d2 commit 29209d5

File tree

7 files changed

+57
-8
lines changed

7 files changed

+57
-8
lines changed

config_builder.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import (
5050
"github.com/lightningnetwork/lnd/rpcperms"
5151
"github.com/lightningnetwork/lnd/signal"
5252
"github.com/lightningnetwork/lnd/sqldb"
53+
"github.com/lightningnetwork/lnd/sweep"
5354
"github.com/lightningnetwork/lnd/walletunlocker"
5455
"github.com/lightningnetwork/lnd/watchtower"
5556
"github.com/lightningnetwork/lnd/watchtower/wtclient"
@@ -188,6 +189,10 @@ type AuxComponents struct {
188189
// modify the way a coop-close transaction is constructed.
189190
AuxChanCloser fn.Option[chancloser.AuxChanCloser]
190191

192+
// AuxSweeper is an optional interface that can be used to modify the
193+
// way sweep transaction are generated.
194+
AuxSweeper fn.Option[sweep.AuxSweeper]
195+
191196
// AuxContractResolver is an optional interface that can be used to
192197
// modify the way contracts are resolved.
193198
AuxContractResolver fn.Option[lnwallet.AuxContractResolver]

contractcourt/chain_arbitrator.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@ type ChainArbitratorConfig struct {
225225
// AuxSigner is an optional signer that can be used to sign auxiliary
226226
// leaves for certain custom channel types.
227227
AuxSigner fn.Option[lnwallet.AuxSigner]
228+
229+
// AuxResolver is an optional interface that can be used to modify the
230+
// way contracts are resolved.
231+
AuxResolver fn.Option[lnwallet.AuxContractResolver]
228232
}
229233

230234
// ChainArbitrator is a sub-system that oversees the on-chain resolution of all
@@ -314,6 +318,9 @@ func (a *arbChannel) NewAnchorResolutions() (*lnwallet.AnchorResolutions,
314318
a.c.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
315319
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
316320
})
321+
a.c.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
322+
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
323+
})
317324

318325
chanMachine, err := lnwallet.NewLightningChannel(
319326
a.c.cfg.Signer, channel, nil, chanOpts...,
@@ -367,6 +374,9 @@ func (a *arbChannel) ForceCloseChan() (*lnwallet.LocalForceCloseSummary, error)
367374
a.c.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
368375
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
369376
})
377+
a.c.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
378+
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
379+
})
370380

371381
// Finally, we'll force close the channel completing
372382
// the force close workflow.
@@ -581,6 +591,8 @@ func (c *ChainArbitrator) Start() error {
581591
isOurAddr: c.cfg.IsOurAddress,
582592
contractBreach: breachClosure,
583593
extractStateNumHint: lnwallet.GetStateNumHint,
594+
auxLeafStore: c.cfg.AuxLeafStore,
595+
auxResolver: c.cfg.AuxResolver,
584596
},
585597
)
586598
if err != nil {
@@ -1210,6 +1222,8 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error
12101222
)
12111223
},
12121224
extractStateNumHint: lnwallet.GetStateNumHint,
1225+
auxLeafStore: c.cfg.AuxLeafStore,
1226+
auxResolver: c.cfg.AuxResolver,
12131227
},
12141228
)
12151229
if err != nil {

funding/manager.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,10 @@ type Config struct {
558558
// AuxSigner is an optional signer that can be used to sign auxiliary
559559
// leaves for certain custom channel types.
560560
AuxSigner fn.Option[lnwallet.AuxSigner]
561+
562+
// AuxResolver is an optional interface that can be used to modify the
563+
// way contracts are resolved.
564+
AuxResolver fn.Option[lnwallet.AuxContractResolver]
561565
}
562566

563567
// Manager acts as an orchestrator/bridge between the wallet's
@@ -1090,6 +1094,9 @@ func (f *Manager) advanceFundingState(channel *channeldb.OpenChannel,
10901094
f.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
10911095
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
10921096
})
1097+
f.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
1098+
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
1099+
})
10931100

10941101
// We create the state-machine object which wraps the database state.
10951102
lnChannel, err := lnwallet.NewLightningChannel(

peer/brontide.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,10 @@ type Config struct {
396396
// leaves for certain custom channel types.
397397
AuxSigner fn.Option[lnwallet.AuxSigner]
398398

399+
// AuxResolver is an optional interface that can be used to modify the
400+
// way contracts are resolved.
401+
AuxResolver fn.Option[lnwallet.AuxContractResolver]
402+
399403
// PongBuf is a slice we'll reuse instead of allocating memory on the
400404
// heap. Since only reads will occur and no writes, there is no need
401405
// for any synchronization primitives. As a result, it's safe to share
@@ -999,15 +1003,21 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
9991003
}
10001004
}
10011005

1002-
// TODO(roasbeef): also make aux resolver here
1003-
10041006
var chanOpts []lnwallet.ChannelOpt
10051007
p.cfg.AuxLeafStore.WhenSome(func(s lnwallet.AuxLeafStore) {
10061008
chanOpts = append(chanOpts, lnwallet.WithLeafStore(s))
10071009
})
10081010
p.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
10091011
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
10101012
})
1013+
p.cfg.AuxResolver.WhenSome(
1014+
func(s lnwallet.AuxContractResolver) {
1015+
chanOpts = append(
1016+
chanOpts, lnwallet.WithAuxResolver(s),
1017+
)
1018+
},
1019+
)
1020+
10111021
lnChan, err := lnwallet.NewLightningChannel(
10121022
p.cfg.Signer, dbChan, p.cfg.SigPool, chanOpts...,
10131023
)
@@ -4255,6 +4265,9 @@ func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
42554265
p.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
42564266
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
42574267
})
4268+
p.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
4269+
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
4270+
})
42584271

42594272
// If not already active, we'll add this channel to the set of active
42604273
// channels, so we can look it up later easily according to its channel

server.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1114,10 +1114,11 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
11141114
)
11151115

11161116
s.txPublisher = sweep.NewTxPublisher(sweep.TxPublisherConfig{
1117-
Signer: cc.Wallet.Cfg.Signer,
1118-
Wallet: cc.Wallet,
1119-
Estimator: cc.FeeEstimator,
1120-
Notifier: cc.ChainNotifier,
1117+
Signer: cc.Wallet.Cfg.Signer,
1118+
Wallet: cc.Wallet,
1119+
Estimator: cc.FeeEstimator,
1120+
Notifier: cc.ChainNotifier,
1121+
AuxSweeper: s.implCfg.AuxSweeper,
11211122
})
11221123

11231124
s.sweeper = sweep.New(&sweep.UtxoSweeperConfig{
@@ -1135,6 +1136,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
11351136
Aggregator: aggregator,
11361137
Publisher: s.txPublisher,
11371138
NoDeadlineConfTarget: cfg.Sweeper.NoDeadlineConfTarget,
1139+
AuxSweeper: s.implCfg.AuxSweeper,
11381140
})
11391141

11401142
s.utxoNursery = contractcourt.NewUtxoNursery(&contractcourt.NurseryConfig{
@@ -1312,6 +1314,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
13121314
},
13131315
AuxLeafStore: implCfg.AuxLeafStore,
13141316
AuxSigner: implCfg.AuxSigner,
1317+
AuxResolver: implCfg.AuxContractResolver,
13151318
}, dbs.ChanStateDB)
13161319

13171320
// Select the configuration and funding parameters for Bitcoin.
@@ -1560,6 +1563,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
15601563
AliasManager: s.aliasMgr,
15611564
IsSweeperOutpoint: s.sweeper.IsSweeperOutpoint,
15621565
AuxFundingController: implCfg.AuxFundingController,
1566+
AuxSigner: implCfg.AuxSigner,
1567+
AuxResolver: implCfg.AuxContractResolver,
15631568
})
15641569
if err != nil {
15651570
return nil, err
@@ -4055,6 +4060,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
40554060
AuxSigner: s.implCfg.AuxSigner,
40564061
MsgRouter: s.implCfg.MsgRouter,
40574062
AuxChanCloser: s.implCfg.AuxChanCloser,
4063+
AuxResolver: s.implCfg.AuxContractResolver,
40584064
}
40594065

40604066
copy(pCfg.PubKeyBytes[:], peerAddr.IdentityKey.SerializeCompressed())

sweep/fee_bumper.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,8 @@ type TxPublisherConfig struct {
258258
// Notifier is used to monitor the confirmation status of the tx.
259259
Notifier chainntnfs.ChainNotifier
260260

261-
// AuxSweeper is an optional interface that can be used to shape the
262-
// way the final sweep transaction is generated.
261+
// AuxSweeper is an optional interface that can be used to modify the
262+
// way sweep transaction are generated.
263263
AuxSweeper fn.Option[AuxSweeper]
264264
}
265265

sweep/sweeper.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,10 @@ type UtxoSweeperConfig struct {
362362
// NoDeadlineConfTarget is the conf target to use when sweeping
363363
// non-time-sensitive outputs.
364364
NoDeadlineConfTarget uint32
365+
366+
// AuxSweeper is an optional interface that can be used to modify the
367+
// way sweep transaction are generated.
368+
AuxSweeper fn.Option[AuxSweeper]
365369
}
366370

367371
// Result is the struct that is pushed through the result channel. Callers can

0 commit comments

Comments
 (0)