mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-05 09:20:21 +02:00
multi: hook up new aux interfaces
This commit is contained in:
parent
0027da8732
commit
bf9dab6242
@ -50,6 +50,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/rpcperms"
|
"github.com/lightningnetwork/lnd/rpcperms"
|
||||||
"github.com/lightningnetwork/lnd/signal"
|
"github.com/lightningnetwork/lnd/signal"
|
||||||
"github.com/lightningnetwork/lnd/sqldb"
|
"github.com/lightningnetwork/lnd/sqldb"
|
||||||
|
"github.com/lightningnetwork/lnd/sweep"
|
||||||
"github.com/lightningnetwork/lnd/walletunlocker"
|
"github.com/lightningnetwork/lnd/walletunlocker"
|
||||||
"github.com/lightningnetwork/lnd/watchtower"
|
"github.com/lightningnetwork/lnd/watchtower"
|
||||||
"github.com/lightningnetwork/lnd/watchtower/wtclient"
|
"github.com/lightningnetwork/lnd/watchtower/wtclient"
|
||||||
@ -188,13 +189,13 @@ type AuxComponents struct {
|
|||||||
// modify the way a coop-close transaction is constructed.
|
// modify the way a coop-close transaction is constructed.
|
||||||
AuxChanCloser fn.Option[chancloser.AuxChanCloser]
|
AuxChanCloser fn.Option[chancloser.AuxChanCloser]
|
||||||
|
|
||||||
|
// AuxSweeper is an optional interface that can be used to modify the
|
||||||
|
// way sweep transaction are generated.
|
||||||
|
AuxSweeper fn.Option[sweep.AuxSweeper]
|
||||||
|
|
||||||
// AuxContractResolver is an optional interface that can be used to
|
// AuxContractResolver is an optional interface that can be used to
|
||||||
// modify the way contracts are resolved.
|
// modify the way contracts are resolved.
|
||||||
AuxContractResolver fn.Option[lnwallet.AuxContractResolver]
|
AuxContractResolver fn.Option[lnwallet.AuxContractResolver]
|
||||||
|
|
||||||
// AuxSweeper is an optional interface that can be used to modify the
|
|
||||||
// way sweep transaction are generated.
|
|
||||||
AuxSweeper fn.Option[lnwallet.AuxContractResolver]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultWalletImpl is the default implementation of our normal, btcwallet
|
// DefaultWalletImpl is the default implementation of our normal, btcwallet
|
||||||
|
@ -225,6 +225,10 @@ type ChainArbitratorConfig struct {
|
|||||||
// AuxSigner is an optional signer that can be used to sign auxiliary
|
// AuxSigner is an optional signer that can be used to sign auxiliary
|
||||||
// leaves for certain custom channel types.
|
// leaves for certain custom channel types.
|
||||||
AuxSigner fn.Option[lnwallet.AuxSigner]
|
AuxSigner fn.Option[lnwallet.AuxSigner]
|
||||||
|
|
||||||
|
// AuxResolver is an optional interface that can be used to modify the
|
||||||
|
// way contracts are resolved.
|
||||||
|
AuxResolver fn.Option[lnwallet.AuxContractResolver]
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@ -314,6 +318,9 @@ func (a *arbChannel) NewAnchorResolutions() (*lnwallet.AnchorResolutions,
|
|||||||
a.c.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
a.c.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
||||||
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
||||||
})
|
})
|
||||||
|
a.c.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
|
||||||
|
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
|
||||||
|
})
|
||||||
|
|
||||||
chanMachine, err := lnwallet.NewLightningChannel(
|
chanMachine, err := lnwallet.NewLightningChannel(
|
||||||
a.c.cfg.Signer, channel, nil, chanOpts...,
|
a.c.cfg.Signer, channel, nil, chanOpts...,
|
||||||
@ -367,6 +374,9 @@ func (a *arbChannel) ForceCloseChan() (*lnwallet.LocalForceCloseSummary, error)
|
|||||||
a.c.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
a.c.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
||||||
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
||||||
})
|
})
|
||||||
|
a.c.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
|
||||||
|
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
|
||||||
|
})
|
||||||
|
|
||||||
// Finally, we'll force close the channel completing
|
// Finally, we'll force close the channel completing
|
||||||
// the force close workflow.
|
// the force close workflow.
|
||||||
@ -1198,10 +1208,11 @@ func (c *ChainArbitrator) WatchNewChannel(newChan *channeldb.OpenChannel) error
|
|||||||
// that we detect any relevant on chain events.
|
// that we detect any relevant on chain events.
|
||||||
chainWatcher, err := newChainWatcher(
|
chainWatcher, err := newChainWatcher(
|
||||||
chainWatcherConfig{
|
chainWatcherConfig{
|
||||||
chanState: newChan,
|
chanState: newChan,
|
||||||
notifier: c.cfg.Notifier,
|
notifier: c.cfg.Notifier,
|
||||||
signer: c.cfg.Signer,
|
signer: c.cfg.Signer,
|
||||||
isOurAddr: c.cfg.IsOurAddress,
|
isOurAddr: c.cfg.IsOurAddress,
|
||||||
|
auxResolver: c.cfg.AuxResolver,
|
||||||
contractBreach: func(
|
contractBreach: func(
|
||||||
retInfo *lnwallet.BreachRetribution) error {
|
retInfo *lnwallet.BreachRetribution) error {
|
||||||
|
|
||||||
|
@ -193,10 +193,8 @@ type chainWatcherConfig struct {
|
|||||||
// auxLeafStore can be used to fetch information for custom channels.
|
// auxLeafStore can be used to fetch information for custom channels.
|
||||||
auxLeafStore fn.Option[lnwallet.AuxLeafStore]
|
auxLeafStore fn.Option[lnwallet.AuxLeafStore]
|
||||||
|
|
||||||
// auxResolver...
|
// auxResolver is used to supplement contract resolution.
|
||||||
auxResolver fn.Option[lnwallet.AuxContractResolver]
|
auxResolver fn.Option[lnwallet.AuxContractResolver]
|
||||||
|
|
||||||
// TODO(roasbeef): always set in config ^
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
|
@ -558,6 +558,10 @@ type Config struct {
|
|||||||
// AuxSigner is an optional signer that can be used to sign auxiliary
|
// AuxSigner is an optional signer that can be used to sign auxiliary
|
||||||
// leaves for certain custom channel types.
|
// leaves for certain custom channel types.
|
||||||
AuxSigner fn.Option[lnwallet.AuxSigner]
|
AuxSigner fn.Option[lnwallet.AuxSigner]
|
||||||
|
|
||||||
|
// AuxResolver is an optional interface that can be used to modify the
|
||||||
|
// way contracts are resolved.
|
||||||
|
AuxResolver fn.Option[lnwallet.AuxContractResolver]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Manager acts as an orchestrator/bridge between the wallet's
|
// Manager acts as an orchestrator/bridge between the wallet's
|
||||||
@ -1090,6 +1094,9 @@ func (f *Manager) advanceFundingState(channel *channeldb.OpenChannel,
|
|||||||
f.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
f.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
||||||
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
||||||
})
|
})
|
||||||
|
f.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
|
||||||
|
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
|
||||||
|
})
|
||||||
|
|
||||||
// We create the state-machine object which wraps the database state.
|
// We create the state-machine object which wraps the database state.
|
||||||
lnChannel, err := lnwallet.NewLightningChannel(
|
lnChannel, err := lnwallet.NewLightningChannel(
|
||||||
|
@ -1467,7 +1467,8 @@ func WithAuxSigner(signer AuxSigner) ChannelOpt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WithAuxResolver...
|
// WithAuxResolver is used to specify a custom aux contract resolver for the
|
||||||
|
// channel.
|
||||||
func WithAuxResolver(resolver AuxContractResolver) ChannelOpt {
|
func WithAuxResolver(resolver AuxContractResolver) ChannelOpt {
|
||||||
return func(o *channelOpts) {
|
return func(o *channelOpts) {
|
||||||
o.auxResolver = fn.Some[AuxContractResolver](resolver)
|
o.auxResolver = fn.Some[AuxContractResolver](resolver)
|
||||||
|
@ -395,6 +395,10 @@ type Config struct {
|
|||||||
// leaves for certain custom channel types.
|
// leaves for certain custom channel types.
|
||||||
AuxSigner fn.Option[lnwallet.AuxSigner]
|
AuxSigner fn.Option[lnwallet.AuxSigner]
|
||||||
|
|
||||||
|
// AuxResolver is an optional interface that can be used to modify the
|
||||||
|
// way contracts are resolved.
|
||||||
|
AuxResolver fn.Option[lnwallet.AuxContractResolver]
|
||||||
|
|
||||||
// PongBuf is a slice we'll reuse instead of allocating memory on the
|
// PongBuf is a slice we'll reuse instead of allocating memory on the
|
||||||
// heap. Since only reads will occur and no writes, there is no need
|
// heap. Since only reads will occur and no writes, there is no need
|
||||||
// for any synchronization primitives. As a result, it's safe to share
|
// for any synchronization primitives. As a result, it's safe to share
|
||||||
@ -982,8 +986,6 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(roasbeef): also make aux resolver here
|
|
||||||
|
|
||||||
var chanOpts []lnwallet.ChannelOpt
|
var chanOpts []lnwallet.ChannelOpt
|
||||||
p.cfg.AuxLeafStore.WhenSome(func(s lnwallet.AuxLeafStore) {
|
p.cfg.AuxLeafStore.WhenSome(func(s lnwallet.AuxLeafStore) {
|
||||||
chanOpts = append(chanOpts, lnwallet.WithLeafStore(s))
|
chanOpts = append(chanOpts, lnwallet.WithLeafStore(s))
|
||||||
@ -991,6 +993,10 @@ func (p *Brontide) loadActiveChannels(chans []*channeldb.OpenChannel) (
|
|||||||
p.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
p.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
||||||
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
||||||
})
|
})
|
||||||
|
p.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) { //nolint:lll
|
||||||
|
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
|
||||||
|
})
|
||||||
|
|
||||||
lnChan, err := lnwallet.NewLightningChannel(
|
lnChan, err := lnwallet.NewLightningChannel(
|
||||||
p.cfg.Signer, dbChan, p.cfg.SigPool, chanOpts...,
|
p.cfg.Signer, dbChan, p.cfg.SigPool, chanOpts...,
|
||||||
)
|
)
|
||||||
@ -4163,6 +4169,9 @@ func (p *Brontide) addActiveChannel(c *lnpeer.NewChannel) error {
|
|||||||
p.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
p.cfg.AuxSigner.WhenSome(func(s lnwallet.AuxSigner) {
|
||||||
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
chanOpts = append(chanOpts, lnwallet.WithAuxSigner(s))
|
||||||
})
|
})
|
||||||
|
p.cfg.AuxResolver.WhenSome(func(s lnwallet.AuxContractResolver) {
|
||||||
|
chanOpts = append(chanOpts, lnwallet.WithAuxResolver(s))
|
||||||
|
})
|
||||||
|
|
||||||
// If not already active, we'll add this channel to the set of active
|
// If not already active, we'll add this channel to the set of active
|
||||||
// channels, so we can look it up later easily according to its channel
|
// channels, so we can look it up later easily according to its channel
|
||||||
|
17
server.go
17
server.go
@ -1094,10 +1094,11 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
)
|
)
|
||||||
|
|
||||||
s.txPublisher = sweep.NewTxPublisher(sweep.TxPublisherConfig{
|
s.txPublisher = sweep.NewTxPublisher(sweep.TxPublisherConfig{
|
||||||
Signer: cc.Wallet.Cfg.Signer,
|
Signer: cc.Wallet.Cfg.Signer,
|
||||||
Wallet: cc.Wallet,
|
Wallet: cc.Wallet,
|
||||||
Estimator: cc.FeeEstimator,
|
Estimator: cc.FeeEstimator,
|
||||||
Notifier: cc.ChainNotifier,
|
Notifier: cc.ChainNotifier,
|
||||||
|
AuxSweeper: s.implCfg.AuxSweeper,
|
||||||
})
|
})
|
||||||
|
|
||||||
s.sweeper = sweep.New(&sweep.UtxoSweeperConfig{
|
s.sweeper = sweep.New(&sweep.UtxoSweeperConfig{
|
||||||
@ -1115,6 +1116,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
Aggregator: aggregator,
|
Aggregator: aggregator,
|
||||||
Publisher: s.txPublisher,
|
Publisher: s.txPublisher,
|
||||||
NoDeadlineConfTarget: cfg.Sweeper.NoDeadlineConfTarget,
|
NoDeadlineConfTarget: cfg.Sweeper.NoDeadlineConfTarget,
|
||||||
|
AuxSweeper: s.implCfg.AuxSweeper,
|
||||||
})
|
})
|
||||||
|
|
||||||
s.utxoNursery = contractcourt.NewUtxoNursery(&contractcourt.NurseryConfig{
|
s.utxoNursery = contractcourt.NewUtxoNursery(&contractcourt.NurseryConfig{
|
||||||
@ -1292,6 +1294,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
},
|
},
|
||||||
AuxLeafStore: implCfg.AuxLeafStore,
|
AuxLeafStore: implCfg.AuxLeafStore,
|
||||||
AuxSigner: implCfg.AuxSigner,
|
AuxSigner: implCfg.AuxSigner,
|
||||||
|
AuxResolver: implCfg.AuxContractResolver,
|
||||||
}, dbs.ChanStateDB)
|
}, dbs.ChanStateDB)
|
||||||
|
|
||||||
// Select the configuration and funding parameters for Bitcoin.
|
// Select the configuration and funding parameters for Bitcoin.
|
||||||
@ -1540,6 +1543,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
AliasManager: s.aliasMgr,
|
AliasManager: s.aliasMgr,
|
||||||
IsSweeperOutpoint: s.sweeper.IsSweeperOutpoint,
|
IsSweeperOutpoint: s.sweeper.IsSweeperOutpoint,
|
||||||
AuxFundingController: implCfg.AuxFundingController,
|
AuxFundingController: implCfg.AuxFundingController,
|
||||||
|
AuxSigner: implCfg.AuxSigner,
|
||||||
|
AuxResolver: implCfg.AuxContractResolver,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -1627,7 +1632,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
|
|
||||||
br, err := lnwallet.NewBreachRetribution(
|
br, err := lnwallet.NewBreachRetribution(
|
||||||
channel, commitHeight, 0, nil,
|
channel, commitHeight, 0, nil,
|
||||||
implCfg.AuxLeafStore, implCfg.AuxSweeper,
|
implCfg.AuxLeafStore,
|
||||||
|
implCfg.AuxContractResolver,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
@ -3975,6 +3981,7 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
|
|||||||
AuxSigner: s.implCfg.AuxSigner,
|
AuxSigner: s.implCfg.AuxSigner,
|
||||||
MsgRouter: s.implCfg.MsgRouter,
|
MsgRouter: s.implCfg.MsgRouter,
|
||||||
AuxChanCloser: s.implCfg.AuxChanCloser,
|
AuxChanCloser: s.implCfg.AuxChanCloser,
|
||||||
|
AuxResolver: s.implCfg.AuxContractResolver,
|
||||||
}
|
}
|
||||||
|
|
||||||
copy(pCfg.PubKeyBytes[:], peerAddr.IdentityKey.SerializeCompressed())
|
copy(pCfg.PubKeyBytes[:], peerAddr.IdentityKey.SerializeCompressed())
|
||||||
|
@ -258,8 +258,8 @@ type TxPublisherConfig struct {
|
|||||||
// Notifier is used to monitor the confirmation status of the tx.
|
// Notifier is used to monitor the confirmation status of the tx.
|
||||||
Notifier chainntnfs.ChainNotifier
|
Notifier chainntnfs.ChainNotifier
|
||||||
|
|
||||||
// AuxSweeper is an optional interface that can be used to shape the
|
// AuxSweeper is an optional interface that can be used to modify the
|
||||||
// way the final sweep transaction is generated.
|
// way sweep transaction are generated.
|
||||||
AuxSweeper fn.Option[AuxSweeper]
|
AuxSweeper fn.Option[AuxSweeper]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,6 +361,10 @@ type UtxoSweeperConfig struct {
|
|||||||
// NoDeadlineConfTarget is the conf target to use when sweeping
|
// NoDeadlineConfTarget is the conf target to use when sweeping
|
||||||
// non-time-sensitive outputs.
|
// non-time-sensitive outputs.
|
||||||
NoDeadlineConfTarget uint32
|
NoDeadlineConfTarget uint32
|
||||||
|
|
||||||
|
// AuxSweeper is an optional interface that can be used to modify the
|
||||||
|
// way sweep transaction are generated.
|
||||||
|
AuxSweeper fn.Option[AuxSweeper]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Result is the struct that is pushed through the result channel. Callers can
|
// Result is the struct that is pushed through the result channel. Callers can
|
||||||
|
Loading…
x
Reference in New Issue
Block a user