lnd: export ChainControl, ChainRegistry

This commit is contained in:
Eugene 2020-10-06 08:03:42 -07:00 committed by eugene
parent cbdea57d52
commit 4d238cfa2f
9 changed files with 210 additions and 197 deletions

View File

@ -101,40 +101,53 @@ var DefaultLtcChannelConstraints = channeldb.ChannelConstraints{
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2, MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
} }
// chainControl couples the three primary interfaces lnd utilizes for a // ChainControl couples the three primary interfaces lnd utilizes for a
// particular chain together. A single chainControl instance will exist for all // particular chain together. A single ChainControl instance will exist for all
// the chains lnd is currently active on. // the chains lnd is currently active on.
type chainControl struct { type ChainControl struct {
chainIO lnwallet.BlockChainIO // ChainIO represents an abstraction over a source that can query the blockchain.
ChainIO lnwallet.BlockChainIO
feeEstimator chainfee.Estimator // FeeEstimator is used to estimate an optimal fee for transactions important to us.
FeeEstimator chainfee.Estimator
signer input.Signer // Signer is used to provide signatures over things like transactions.
Signer input.Signer
keyRing keychain.SecretKeyRing // KeyRing represents a set of keys that we have the private keys to.
KeyRing keychain.SecretKeyRing
wc lnwallet.WalletController // Wc is an abstraction over some basic wallet commands. This base set of commands
// will be provided to the Wallet *LightningWallet raw pointer below.
Wc lnwallet.WalletController
msgSigner lnwallet.MessageSigner // MsgSigner is used to sign arbitrary messages.
MsgSigner lnwallet.MessageSigner
chainNotifier chainntnfs.ChainNotifier // ChainNotifier is used to receive blockchain events that we are interested in.
ChainNotifier chainntnfs.ChainNotifier
chainView chainview.FilteredChainView // ChainView is used in the router for maintaining an up-to-date graph.
ChainView chainview.FilteredChainView
wallet *lnwallet.LightningWallet // Wallet is our LightningWallet that also contains the abstract Wc above. This wallet
// handles all of the lightning operations.
Wallet *lnwallet.LightningWallet
routingPolicy htlcswitch.ForwardingPolicy // RoutingPolicy is the routing policy we have decided to use.
RoutingPolicy htlcswitch.ForwardingPolicy
minHtlcIn lnwire.MilliSatoshi // MinHtlcIn is the minimum HTLC we will accept.
MinHtlcIn lnwire.MilliSatoshi
} }
// newChainControl attempts to create a chainControl instance according // NewChainControl attempts to create a ChainControl instance according
// to the parameters in the passed configuration. Currently three // to the parameters in the passed configuration. Currently three
// branches of chainControl instances exist: one backed by a running btcd // branches of ChainControl instances exist: one backed by a running btcd
// full-node, another backed by a running bitcoind full-node, and the other // full-node, another backed by a running bitcoind full-node, and the other
// backed by a running neutrino light client instance. When running with a // backed by a running neutrino light client instance. When running with a
// neutrino light client instance, `neutrinoCS` must be non-nil. // neutrino light client instance, `neutrinoCS` must be non-nil.
func newChainControl(cfg *chainreg.Config) (*chainControl, error) { func NewChainControl(cfg *chainreg.Config) (*ChainControl, error) {
// Set the RPC config from the "home" chain. Multi-chain isn't yet // Set the RPC config from the "home" chain. Multi-chain isn't yet
// active, so we'll restrict usage to a particular chain for now. // active, so we'll restrict usage to a particular chain for now.
@ -145,30 +158,30 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
ltndLog.Infof("Primary chain is set to: %v", ltndLog.Infof("Primary chain is set to: %v",
cfg.PrimaryChain()) cfg.PrimaryChain())
cc := &chainControl{} cc := &ChainControl{}
switch cfg.PrimaryChain() { switch cfg.PrimaryChain() {
case chainreg.BitcoinChain: case chainreg.BitcoinChain:
cc.routingPolicy = htlcswitch.ForwardingPolicy{ cc.RoutingPolicy = htlcswitch.ForwardingPolicy{
MinHTLCOut: cfg.Bitcoin.MinHTLCOut, MinHTLCOut: cfg.Bitcoin.MinHTLCOut,
BaseFee: cfg.Bitcoin.BaseFee, BaseFee: cfg.Bitcoin.BaseFee,
FeeRate: cfg.Bitcoin.FeeRate, FeeRate: cfg.Bitcoin.FeeRate,
TimeLockDelta: cfg.Bitcoin.TimeLockDelta, TimeLockDelta: cfg.Bitcoin.TimeLockDelta,
} }
cc.minHtlcIn = cfg.Bitcoin.MinHTLCIn cc.MinHtlcIn = cfg.Bitcoin.MinHTLCIn
cc.feeEstimator = chainfee.NewStaticEstimator( cc.FeeEstimator = chainfee.NewStaticEstimator(
DefaultBitcoinStaticFeePerKW, DefaultBitcoinStaticFeePerKW,
DefaultBitcoinStaticMinRelayFeeRate, DefaultBitcoinStaticMinRelayFeeRate,
) )
case chainreg.LitecoinChain: case chainreg.LitecoinChain:
cc.routingPolicy = htlcswitch.ForwardingPolicy{ cc.RoutingPolicy = htlcswitch.ForwardingPolicy{
MinHTLCOut: cfg.Litecoin.MinHTLCOut, MinHTLCOut: cfg.Litecoin.MinHTLCOut,
BaseFee: cfg.Litecoin.BaseFee, BaseFee: cfg.Litecoin.BaseFee,
FeeRate: cfg.Litecoin.FeeRate, FeeRate: cfg.Litecoin.FeeRate,
TimeLockDelta: cfg.Litecoin.TimeLockDelta, TimeLockDelta: cfg.Litecoin.TimeLockDelta,
} }
cc.minHtlcIn = cfg.Litecoin.MinHTLCIn cc.MinHtlcIn = cfg.Litecoin.MinHTLCIn
cc.feeEstimator = chainfee.NewStaticEstimator( cc.FeeEstimator = chainfee.NewStaticEstimator(
DefaultLitecoinStaticFeePerKW, 0, DefaultLitecoinStaticFeePerKW, 0,
) )
default: default:
@ -213,10 +226,10 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
// We'll create ChainNotifier and FilteredChainView instances, // We'll create ChainNotifier and FilteredChainView instances,
// along with the wallet's ChainSource, which are all backed by // along with the wallet's ChainSource, which are all backed by
// the neutrino light client. // the neutrino light client.
cc.chainNotifier = neutrinonotify.New( cc.ChainNotifier = neutrinonotify.New(
cfg.NeutrinoCS, hintCache, hintCache, cfg.NeutrinoCS, hintCache, hintCache,
) )
cc.chainView, err = chainview.NewCfFilteredChainView(cfg.NeutrinoCS) cc.ChainView, err = chainview.NewCfFilteredChainView(cfg.NeutrinoCS)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -299,10 +312,10 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
"%v", err) "%v", err)
} }
cc.chainNotifier = bitcoindnotify.New( cc.ChainNotifier = bitcoindnotify.New(
bitcoindConn, cfg.ActiveNetParams.Params, hintCache, hintCache, bitcoindConn, cfg.ActiveNetParams.Params, hintCache, hintCache,
) )
cc.chainView = chainview.NewBitcoindFilteredChainView(bitcoindConn) cc.ChainView = chainview.NewBitcoindFilteredChainView(bitcoindConn)
walletConfig.ChainSource = bitcoindConn.NewBitcoindClient() walletConfig.ChainSource = bitcoindConn.NewBitcoindClient()
// If we're not in regtest mode, then we'll attempt to use a // If we're not in regtest mode, then we'll attempt to use a
@ -325,7 +338,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
// use live fee estimates, rather than a statically // use live fee estimates, rather than a statically
// coded value. // coded value.
fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000) fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000)
cc.feeEstimator, err = chainfee.NewBitcoindEstimator( cc.FeeEstimator, err = chainfee.NewBitcoindEstimator(
*rpcConfig, bitcoindMode.EstimateMode, *rpcConfig, bitcoindMode.EstimateMode,
fallBackFeeRate.FeePerKWeight(), fallBackFeeRate.FeePerKWeight(),
) )
@ -341,7 +354,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
// use live fee estimates, rather than a statically // use live fee estimates, rather than a statically
// coded value. // coded value.
fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000) fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000)
cc.feeEstimator, err = chainfee.NewBitcoindEstimator( cc.FeeEstimator, err = chainfee.NewBitcoindEstimator(
*rpcConfig, bitcoindMode.EstimateMode, *rpcConfig, bitcoindMode.EstimateMode,
fallBackFeeRate.FeePerKWeight(), fallBackFeeRate.FeePerKWeight(),
) )
@ -407,7 +420,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
DisableConnectOnNew: true, DisableConnectOnNew: true,
DisableAutoReconnect: false, DisableAutoReconnect: false,
} }
cc.chainNotifier, err = btcdnotify.New( cc.ChainNotifier, err = btcdnotify.New(
rpcConfig, cfg.ActiveNetParams.Params, hintCache, hintCache, rpcConfig, cfg.ActiveNetParams.Params, hintCache, hintCache,
) )
if err != nil { if err != nil {
@ -416,7 +429,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
// Finally, we'll create an instance of the default chain view to be // Finally, we'll create an instance of the default chain view to be
// used within the routing layer. // used within the routing layer.
cc.chainView, err = chainview.NewBtcdFilteredChainView(*rpcConfig) cc.ChainView, err = chainview.NewBtcdFilteredChainView(*rpcConfig)
if err != nil { if err != nil {
srvrLog.Errorf("unable to create chain view: %v", err) srvrLog.Errorf("unable to create chain view: %v", err)
return nil, err return nil, err
@ -444,7 +457,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
// live fee estimates, rather than a statically coded // live fee estimates, rather than a statically coded
// value. // value.
fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000) fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000)
cc.feeEstimator, err = chainfee.NewBtcdEstimator( cc.FeeEstimator, err = chainfee.NewBtcdEstimator(
*rpcConfig, fallBackFeeRate.FeePerKWeight(), *rpcConfig, fallBackFeeRate.FeePerKWeight(),
) )
if err != nil { if err != nil {
@ -465,7 +478,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
ltndLog.Infof("Using external fee estimator %v: cached=%v", ltndLog.Infof("Using external fee estimator %v: cached=%v",
cfg.FeeURL, cacheFees) cfg.FeeURL, cacheFees)
cc.feeEstimator = chainfee.NewWebAPIEstimator( cc.FeeEstimator = chainfee.NewWebAPIEstimator(
chainfee.SparseConfFeeSource{ chainfee.SparseConfFeeSource{
URL: cfg.FeeURL, URL: cfg.FeeURL,
}, },
@ -474,7 +487,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
} }
// Start fee estimator. // Start fee estimator.
if err := cc.feeEstimator.Start(); err != nil { if err := cc.FeeEstimator.Start(); err != nil {
return nil, err return nil, err
} }
@ -484,10 +497,10 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
return nil, err return nil, err
} }
cc.msgSigner = wc cc.MsgSigner = wc
cc.signer = wc cc.Signer = wc
cc.chainIO = wc cc.ChainIO = wc
cc.wc = wc cc.Wc = wc
// Select the default channel constraints for the primary chain. // Select the default channel constraints for the primary chain.
channelConstraints := DefaultBtcChannelConstraints channelConstraints := DefaultBtcChannelConstraints
@ -498,18 +511,18 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
keyRing := keychain.NewBtcWalletKeyRing( keyRing := keychain.NewBtcWalletKeyRing(
wc.InternalWallet(), cfg.ActiveNetParams.CoinType, wc.InternalWallet(), cfg.ActiveNetParams.CoinType,
) )
cc.keyRing = keyRing cc.KeyRing = keyRing
// Create, and start the lnwallet, which handles the core payment // Create, and start the lnwallet, which handles the core payment
// channel logic, and exposes control via proxy state machines. // channel logic, and exposes control via proxy state machines.
walletCfg := lnwallet.Config{ walletCfg := lnwallet.Config{
Database: cfg.RemoteChanDB, Database: cfg.RemoteChanDB,
Notifier: cc.chainNotifier, Notifier: cc.ChainNotifier,
WalletController: wc, WalletController: wc,
Signer: cc.signer, Signer: cc.Signer,
FeeEstimator: cc.feeEstimator, FeeEstimator: cc.FeeEstimator,
SecretKeyRing: keyRing, SecretKeyRing: keyRing,
ChainIO: cc.chainIO, ChainIO: cc.ChainIO,
DefaultConstraints: channelConstraints, DefaultConstraints: channelConstraints,
NetParams: *cfg.ActiveNetParams.Params, NetParams: *cfg.ActiveNetParams.Params,
} }
@ -525,7 +538,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
ltndLog.Info("LightningWallet opened") ltndLog.Info("LightningWallet opened")
cc.wallet = lnWallet cc.Wallet = lnWallet
return cc, nil return cc, nil
} }
@ -575,7 +588,7 @@ var (
LitecoinMainnetGenesis: chainreg.LitecoinChain, LitecoinMainnetGenesis: chainreg.LitecoinChain,
} }
// chainDNSSeeds is a map of a chain's hash to the set of DNS seeds // ChainDNSSeeds is a map of a chain's hash to the set of DNS seeds
// that will be use to bootstrap peers upon first startup. // that will be use to bootstrap peers upon first startup.
// //
// The first item in the array is the primary host we'll use to attempt // The first item in the array is the primary host we'll use to attempt
@ -587,7 +600,7 @@ var (
// //
// TODO(roasbeef): extend and collapse these and chainparams.go into // TODO(roasbeef): extend and collapse these and chainparams.go into
// struct like chaincfg.Params // struct like chaincfg.Params
chainDNSSeeds = map[chainhash.Hash][][2]string{ ChainDNSSeeds = map[chainhash.Hash][][2]string{
BitcoinMainnetGenesis: { BitcoinMainnetGenesis: {
{ {
"nodes.lightning.directory", "nodes.lightning.directory",
@ -614,38 +627,38 @@ var (
} }
) )
// chainRegistry keeps track of the current chains // ChainRegistry keeps track of the current chains
type chainRegistry struct { type ChainRegistry struct {
sync.RWMutex sync.RWMutex
activeChains map[chainreg.ChainCode]*chainControl activeChains map[chainreg.ChainCode]*ChainControl
netParams map[chainreg.ChainCode]*chainreg.BitcoinNetParams netParams map[chainreg.ChainCode]*chainreg.BitcoinNetParams
primaryChain chainreg.ChainCode primaryChain chainreg.ChainCode
} }
// newChainRegistry creates a new chainRegistry. // NewChainRegistry creates a new ChainRegistry.
func newChainRegistry() *chainRegistry { func NewChainRegistry() *ChainRegistry {
return &chainRegistry{ return &ChainRegistry{
activeChains: make(map[chainreg.ChainCode]*chainControl), activeChains: make(map[chainreg.ChainCode]*ChainControl),
netParams: make(map[chainreg.ChainCode]*chainreg.BitcoinNetParams), netParams: make(map[chainreg.ChainCode]*chainreg.BitcoinNetParams),
} }
} }
// RegisterChain assigns an active chainControl instance to a target chain // RegisterChain assigns an active ChainControl instance to a target chain
// identified by its ChainCode. // identified by its ChainCode.
func (c *chainRegistry) RegisterChain(newChain chainreg.ChainCode, func (c *ChainRegistry) RegisterChain(newChain chainreg.ChainCode,
cc *chainControl) { cc *ChainControl) {
c.Lock() c.Lock()
c.activeChains[newChain] = cc c.activeChains[newChain] = cc
c.Unlock() c.Unlock()
} }
// LookupChain attempts to lookup an active chainControl instance for the // LookupChain attempts to lookup an active ChainControl instance for the
// target chain. // target chain.
func (c *chainRegistry) LookupChain(targetChain chainreg.ChainCode) ( func (c *ChainRegistry) LookupChain(targetChain chainreg.ChainCode) (
*chainControl, bool) { *ChainControl, bool) {
c.RLock() c.RLock()
cc, ok := c.activeChains[targetChain] cc, ok := c.activeChains[targetChain]
@ -653,9 +666,9 @@ func (c *chainRegistry) LookupChain(targetChain chainreg.ChainCode) (
return cc, ok return cc, ok
} }
// LookupChainByHash attempts to look up an active chainControl which // LookupChainByHash attempts to look up an active ChainControl which
// corresponds to the passed genesis hash. // corresponds to the passed genesis hash.
func (c *chainRegistry) LookupChainByHash(chainHash chainhash.Hash) (*chainControl, bool) { func (c *ChainRegistry) LookupChainByHash(chainHash chainhash.Hash) (*ChainControl, bool) {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()
@ -669,7 +682,7 @@ func (c *chainRegistry) LookupChainByHash(chainHash chainhash.Hash) (*chainContr
} }
// RegisterPrimaryChain sets a target chain as the "home chain" for lnd. // RegisterPrimaryChain sets a target chain as the "home chain" for lnd.
func (c *chainRegistry) RegisterPrimaryChain(cc chainreg.ChainCode) { func (c *ChainRegistry) RegisterPrimaryChain(cc chainreg.ChainCode) {
c.Lock() c.Lock()
defer c.Unlock() defer c.Unlock()
@ -679,7 +692,7 @@ func (c *chainRegistry) RegisterPrimaryChain(cc chainreg.ChainCode) {
// PrimaryChain returns the primary chain for this running lnd instance. The // PrimaryChain returns the primary chain for this running lnd instance. The
// primary chain is considered the "home base" while the other registered // primary chain is considered the "home base" while the other registered
// chains are treated as secondary chains. // chains are treated as secondary chains.
func (c *chainRegistry) PrimaryChain() chainreg.ChainCode { func (c *ChainRegistry) PrimaryChain() chainreg.ChainCode {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()
@ -687,7 +700,7 @@ func (c *chainRegistry) PrimaryChain() chainreg.ChainCode {
} }
// ActiveChains returns a slice containing the active chains. // ActiveChains returns a slice containing the active chains.
func (c *chainRegistry) ActiveChains() []chainreg.ChainCode { func (c *ChainRegistry) ActiveChains() []chainreg.ChainCode {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()
@ -700,7 +713,7 @@ func (c *chainRegistry) ActiveChains() []chainreg.ChainCode {
} }
// NumActiveChains returns the total number of active chains. // NumActiveChains returns the total number of active chains.
func (c *chainRegistry) NumActiveChains() uint32 { func (c *ChainRegistry) NumActiveChains() uint32 {
c.RLock() c.RLock()
defer c.RUnlock() defer c.RUnlock()

View File

@ -312,7 +312,7 @@ type Config struct {
// registeredChains keeps track of all chains that have been registered // registeredChains keeps track of all chains that have been registered
// with the daemon. // with the daemon.
registeredChains *chainRegistry registeredChains *ChainRegistry
// networkDir is the path to the directory of the currently active // networkDir is the path to the directory of the currently active
// network. This path will hold the files related to each different // network. This path will hold the files related to each different
@ -452,7 +452,7 @@ func DefaultConfig() Config {
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation, MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
LogWriter: build.NewRotatingLogWriter(), LogWriter: build.NewRotatingLogWriter(),
DB: lncfg.DefaultDB(), DB: lncfg.DefaultDB(),
registeredChains: newChainRegistry(), registeredChains: NewChainRegistry(),
ActiveNetParams: chainreg.BitcoinTestNetParams, ActiveNetParams: chainreg.BitcoinTestNetParams,
} }
} }

View File

@ -358,7 +358,7 @@ type fundingConfig struct {
// RegisteredChains keeps track of all chains that have been registered // RegisteredChains keeps track of all chains that have been registered
// with the daemon. // with the daemon.
RegisteredChains *chainRegistry RegisteredChains *ChainRegistry
} }
// fundingManager acts as an orchestrator/bridge between the wallet's // fundingManager acts as an orchestrator/bridge between the wallet's

View File

@ -437,7 +437,7 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey,
NotifyOpenChannelEvent: evt.NotifyOpenChannelEvent, NotifyOpenChannelEvent: evt.NotifyOpenChannelEvent,
OpenChannelPredicate: chainedAcceptor, OpenChannelPredicate: chainedAcceptor,
NotifyPendingOpenChannelEvent: evt.NotifyPendingOpenChannelEvent, NotifyPendingOpenChannelEvent: evt.NotifyPendingOpenChannelEvent,
RegisteredChains: newChainRegistry(), RegisteredChains: NewChainRegistry(),
} }
for _, op := range options { for _, op := range options {

22
lnd.go
View File

@ -472,7 +472,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
FeeURL: cfg.FeeURL, FeeURL: cfg.FeeURL,
} }
activeChainControl, err := newChainControl(chainControlCfg) activeChainControl, err := NewChainControl(chainControlCfg)
if err != nil { if err != nil {
err := fmt.Errorf("unable to create chain control: %v", err) err := fmt.Errorf("unable to create chain control: %v", err)
ltndLog.Error(err) ltndLog.Error(err)
@ -486,7 +486,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
cfg.registeredChains.RegisterChain(primaryChain, activeChainControl) cfg.registeredChains.RegisterChain(primaryChain, activeChainControl)
// TODO(roasbeef): add rotation // TODO(roasbeef): add rotation
idKeyDesc, err := activeChainControl.keyRing.DeriveKey( idKeyDesc, err := activeChainControl.KeyRing.DeriveKey(
keychain.KeyLocator{ keychain.KeyLocator{
Family: keychain.KeyFamilyNodeKey, Family: keychain.KeyFamilyNodeKey,
Index: 0, Index: 0,
@ -559,7 +559,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
} }
defer towerDB.Close() defer towerDB.Close()
towerKeyDesc, err := activeChainControl.keyRing.DeriveKey( towerKeyDesc, err := activeChainControl.KeyRing.DeriveKey(
keychain.KeyLocator{ keychain.KeyLocator{
Family: keychain.KeyFamilyTowerID, Family: keychain.KeyFamilyTowerID,
Index: 0, Index: 0,
@ -572,19 +572,19 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
} }
wtCfg := &watchtower.Config{ wtCfg := &watchtower.Config{
BlockFetcher: activeChainControl.chainIO, BlockFetcher: activeChainControl.ChainIO,
DB: towerDB, DB: towerDB,
EpochRegistrar: activeChainControl.chainNotifier, EpochRegistrar: activeChainControl.ChainNotifier,
Net: cfg.net, Net: cfg.net,
NewAddress: func() (btcutil.Address, error) { NewAddress: func() (btcutil.Address, error) {
return activeChainControl.wallet.NewAddress( return activeChainControl.Wallet.NewAddress(
lnwallet.WitnessPubKey, false, lnwallet.WitnessPubKey, false,
) )
}, },
NodeKeyECDH: keychain.NewPubKeyECDH( NodeKeyECDH: keychain.NewPubKeyECDH(
towerKeyDesc, activeChainControl.keyRing, towerKeyDesc, activeChainControl.KeyRing,
), ),
PublishTx: activeChainControl.wallet.PublishTransaction, PublishTx: activeChainControl.Wallet.PublishTransaction,
ChainHash: *cfg.ActiveNetParams.GenesisHash, ChainHash: *cfg.ActiveNetParams.GenesisHash,
} }
@ -697,7 +697,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
if !(cfg.Bitcoin.RegTest || cfg.Bitcoin.SimNet || if !(cfg.Bitcoin.RegTest || cfg.Bitcoin.SimNet ||
cfg.Litecoin.RegTest || cfg.Litecoin.SimNet) { cfg.Litecoin.RegTest || cfg.Litecoin.SimNet) {
_, bestHeight, err := activeChainControl.chainIO.GetBestBlock() _, bestHeight, err := activeChainControl.ChainIO.GetBestBlock()
if err != nil { if err != nil {
err := fmt.Errorf("unable to determine chain tip: %v", err := fmt.Errorf("unable to determine chain tip: %v",
err) err)
@ -713,7 +713,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
return nil return nil
} }
synced, _, err := activeChainControl.wallet.IsSynced() synced, _, err := activeChainControl.Wallet.IsSynced()
if err != nil { if err != nil {
err := fmt.Errorf("unable to determine if "+ err := fmt.Errorf("unable to determine if "+
"wallet is synced: %v", err) "wallet is synced: %v", err)
@ -728,7 +728,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
time.Sleep(time.Second * 1) time.Sleep(time.Second * 1)
} }
_, bestHeight, err = activeChainControl.chainIO.GetBestBlock() _, bestHeight, err = activeChainControl.ChainIO.GetBestBlock()
if err != nil { if err != nil {
err := fmt.Errorf("unable to determine chain tip: %v", err := fmt.Errorf("unable to determine chain tip: %v",
err) err)

View File

@ -88,7 +88,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
// With the connection established, we'll now establish our connection // With the connection established, we'll now establish our connection
// to the target peer, waiting for the first update before we exit. // to the target peer, waiting for the first update before we exit.
feePerKw, err := c.server.cc.feeEstimator.EstimateFeePerKW( feePerKw, err := c.server.cc.FeeEstimator.EstimateFeePerKW(
c.confTarget, c.confTarget,
) )
if err != nil { if err != nil {
@ -179,7 +179,7 @@ func initAutoPilot(svr *server, cfg *lncfg.AutoPilot,
netParams: netParams, netParams: netParams,
}, },
WalletBalance: func() (btcutil.Amount, error) { WalletBalance: func() (btcutil.Amount, error) {
return svr.cc.wallet.ConfirmedBalance(cfg.MinConfs) return svr.cc.Wallet.ConfirmedBalance(cfg.MinConfs)
}, },
Graph: autopilot.ChannelGraphFromDatabase(svr.localChanDB.ChannelGraph()), Graph: autopilot.ChannelGraphFromDatabase(svr.localChanDB.ChannelGraph()),
Constraints: atplConstraints, Constraints: atplConstraints,
@ -290,7 +290,7 @@ func initAutoPilot(svr *server, cfg *lncfg.AutoPilot,
Node: autopilot.NewNodeID(channel.IdentityPub), Node: autopilot.NewNodeID(channel.IdentityPub),
}, nil }, nil
}, },
SubscribeTransactions: svr.cc.wallet.SubscribeTransactions, SubscribeTransactions: svr.cc.Wallet.SubscribeTransactions,
SubscribeTopology: svr.chanRouter.SubscribeTopology, SubscribeTopology: svr.chanRouter.SubscribeTopology,
}, nil }, nil
} }

View File

@ -1051,7 +1051,7 @@ func (r *rpcServer) sendCoinsOnChain(paymentMap map[string]int64,
return nil, err return nil, err
} }
tx, err := r.server.cc.wallet.SendOutputs(outputs, feeRate, minconf, label) tx, err := r.server.cc.Wallet.SendOutputs(outputs, feeRate, minconf, label)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1083,8 +1083,8 @@ func (r *rpcServer) ListUnspent(ctx context.Context,
// any other concurrent processes attempting to lock any UTXOs which may // any other concurrent processes attempting to lock any UTXOs which may
// be shown available to us. // be shown available to us.
var utxos []*lnwallet.Utxo var utxos []*lnwallet.Utxo
err = r.server.cc.wallet.WithCoinSelectLock(func() error { err = r.server.cc.Wallet.WithCoinSelectLock(func() error {
utxos, err = r.server.cc.wallet.ListUnspentWitness( utxos, err = r.server.cc.Wallet.ListUnspentWitness(
minConfs, maxConfs, minConfs, maxConfs,
) )
return err return err
@ -1126,7 +1126,7 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
// target. // target.
target := in.TargetConf target := in.TargetConf
feePerKw, err := sweep.DetermineFeePerKw( feePerKw, err := sweep.DetermineFeePerKw(
r.server.cc.feeEstimator, sweep.FeePreference{ r.server.cc.FeeEstimator, sweep.FeePreference{
ConfTarget: uint32(target), ConfTarget: uint32(target),
}, },
) )
@ -1137,7 +1137,7 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
// We will ask the wallet to create a tx using this fee rate. We set // We will ask the wallet to create a tx using this fee rate. We set
// dryRun=true to avoid inflating the change addresses in the db. // dryRun=true to avoid inflating the change addresses in the db.
var tx *txauthor.AuthoredTx var tx *txauthor.AuthoredTx
wallet := r.server.cc.wallet wallet := r.server.cc.Wallet
err = wallet.WithCoinSelectLock(func() error { err = wallet.WithCoinSelectLock(func() error {
tx, err = wallet.CreateSimpleTx(outputs, feePerKw, true) tx, err = wallet.CreateSimpleTx(outputs, feePerKw, true)
return err return err
@ -1173,7 +1173,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
// appropriate fee rate for this transaction. // appropriate fee rate for this transaction.
satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight() satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight()
feePerKw, err := sweep.DetermineFeePerKw( feePerKw, err := sweep.DetermineFeePerKw(
r.server.cc.feeEstimator, sweep.FeePreference{ r.server.cc.FeeEstimator, sweep.FeePreference{
ConfTarget: uint32(in.TargetConf), ConfTarget: uint32(in.TargetConf),
FeeRate: satPerKw, FeeRate: satPerKw,
}, },
@ -1226,7 +1226,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
var txid *chainhash.Hash var txid *chainhash.Hash
wallet := r.server.cc.wallet wallet := r.server.cc.Wallet
// If the send all flag is active, then we'll attempt to sweep all the // If the send all flag is active, then we'll attempt to sweep all the
// coins in the wallet in a single transaction (if possible), // coins in the wallet in a single transaction (if possible),
@ -1240,7 +1240,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
"active") "active")
} }
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock() _, bestHeight, err := r.server.cc.ChainIO.GetBestBlock()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -1252,7 +1252,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
sweepTxPkg, err := sweep.CraftSweepAllTx( sweepTxPkg, err := sweep.CraftSweepAllTx(
feePerKw, uint32(bestHeight), targetAddr, wallet, feePerKw, uint32(bestHeight), targetAddr, wallet,
wallet.WalletController, wallet.WalletController, wallet.WalletController, wallet.WalletController,
r.server.cc.feeEstimator, r.server.cc.signer, r.server.cc.FeeEstimator, r.server.cc.Signer,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -1312,7 +1312,7 @@ func (r *rpcServer) SendMany(ctx context.Context,
// appropriate fee rate for this transaction. // appropriate fee rate for this transaction.
satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight() satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight()
feePerKw, err := sweep.DetermineFeePerKw( feePerKw, err := sweep.DetermineFeePerKw(
r.server.cc.feeEstimator, sweep.FeePreference{ r.server.cc.FeeEstimator, sweep.FeePreference{
ConfTarget: uint32(in.TargetConf), ConfTarget: uint32(in.TargetConf),
FeeRate: satPerKw, FeeRate: satPerKw,
}, },
@ -1341,7 +1341,7 @@ func (r *rpcServer) SendMany(ctx context.Context,
// We'll attempt to send to the target set of outputs, ensuring that we // We'll attempt to send to the target set of outputs, ensuring that we
// synchronize with any other ongoing coin selection attempts which // synchronize with any other ongoing coin selection attempts which
// happen to also be concurrently executing. // happen to also be concurrently executing.
wallet := r.server.cc.wallet wallet := r.server.cc.Wallet
err = wallet.WithCoinSelectLock(func() error { err = wallet.WithCoinSelectLock(func() error {
sendManyTXID, err := r.sendCoinsOnChain( sendManyTXID, err := r.sendCoinsOnChain(
in.AddrToAmount, feePerKw, minConfs, label, in.AddrToAmount, feePerKw, minConfs, label,
@ -1375,7 +1375,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
) )
switch in.Type { switch in.Type {
case lnrpc.AddressType_WITNESS_PUBKEY_HASH: case lnrpc.AddressType_WITNESS_PUBKEY_HASH:
addr, err = r.server.cc.wallet.NewAddress( addr, err = r.server.cc.Wallet.NewAddress(
lnwallet.WitnessPubKey, false, lnwallet.WitnessPubKey, false,
) )
if err != nil { if err != nil {
@ -1383,7 +1383,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
} }
case lnrpc.AddressType_NESTED_PUBKEY_HASH: case lnrpc.AddressType_NESTED_PUBKEY_HASH:
addr, err = r.server.cc.wallet.NewAddress( addr, err = r.server.cc.Wallet.NewAddress(
lnwallet.NestedWitnessPubKey, false, lnwallet.NestedWitnessPubKey, false,
) )
if err != nil { if err != nil {
@ -1391,7 +1391,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
} }
case lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH: case lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH:
addr, err = r.server.cc.wallet.LastUnusedAddress( addr, err = r.server.cc.Wallet.LastUnusedAddress(
lnwallet.WitnessPubKey, lnwallet.WitnessPubKey,
) )
if err != nil { if err != nil {
@ -1399,7 +1399,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
} }
case lnrpc.AddressType_UNUSED_NESTED_PUBKEY_HASH: case lnrpc.AddressType_UNUSED_NESTED_PUBKEY_HASH:
addr, err = r.server.cc.wallet.LastUnusedAddress( addr, err = r.server.cc.Wallet.LastUnusedAddress(
lnwallet.NestedWitnessPubKey, lnwallet.NestedWitnessPubKey,
) )
if err != nil { if err != nil {
@ -1743,7 +1743,7 @@ func (r *rpcServer) canOpenChannel() error {
// Creation of channels before the wallet syncs up is currently // Creation of channels before the wallet syncs up is currently
// disallowed. // disallowed.
isSynced, _, err := r.server.cc.wallet.IsSynced() isSynced, _, err := r.server.cc.Wallet.IsSynced()
if err != nil { if err != nil {
return err return err
} }
@ -1863,7 +1863,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
// appropriate fee rate for the funding transaction. // appropriate fee rate for the funding transaction.
satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight() satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight()
feeRate, err := sweep.DetermineFeePerKw( feeRate, err := sweep.DetermineFeePerKw(
r.server.cc.feeEstimator, sweep.FeePreference{ r.server.cc.FeeEstimator, sweep.FeePreference{
ConfTarget: uint32(in.TargetConf), ConfTarget: uint32(in.TargetConf),
FeeRate: satPerKw, FeeRate: satPerKw,
}, },
@ -1931,7 +1931,7 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
// to obtain the channel point details. // to obtain the channel point details.
copy(req.pendingChanID[:], chanPointShim.PendingChanId) copy(req.pendingChanID[:], chanPointShim.PendingChanId)
req.chanFunder, err = newFundingShimAssembler( req.chanFunder, err = newFundingShimAssembler(
chanPointShim, true, r.server.cc.keyRing, chanPointShim, true, r.server.cc.KeyRing,
) )
if err != nil { if err != nil {
return err return err
@ -1950,7 +1950,7 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
copy(req.pendingChanID[:], psbtShim.PendingChanId) copy(req.pendingChanID[:], psbtShim.PendingChanId)
req.chanFunder, err = newPsbtAssembler( req.chanFunder, err = newPsbtAssembler(
in, req.minConfs, psbtShim, in, req.minConfs, psbtShim,
&r.server.cc.wallet.Cfg.NetParams, &r.server.cc.Wallet.Cfg.NetParams,
) )
if err != nil { if err != nil {
return err return err
@ -2155,7 +2155,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
// Retrieve the best height of the chain, which we'll use to complete // Retrieve the best height of the chain, which we'll use to complete
// either closing flow. // either closing flow.
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock() _, bestHeight, err := r.server.cc.ChainIO.GetBestBlock()
if err != nil { if err != nil {
return err return err
} }
@ -2202,7 +2202,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
} }
errChan = make(chan error, 1) errChan = make(chan error, 1)
notifier := r.server.cc.chainNotifier notifier := r.server.cc.ChainNotifier
go peer.WaitForChanToClose(uint32(bestHeight), notifier, errChan, chanPoint, go peer.WaitForChanToClose(uint32(bestHeight), notifier, errChan, chanPoint,
&closingTxid, closingTx.TxOut[0].PkScript, func() { &closingTxid, closingTx.TxOut[0].PkScript, func() {
// Respond to the local subsystem which // Respond to the local subsystem which
@ -2246,7 +2246,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
in.SatPerByte * 1000, in.SatPerByte * 1000,
).FeePerKWeight() ).FeePerKWeight()
feeRate, err := sweep.DetermineFeePerKw( feeRate, err := sweep.DetermineFeePerKw(
r.server.cc.feeEstimator, sweep.FeePreference{ r.server.cc.FeeEstimator, sweep.FeePreference{
ConfTarget: uint32(in.TargetConf), ConfTarget: uint32(in.TargetConf),
FeeRate: satPerKw, FeeRate: satPerKw,
}, },
@ -2408,7 +2408,7 @@ func (r *rpcServer) AbandonChannel(_ context.Context,
// When we remove the channel from the database, we need to set a close // When we remove the channel from the database, we need to set a close
// height, so we'll just use the current best known height. // height, so we'll just use the current best known height.
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock() _, bestHeight, err := r.server.cc.ChainIO.GetBestBlock()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -2522,12 +2522,12 @@ func (r *rpcServer) GetInfo(ctx context.Context,
idPub := r.server.identityECDH.PubKey().SerializeCompressed() idPub := r.server.identityECDH.PubKey().SerializeCompressed()
encodedIDPub := hex.EncodeToString(idPub) encodedIDPub := hex.EncodeToString(idPub)
bestHash, bestHeight, err := r.server.cc.chainIO.GetBestBlock() bestHash, bestHeight, err := r.server.cc.ChainIO.GetBestBlock()
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to get best block info: %v", err) return nil, fmt.Errorf("unable to get best block info: %v", err)
} }
isSynced, bestHeaderTimestamp, err := r.server.cc.wallet.IsSynced() isSynced, bestHeaderTimestamp, err := r.server.cc.Wallet.IsSynced()
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to sync PoV of the wallet "+ return nil, fmt.Errorf("unable to sync PoV of the wallet "+
"with current best block in the main chain: %v", err) "with current best block in the main chain: %v", err)
@ -2603,7 +2603,7 @@ func (r *rpcServer) GetInfo(ctx context.Context,
func (r *rpcServer) GetRecoveryInfo(ctx context.Context, func (r *rpcServer) GetRecoveryInfo(ctx context.Context,
in *lnrpc.GetRecoveryInfoRequest) (*lnrpc.GetRecoveryInfoResponse, error) { in *lnrpc.GetRecoveryInfoRequest) (*lnrpc.GetRecoveryInfoResponse, error) {
isRecoveryMode, progress, err := r.server.cc.wallet.GetRecoveryInfo() isRecoveryMode, progress, err := r.server.cc.Wallet.GetRecoveryInfo()
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to get wallet recovery info: %v", err) return nil, fmt.Errorf("unable to get wallet recovery info: %v", err)
} }
@ -2804,7 +2804,7 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
in *lnrpc.WalletBalanceRequest) (*lnrpc.WalletBalanceResponse, error) { in *lnrpc.WalletBalanceRequest) (*lnrpc.WalletBalanceResponse, error) {
// Get total balance, from txs that have >= 0 confirmations. // Get total balance, from txs that have >= 0 confirmations.
totalBal, err := r.server.cc.wallet.ConfirmedBalance(0) totalBal, err := r.server.cc.Wallet.ConfirmedBalance(0)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -2812,7 +2812,7 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
// Get confirmed balance, from txs that have >= 1 confirmations. // Get confirmed balance, from txs that have >= 1 confirmations.
// TODO(halseth): get both unconfirmed and confirmed balance in one // TODO(halseth): get both unconfirmed and confirmed balance in one
// call, as this is racy. // call, as this is racy.
confirmedBal, err := r.server.cc.wallet.ConfirmedBalance(1) confirmedBal, err := r.server.cc.Wallet.ConfirmedBalance(1)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -2980,7 +2980,7 @@ func (r *rpcServer) PendingChannels(ctx context.Context,
} }
} }
_, currentHeight, err := r.server.cc.chainIO.GetBestBlock() _, currentHeight, err := r.server.cc.ChainIO.GetBestBlock()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -4880,7 +4880,7 @@ func (r *rpcServer) SubscribeInvoices(req *lnrpc.InvoiceSubscription,
func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest, func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest,
updateStream lnrpc.Lightning_SubscribeTransactionsServer) error { updateStream lnrpc.Lightning_SubscribeTransactionsServer) error {
txClient, err := r.server.cc.wallet.SubscribeTransactions() txClient, err := r.server.cc.Wallet.SubscribeTransactions()
if err != nil { if err != nil {
return err return err
} }
@ -4946,7 +4946,7 @@ func (r *rpcServer) GetTransactions(ctx context.Context,
endHeight = req.EndHeight endHeight = req.EndHeight
} }
transactions, err := r.server.cc.wallet.ListTransactionDetails( transactions, err := r.server.cc.Wallet.ListTransactionDetails(
req.StartHeight, endHeight, req.StartHeight, endHeight,
) )
if err != nil { if err != nil {
@ -6047,7 +6047,7 @@ func (r *rpcServer) ExportChannelBackup(ctx context.Context,
// backup. // backup.
packedBackups, err := chanbackup.PackStaticChanBackups( packedBackups, err := chanbackup.PackStaticChanBackups(
[]chanbackup.Single{*unpackedBackup}, []chanbackup.Single{*unpackedBackup},
r.server.cc.keyRing, r.server.cc.KeyRing,
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("packing of back ups failed: %v", err) return nil, fmt.Errorf("packing of back ups failed: %v", err)
@ -6104,7 +6104,7 @@ func (r *rpcServer) VerifyChanBackup(ctx context.Context,
// With our PackedSingles created, we'll attempt to unpack the // With our PackedSingles created, we'll attempt to unpack the
// backup. If this fails, then we know the backup is invalid for // backup. If this fails, then we know the backup is invalid for
// some reason. // some reason.
_, err := chanBackup.Unpack(r.server.cc.keyRing) _, err := chanBackup.Unpack(r.server.cc.KeyRing)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid single channel "+ return nil, fmt.Errorf("invalid single channel "+
"backup: %v", err) "backup: %v", err)
@ -6118,7 +6118,7 @@ func (r *rpcServer) VerifyChanBackup(ctx context.Context,
// We'll now attempt to unpack the Multi. If this fails, then we // We'll now attempt to unpack the Multi. If this fails, then we
// know it's invalid. // know it's invalid.
_, err := packedMulti.Unpack(r.server.cc.keyRing) _, err := packedMulti.Unpack(r.server.cc.KeyRing)
if err != nil { if err != nil {
return nil, fmt.Errorf("invalid multi channel backup: "+ return nil, fmt.Errorf("invalid multi channel backup: "+
"%v", err) "%v", err)
@ -6137,7 +6137,7 @@ func (r *rpcServer) createBackupSnapshot(backups []chanbackup.Single) (
// Once we have the set of back ups, we'll attempt to pack them all // Once we have the set of back ups, we'll attempt to pack them all
// into a series of single channel backups. // into a series of single channel backups.
singleChanPackedBackups, err := chanbackup.PackStaticChanBackups( singleChanPackedBackups, err := chanbackup.PackStaticChanBackups(
backups, r.server.cc.keyRing, backups, r.server.cc.KeyRing,
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to pack set of chan "+ return nil, fmt.Errorf("unable to pack set of chan "+
@ -6175,7 +6175,7 @@ func (r *rpcServer) createBackupSnapshot(backups []chanbackup.Single) (
unpackedMultiBackup := chanbackup.Multi{ unpackedMultiBackup := chanbackup.Multi{
StaticBackups: backups, StaticBackups: backups,
} }
err = unpackedMultiBackup.PackToWriter(&b, r.server.cc.keyRing) err = unpackedMultiBackup.PackToWriter(&b, r.server.cc.KeyRing)
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to multi-pack backups: %v", err) return nil, fmt.Errorf("unable to multi-pack backups: %v", err)
} }
@ -6230,7 +6230,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
// backups. // backups.
chanRestorer := &chanDBRestorer{ chanRestorer := &chanDBRestorer{
db: r.server.remoteChanDB, db: r.server.remoteChanDB,
secretKeys: r.server.cc.keyRing, secretKeys: r.server.cc.KeyRing,
chainArb: r.server.chainArb, chainArb: r.server.chainArb,
} }
@ -6255,7 +6255,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
// channel peers. // channel peers.
err := chanbackup.UnpackAndRecoverSingles( err := chanbackup.UnpackAndRecoverSingles(
chanbackup.PackedSingles(packedBackups), chanbackup.PackedSingles(packedBackups),
r.server.cc.keyRing, chanRestorer, r.server, r.server.cc.KeyRing, chanRestorer, r.server,
) )
if err != nil { if err != nil {
return nil, fmt.Errorf("unable to unpack single "+ return nil, fmt.Errorf("unable to unpack single "+
@ -6271,7 +6271,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
// channel peers. // channel peers.
packedMulti := chanbackup.PackedMulti(packedMultiBackup) packedMulti := chanbackup.PackedMulti(packedMultiBackup)
err := chanbackup.UnpackAndRecoverMulti( err := chanbackup.UnpackAndRecoverMulti(
packedMulti, r.server.cc.keyRing, chanRestorer, packedMulti, r.server.cc.KeyRing, chanRestorer,
r.server, r.server,
) )
if err != nil { if err != nil {
@ -6714,7 +6714,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
// chanfunding.Assembler that is able to express proper // chanfunding.Assembler that is able to express proper
// formulation of this expected channel. // formulation of this expected channel.
shimAssembler, err := newFundingShimAssembler( shimAssembler, err := newFundingShimAssembler(
rpcShimIntent, false, r.server.cc.keyRing, rpcShimIntent, false, r.server.cc.KeyRing,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -6732,7 +6732,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
// pending channel ID, then this shim will be dispatched in // pending channel ID, then this shim will be dispatched in
// place of our regular funding workflow. // place of our regular funding workflow.
copy(pendingChanID[:], rpcShimIntent.PendingChanId) copy(pendingChanID[:], rpcShimIntent.PendingChanId)
err = r.server.cc.wallet.RegisterFundingIntent( err = r.server.cc.Wallet.RegisterFundingIntent(
pendingChanID, shimIntent, pendingChanID, shimIntent,
) )
if err != nil { if err != nil {
@ -6756,7 +6756,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
in.GetShimCancel().PendingChanId) in.GetShimCancel().PendingChanId)
copy(pendingChanID[:], in.GetShimCancel().PendingChanId) copy(pendingChanID[:], in.GetShimCancel().PendingChanId)
err := r.server.cc.wallet.CancelFundingIntent(pendingChanID) err := r.server.cc.Wallet.CancelFundingIntent(pendingChanID)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -6776,7 +6776,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
return nil, fmt.Errorf("error parsing psbt: %v", err) return nil, fmt.Errorf("error parsing psbt: %v", err)
} }
err = r.server.cc.wallet.PsbtFundingVerify( err = r.server.cc.Wallet.PsbtFundingVerify(
pendingChanID, packet, pendingChanID, packet,
) )
if err != nil { if err != nil {
@ -6829,7 +6829,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
"finalize missing") "finalize missing")
} }
err = r.server.cc.wallet.PsbtFundingFinalize( err = r.server.cc.Wallet.PsbtFundingFinalize(
pendingChanID, packet, rawTx, pendingChanID, packet, rawTx,
) )
if err != nil { if err != nil {

120
server.go
View File

@ -204,7 +204,7 @@ type server struct {
// intended to replace it. // intended to replace it.
scheduledPeerConnection map[string]func() scheduledPeerConnection map[string]func()
cc *chainControl cc *ChainControl
fundingMgr *fundingManager fundingMgr *fundingManager
@ -339,7 +339,7 @@ func noiseDial(idKey keychain.SingleKeyECDH,
// passed listener address. // passed listener address.
func newServer(cfg *Config, listenAddrs []net.Addr, func newServer(cfg *Config, listenAddrs []net.Addr,
localChanDB, remoteChanDB *channeldb.DB, localChanDB, remoteChanDB *channeldb.DB,
towerClientDB *wtdb.ClientDB, cc *chainControl, towerClientDB *wtdb.ClientDB, cc *ChainControl,
nodeKeyDesc *keychain.KeyDescriptor, nodeKeyDesc *keychain.KeyDescriptor,
chansToRestore walletunlocker.ChannelsToRecover, chansToRestore walletunlocker.ChannelsToRecover,
chanPredicate chanacceptor.ChannelAcceptor, chanPredicate chanacceptor.ChannelAcceptor,
@ -347,9 +347,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
var ( var (
err error err error
nodeKeyECDH = keychain.NewPubKeyECDH(*nodeKeyDesc, cc.keyRing) nodeKeyECDH = keychain.NewPubKeyECDH(*nodeKeyDesc, cc.KeyRing)
nodeKeySigner = keychain.NewPubKeyDigestSigner( nodeKeySigner = keychain.NewPubKeyDigestSigner(
*nodeKeyDesc, cc.keyRing, *nodeKeyDesc, cc.KeyRing,
) )
) )
@ -375,7 +375,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
sharedSecretPath := filepath.Join( sharedSecretPath := filepath.Join(
cfg.localDatabaseDir(), defaultSphinxDbName, cfg.localDatabaseDir(), defaultSphinxDbName,
) )
replayLog := htlcswitch.NewDecayedLog(sharedSecretPath, cc.chainNotifier) replayLog := htlcswitch.NewDecayedLog(sharedSecretPath, cc.ChainNotifier)
sphinxRouter := sphinx.NewRouter( sphinxRouter := sphinx.NewRouter(
nodeKeyECDH, cfg.ActiveNetParams.Params, replayLog, nodeKeyECDH, cfg.ActiveNetParams.Params, replayLog,
) )
@ -423,7 +423,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
localChanDB: localChanDB, localChanDB: localChanDB,
remoteChanDB: remoteChanDB, remoteChanDB: remoteChanDB,
cc: cc, cc: cc,
sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.signer), sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.Signer),
writePool: writePool, writePool: writePool,
readPool: readPool, readPool: readPool,
chansToRestore: chansToRestore, chansToRestore: chansToRestore,
@ -469,7 +469,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
subscribers: make(map[uint64]*preimageSubscriber), subscribers: make(map[uint64]*preimageSubscriber),
} }
_, currentHeight, err := s.cc.chainIO.GetBestBlock() _, currentHeight, err := s.cc.ChainIO.GetBestBlock()
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -496,7 +496,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
SwitchPackager: channeldb.NewSwitchPackager(), SwitchPackager: channeldb.NewSwitchPackager(),
ExtractErrorEncrypter: s.sphinx.ExtractErrorEncrypter, ExtractErrorEncrypter: s.sphinx.ExtractErrorEncrypter,
FetchLastChannelUpdate: s.fetchLastChanUpdate(), FetchLastChannelUpdate: s.fetchLastChanUpdate(),
Notifier: s.cc.chainNotifier, Notifier: s.cc.ChainNotifier,
HtlcNotifier: s.htlcNotifier, HtlcNotifier: s.htlcNotifier,
FwdEventTicker: ticker.New(htlcswitch.DefaultFwdEventInterval), FwdEventTicker: ticker.New(htlcswitch.DefaultFwdEventInterval),
LogEventTicker: ticker.New(htlcswitch.DefaultLogInterval), LogEventTicker: ticker.New(htlcswitch.DefaultLogInterval),
@ -753,8 +753,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
s.chanRouter, err = routing.New(routing.Config{ s.chanRouter, err = routing.New(routing.Config{
Graph: chanGraph, Graph: chanGraph,
Chain: cc.chainIO, Chain: cc.ChainIO,
ChainView: cc.chainView, ChainView: cc.ChainView,
Payer: s.htlcSwitch, Payer: s.htlcSwitch,
Control: s.controlTower, Control: s.controlTower,
MissionControl: s.missionControl, MissionControl: s.missionControl,
@ -783,7 +783,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
s.authGossiper = discovery.New(discovery.Config{ s.authGossiper = discovery.New(discovery.Config{
Router: s.chanRouter, Router: s.chanRouter,
Notifier: s.cc.chainNotifier, Notifier: s.cc.ChainNotifier,
ChainHash: *s.cfg.ActiveNetParams.GenesisHash, ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
Broadcast: s.BroadcastMessage, Broadcast: s.BroadcastMessage,
ChanSeries: chanSeries, ChanSeries: chanSeries,
@ -834,14 +834,14 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
} }
s.sweeper = sweep.New(&sweep.UtxoSweeperConfig{ s.sweeper = sweep.New(&sweep.UtxoSweeperConfig{
FeeEstimator: cc.feeEstimator, FeeEstimator: cc.FeeEstimator,
GenSweepScript: newSweepPkScriptGen(cc.wallet), GenSweepScript: newSweepPkScriptGen(cc.Wallet),
Signer: cc.wallet.Cfg.Signer, Signer: cc.Wallet.Cfg.Signer,
Wallet: cc.wallet, Wallet: cc.Wallet,
NewBatchTimer: func() <-chan time.Time { NewBatchTimer: func() <-chan time.Time {
return time.NewTimer(sweep.DefaultBatchWindowDuration).C return time.NewTimer(sweep.DefaultBatchWindowDuration).C
}, },
Notifier: cc.chainNotifier, Notifier: cc.ChainNotifier,
Store: sweeperStore, Store: sweeperStore,
MaxInputsPerTx: sweep.DefaultMaxInputsPerTx, MaxInputsPerTx: sweep.DefaultMaxInputsPerTx,
MaxSweepAttempts: sweep.DefaultMaxSweepAttempts, MaxSweepAttempts: sweep.DefaultMaxSweepAttempts,
@ -851,12 +851,12 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
}) })
s.utxoNursery = newUtxoNursery(&NurseryConfig{ s.utxoNursery = newUtxoNursery(&NurseryConfig{
ChainIO: cc.chainIO, ChainIO: cc.ChainIO,
ConfDepth: 1, ConfDepth: 1,
FetchClosedChannels: remoteChanDB.FetchClosedChannels, FetchClosedChannels: remoteChanDB.FetchClosedChannels,
FetchClosedChannel: remoteChanDB.FetchClosedChannel, FetchClosedChannel: remoteChanDB.FetchClosedChannel,
Notifier: cc.chainNotifier, Notifier: cc.ChainNotifier,
PublishTransaction: cc.wallet.PublishTransaction, PublishTransaction: cc.Wallet.PublishTransaction,
Store: utxnStore, Store: utxnStore,
SweepInput: s.sweeper.SweepInput, SweepInput: s.sweeper.SweepInput,
}) })
@ -881,8 +881,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
ChainHash: *s.cfg.ActiveNetParams.GenesisHash, ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
IncomingBroadcastDelta: lncfg.DefaultIncomingBroadcastDelta, IncomingBroadcastDelta: lncfg.DefaultIncomingBroadcastDelta,
OutgoingBroadcastDelta: lncfg.DefaultOutgoingBroadcastDelta, OutgoingBroadcastDelta: lncfg.DefaultOutgoingBroadcastDelta,
NewSweepAddr: newSweepPkScriptGen(cc.wallet), NewSweepAddr: newSweepPkScriptGen(cc.Wallet),
PublishTx: cc.wallet.PublishTransaction, PublishTx: cc.Wallet.PublishTransaction,
DeliverResolutionMsg: func(msgs ...contractcourt.ResolutionMsg) error { DeliverResolutionMsg: func(msgs ...contractcourt.ResolutionMsg) error {
for _, msg := range msgs { for _, msg := range msgs {
err := s.htlcSwitch.ProcessContractResolution(msg) err := s.htlcSwitch.ProcessContractResolution(msg)
@ -914,16 +914,16 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
) )
}, },
PreimageDB: s.witnessBeacon, PreimageDB: s.witnessBeacon,
Notifier: cc.chainNotifier, Notifier: cc.ChainNotifier,
Signer: cc.wallet.Cfg.Signer, Signer: cc.Wallet.Cfg.Signer,
FeeEstimator: cc.feeEstimator, FeeEstimator: cc.FeeEstimator,
ChainIO: cc.chainIO, ChainIO: cc.ChainIO,
MarkLinkInactive: func(chanPoint wire.OutPoint) error { MarkLinkInactive: func(chanPoint wire.OutPoint) error {
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint) chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
s.htlcSwitch.RemoveLink(chanID) s.htlcSwitch.RemoveLink(chanID)
return nil return nil
}, },
IsOurAddress: cc.wallet.IsOurAddress, IsOurAddress: cc.Wallet.IsOurAddress,
ContractBreach: func(chanPoint wire.OutPoint, ContractBreach: func(chanPoint wire.OutPoint,
breachRet *lnwallet.BreachRetribution) error { breachRet *lnwallet.BreachRetribution) error {
event := &ContractBreachEvent{ event := &ContractBreachEvent{
@ -960,12 +960,12 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
s.breachArbiter = newBreachArbiter(&BreachConfig{ s.breachArbiter = newBreachArbiter(&BreachConfig{
CloseLink: closeLink, CloseLink: closeLink,
DB: remoteChanDB, DB: remoteChanDB,
Estimator: s.cc.feeEstimator, Estimator: s.cc.FeeEstimator,
GenSweepScript: newSweepPkScriptGen(cc.wallet), GenSweepScript: newSweepPkScriptGen(cc.Wallet),
Notifier: cc.chainNotifier, Notifier: cc.ChainNotifier,
PublishTransaction: cc.wallet.PublishTransaction, PublishTransaction: cc.Wallet.PublishTransaction,
ContractBreaches: contractBreaches, ContractBreaches: contractBreaches,
Signer: cc.wallet.Cfg.Signer, Signer: cc.Wallet.Cfg.Signer,
Store: newRetributionStore(remoteChanDB), Store: newRetributionStore(remoteChanDB),
}) })
@ -989,13 +989,13 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
s.fundingMgr, err = newFundingManager(fundingConfig{ s.fundingMgr, err = newFundingManager(fundingConfig{
NoWumboChans: !cfg.ProtocolOptions.Wumbo(), NoWumboChans: !cfg.ProtocolOptions.Wumbo(),
IDKey: nodeKeyECDH.PubKey(), IDKey: nodeKeyECDH.PubKey(),
Wallet: cc.wallet, Wallet: cc.Wallet,
PublishTransaction: cc.wallet.PublishTransaction, PublishTransaction: cc.Wallet.PublishTransaction,
UpdateLabel: func(hash chainhash.Hash, label string) error { UpdateLabel: func(hash chainhash.Hash, label string) error {
return cc.wallet.LabelTransaction(hash, label, true) return cc.Wallet.LabelTransaction(hash, label, true)
}, },
Notifier: cc.chainNotifier, Notifier: cc.ChainNotifier,
FeeEstimator: cc.feeEstimator, FeeEstimator: cc.FeeEstimator,
SignMessage: func(pubKey *btcec.PublicKey, SignMessage: func(pubKey *btcec.PublicKey,
msg []byte) (input.Signature, error) { msg []byte) (input.Signature, error) {
@ -1003,7 +1003,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
return s.nodeSigner.SignMessage(pubKey, msg) return s.nodeSigner.SignMessage(pubKey, msg)
} }
return cc.msgSigner.SignMessage(pubKey, msg) return cc.MsgSigner.SignMessage(pubKey, msg)
}, },
CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, error) { CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, error) {
return s.genNodeAnnouncement(true) return s.genNodeAnnouncement(true)
@ -1033,8 +1033,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
return nil, fmt.Errorf("unable to find channel") return nil, fmt.Errorf("unable to find channel")
}, },
DefaultRoutingPolicy: cc.routingPolicy, DefaultRoutingPolicy: cc.RoutingPolicy,
DefaultMinHtlcIn: cc.minHtlcIn, DefaultMinHtlcIn: cc.MinHtlcIn,
NumRequiredConfs: func(chanAmt btcutil.Amount, NumRequiredConfs: func(chanAmt btcutil.Amount,
pushAmt lnwire.MilliSatoshi) uint16 { pushAmt lnwire.MilliSatoshi) uint16 {
// For large channels we increase the number // For large channels we increase the number
@ -1197,7 +1197,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
return nil, err return nil, err
} }
s.chanSubSwapper, err = chanbackup.NewSubSwapper( s.chanSubSwapper, err = chanbackup.NewSubSwapper(
startingChans, chanNotifier, s.cc.keyRing, backupFile, startingChans, chanNotifier, s.cc.KeyRing, backupFile,
) )
if err != nil { if err != nil {
return nil, err return nil, err
@ -1250,9 +1250,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
} }
s.towerClient, err = wtclient.New(&wtclient.Config{ s.towerClient, err = wtclient.New(&wtclient.Config{
Signer: cc.wallet.Cfg.Signer, Signer: cc.Wallet.Cfg.Signer,
NewAddress: newSweepPkScriptGen(cc.wallet), NewAddress: newSweepPkScriptGen(cc.Wallet),
SecretKeyRing: s.cc.keyRing, SecretKeyRing: s.cc.KeyRing,
Dial: cfg.net.Dial, Dial: cfg.net.Dial,
AuthDial: authDial, AuthDial: authDial,
DB: towerClientDB, DB: towerClientDB,
@ -1293,7 +1293,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
chainHealthCheck := healthcheck.NewObservation( chainHealthCheck := healthcheck.NewObservation(
"chain backend", "chain backend",
func() error { func() error {
_, _, err := cc.chainIO.GetBestBlock() _, _, err := cc.ChainIO.GetBestBlock()
return err return err
}, },
cfg.HealthChecks.ChainCheck.Interval, cfg.HealthChecks.ChainCheck.Interval,
@ -1413,7 +1413,7 @@ func (s *server) Start() error {
startErr = err startErr = err
return return
} }
if err := s.cc.chainNotifier.Start(); err != nil { if err := s.cc.ChainNotifier.Start(); err != nil {
startErr = err startErr = err
return return
} }
@ -1491,13 +1491,13 @@ func (s *server) Start() error {
// recovery _before_ we even accept connections from any peers. // recovery _before_ we even accept connections from any peers.
chanRestorer := &chanDBRestorer{ chanRestorer := &chanDBRestorer{
db: s.remoteChanDB, db: s.remoteChanDB,
secretKeys: s.cc.keyRing, secretKeys: s.cc.KeyRing,
chainArb: s.chainArb, chainArb: s.chainArb,
} }
if len(s.chansToRestore.PackedSingleChanBackups) != 0 { if len(s.chansToRestore.PackedSingleChanBackups) != 0 {
err := chanbackup.UnpackAndRecoverSingles( err := chanbackup.UnpackAndRecoverSingles(
s.chansToRestore.PackedSingleChanBackups, s.chansToRestore.PackedSingleChanBackups,
s.cc.keyRing, chanRestorer, s, s.cc.KeyRing, chanRestorer, s,
) )
if err != nil { if err != nil {
startErr = fmt.Errorf("unable to unpack single "+ startErr = fmt.Errorf("unable to unpack single "+
@ -1508,7 +1508,7 @@ func (s *server) Start() error {
if len(s.chansToRestore.PackedMultiChanBackup) != 0 { if len(s.chansToRestore.PackedMultiChanBackup) != 0 {
err := chanbackup.UnpackAndRecoverMulti( err := chanbackup.UnpackAndRecoverMulti(
s.chansToRestore.PackedMultiChanBackup, s.chansToRestore.PackedMultiChanBackup,
s.cc.keyRing, chanRestorer, s, s.cc.KeyRing, chanRestorer, s,
) )
if err != nil { if err != nil {
startErr = fmt.Errorf("unable to unpack chan "+ startErr = fmt.Errorf("unable to unpack chan "+
@ -1579,7 +1579,7 @@ func (s *server) Stop() error {
// Shutdown the wallet, funding manager, and the rpc server. // Shutdown the wallet, funding manager, and the rpc server.
s.chanStatusMgr.Stop() s.chanStatusMgr.Stop()
s.cc.chainNotifier.Stop() s.cc.ChainNotifier.Stop()
s.chanRouter.Stop() s.chanRouter.Stop()
s.htlcSwitch.Stop() s.htlcSwitch.Stop()
s.sphinx.Stop() s.sphinx.Stop()
@ -1591,10 +1591,10 @@ func (s *server) Stop() error {
s.channelNotifier.Stop() s.channelNotifier.Stop()
s.peerNotifier.Stop() s.peerNotifier.Stop()
s.htlcNotifier.Stop() s.htlcNotifier.Stop()
s.cc.wallet.Shutdown() s.cc.Wallet.Shutdown()
s.cc.chainView.Stop() s.cc.ChainView.Stop()
s.connMgr.Stop() s.connMgr.Stop()
s.cc.feeEstimator.Stop() s.cc.FeeEstimator.Stop()
s.invoices.Stop() s.invoices.Stop()
s.fundingMgr.Stop() s.fundingMgr.Stop()
s.chanSubSwapper.Stop() s.chanSubSwapper.Stop()
@ -1853,7 +1853,7 @@ func initNetworkBootstrappers(s *server) ([]discovery.NetworkPeerBootstrapper, e
// If this isn't simnet mode, then one of our additional bootstrapping // If this isn't simnet mode, then one of our additional bootstrapping
// sources will be the set of running DNS seeds. // sources will be the set of running DNS seeds.
if !s.cfg.Bitcoin.SimNet || !s.cfg.Litecoin.SimNet { if !s.cfg.Bitcoin.SimNet || !s.cfg.Litecoin.SimNet {
dnsSeeds, ok := chainDNSSeeds[*s.cfg.ActiveNetParams.GenesisHash] dnsSeeds, ok := ChainDNSSeeds[*s.cfg.ActiveNetParams.GenesisHash]
// If we have a set of DNS seeds for this chain, then we'll add // If we have a set of DNS seeds for this chain, then we'll add
// it as an additional bootstrapping source. // it as an additional bootstrapping source.
@ -2965,13 +2965,13 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
ChainArb: s.chainArb, ChainArb: s.chainArb,
AuthGossiper: s.authGossiper, AuthGossiper: s.authGossiper,
ChanStatusMgr: s.chanStatusMgr, ChanStatusMgr: s.chanStatusMgr,
ChainIO: s.cc.chainIO, ChainIO: s.cc.ChainIO,
FeeEstimator: s.cc.feeEstimator, FeeEstimator: s.cc.FeeEstimator,
Signer: s.cc.wallet.Cfg.Signer, Signer: s.cc.Wallet.Cfg.Signer,
SigPool: s.sigPool, SigPool: s.sigPool,
Wallet: s.cc.wallet, Wallet: s.cc.Wallet,
ChainNotifier: s.cc.chainNotifier, ChainNotifier: s.cc.ChainNotifier,
RoutingPolicy: s.cc.routingPolicy, RoutingPolicy: s.cc.RoutingPolicy,
Sphinx: s.sphinx, Sphinx: s.sphinx,
WitnessBeacon: s.witnessBeacon, WitnessBeacon: s.witnessBeacon,
Invoices: s.invoices, Invoices: s.invoices,
@ -3573,7 +3573,7 @@ func (s *server) OpenChannel(
// If the fee rate wasn't specified, then we'll use a default // If the fee rate wasn't specified, then we'll use a default
// confirmation target. // confirmation target.
if req.fundingFeePerKw == 0 { if req.fundingFeePerKw == 0 {
estimator := s.cc.feeEstimator estimator := s.cc.FeeEstimator
feeRate, err := estimator.EstimateFeePerKW(6) feeRate, err := estimator.EstimateFeePerKW(6)
if err != nil { if err != nil {
req.err <- err req.err <- err

View File

@ -82,7 +82,7 @@ type subRPCServerConfigs struct {
// //
// NOTE: This MUST be called before any callers are permitted to execute the // NOTE: This MUST be called before any callers are permitted to execute the
// FetchConfig method. // FetchConfig method.
func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl, func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *ChainControl,
networkDir string, macService *macaroons.Service, networkDir string, macService *macaroons.Service,
atpl *autopilot.Manager, atpl *autopilot.Manager,
invoiceRegistry *invoices.InvoiceRegistry, invoiceRegistry *invoices.InvoiceRegistry,
@ -133,10 +133,10 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl
reflect.ValueOf(networkDir), reflect.ValueOf(networkDir),
) )
subCfgValue.FieldByName("Signer").Set( subCfgValue.FieldByName("Signer").Set(
reflect.ValueOf(cc.signer), reflect.ValueOf(cc.Signer),
) )
subCfgValue.FieldByName("KeyRing").Set( subCfgValue.FieldByName("KeyRing").Set(
reflect.ValueOf(cc.keyRing), reflect.ValueOf(cc.KeyRing),
) )
case *walletrpc.Config: case *walletrpc.Config:
@ -149,22 +149,22 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl
reflect.ValueOf(macService), reflect.ValueOf(macService),
) )
subCfgValue.FieldByName("FeeEstimator").Set( subCfgValue.FieldByName("FeeEstimator").Set(
reflect.ValueOf(cc.feeEstimator), reflect.ValueOf(cc.FeeEstimator),
) )
subCfgValue.FieldByName("Wallet").Set( subCfgValue.FieldByName("Wallet").Set(
reflect.ValueOf(cc.wallet), reflect.ValueOf(cc.Wallet),
) )
subCfgValue.FieldByName("CoinSelectionLocker").Set( subCfgValue.FieldByName("CoinSelectionLocker").Set(
reflect.ValueOf(cc.wallet), reflect.ValueOf(cc.Wallet),
) )
subCfgValue.FieldByName("KeyRing").Set( subCfgValue.FieldByName("KeyRing").Set(
reflect.ValueOf(cc.keyRing), reflect.ValueOf(cc.KeyRing),
) )
subCfgValue.FieldByName("Sweeper").Set( subCfgValue.FieldByName("Sweeper").Set(
reflect.ValueOf(sweeper), reflect.ValueOf(sweeper),
) )
subCfgValue.FieldByName("Chain").Set( subCfgValue.FieldByName("Chain").Set(
reflect.ValueOf(cc.chainIO), reflect.ValueOf(cc.ChainIO),
) )
subCfgValue.FieldByName("ChainParams").Set( subCfgValue.FieldByName("ChainParams").Set(
reflect.ValueOf(activeNetParams), reflect.ValueOf(activeNetParams),
@ -187,7 +187,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl
reflect.ValueOf(macService), reflect.ValueOf(macService),
) )
subCfgValue.FieldByName("ChainNotifier").Set( subCfgValue.FieldByName("ChainNotifier").Set(
reflect.ValueOf(cc.chainNotifier), reflect.ValueOf(cc.ChainNotifier),
) )
case *invoicesrpc.Config: case *invoicesrpc.Config: