lnd: export ChainControl, ChainRegistry
This commit is contained in:
parent
cbdea57d52
commit
4d238cfa2f
145
chainregistry.go
145
chainregistry.go
@ -101,40 +101,53 @@ var DefaultLtcChannelConstraints = channeldb.ChannelConstraints{
|
||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||
}
|
||||
|
||||
// chainControl couples the three primary interfaces lnd utilizes for a
|
||||
// particular chain together. A single chainControl instance will exist for all
|
||||
// ChainControl couples the three primary interfaces lnd utilizes for a
|
||||
// particular chain together. A single ChainControl instance will exist for all
|
||||
// the chains lnd is currently active on.
|
||||
type chainControl struct {
|
||||
chainIO lnwallet.BlockChainIO
|
||||
type ChainControl struct {
|
||||
// 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
|
||||
// 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
|
||||
// backed by a running neutrino light client instance. When running with a
|
||||
// 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
|
||||
// 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",
|
||||
cfg.PrimaryChain())
|
||||
|
||||
cc := &chainControl{}
|
||||
cc := &ChainControl{}
|
||||
|
||||
switch cfg.PrimaryChain() {
|
||||
case chainreg.BitcoinChain:
|
||||
cc.routingPolicy = htlcswitch.ForwardingPolicy{
|
||||
cc.RoutingPolicy = htlcswitch.ForwardingPolicy{
|
||||
MinHTLCOut: cfg.Bitcoin.MinHTLCOut,
|
||||
BaseFee: cfg.Bitcoin.BaseFee,
|
||||
FeeRate: cfg.Bitcoin.FeeRate,
|
||||
TimeLockDelta: cfg.Bitcoin.TimeLockDelta,
|
||||
}
|
||||
cc.minHtlcIn = cfg.Bitcoin.MinHTLCIn
|
||||
cc.feeEstimator = chainfee.NewStaticEstimator(
|
||||
cc.MinHtlcIn = cfg.Bitcoin.MinHTLCIn
|
||||
cc.FeeEstimator = chainfee.NewStaticEstimator(
|
||||
DefaultBitcoinStaticFeePerKW,
|
||||
DefaultBitcoinStaticMinRelayFeeRate,
|
||||
)
|
||||
case chainreg.LitecoinChain:
|
||||
cc.routingPolicy = htlcswitch.ForwardingPolicy{
|
||||
cc.RoutingPolicy = htlcswitch.ForwardingPolicy{
|
||||
MinHTLCOut: cfg.Litecoin.MinHTLCOut,
|
||||
BaseFee: cfg.Litecoin.BaseFee,
|
||||
FeeRate: cfg.Litecoin.FeeRate,
|
||||
TimeLockDelta: cfg.Litecoin.TimeLockDelta,
|
||||
}
|
||||
cc.minHtlcIn = cfg.Litecoin.MinHTLCIn
|
||||
cc.feeEstimator = chainfee.NewStaticEstimator(
|
||||
cc.MinHtlcIn = cfg.Litecoin.MinHTLCIn
|
||||
cc.FeeEstimator = chainfee.NewStaticEstimator(
|
||||
DefaultLitecoinStaticFeePerKW, 0,
|
||||
)
|
||||
default:
|
||||
@ -213,10 +226,10 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
// We'll create ChainNotifier and FilteredChainView instances,
|
||||
// along with the wallet's ChainSource, which are all backed by
|
||||
// the neutrino light client.
|
||||
cc.chainNotifier = neutrinonotify.New(
|
||||
cc.ChainNotifier = neutrinonotify.New(
|
||||
cfg.NeutrinoCS, hintCache, hintCache,
|
||||
)
|
||||
cc.chainView, err = chainview.NewCfFilteredChainView(cfg.NeutrinoCS)
|
||||
cc.ChainView, err = chainview.NewCfFilteredChainView(cfg.NeutrinoCS)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -299,10 +312,10 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
"%v", err)
|
||||
}
|
||||
|
||||
cc.chainNotifier = bitcoindnotify.New(
|
||||
cc.ChainNotifier = bitcoindnotify.New(
|
||||
bitcoindConn, cfg.ActiveNetParams.Params, hintCache, hintCache,
|
||||
)
|
||||
cc.chainView = chainview.NewBitcoindFilteredChainView(bitcoindConn)
|
||||
cc.ChainView = chainview.NewBitcoindFilteredChainView(bitcoindConn)
|
||||
walletConfig.ChainSource = bitcoindConn.NewBitcoindClient()
|
||||
|
||||
// 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
|
||||
// coded value.
|
||||
fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000)
|
||||
cc.feeEstimator, err = chainfee.NewBitcoindEstimator(
|
||||
cc.FeeEstimator, err = chainfee.NewBitcoindEstimator(
|
||||
*rpcConfig, bitcoindMode.EstimateMode,
|
||||
fallBackFeeRate.FeePerKWeight(),
|
||||
)
|
||||
@ -341,7 +354,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
// use live fee estimates, rather than a statically
|
||||
// coded value.
|
||||
fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000)
|
||||
cc.feeEstimator, err = chainfee.NewBitcoindEstimator(
|
||||
cc.FeeEstimator, err = chainfee.NewBitcoindEstimator(
|
||||
*rpcConfig, bitcoindMode.EstimateMode,
|
||||
fallBackFeeRate.FeePerKWeight(),
|
||||
)
|
||||
@ -407,7 +420,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
DisableConnectOnNew: true,
|
||||
DisableAutoReconnect: false,
|
||||
}
|
||||
cc.chainNotifier, err = btcdnotify.New(
|
||||
cc.ChainNotifier, err = btcdnotify.New(
|
||||
rpcConfig, cfg.ActiveNetParams.Params, hintCache, hintCache,
|
||||
)
|
||||
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
|
||||
// used within the routing layer.
|
||||
cc.chainView, err = chainview.NewBtcdFilteredChainView(*rpcConfig)
|
||||
cc.ChainView, err = chainview.NewBtcdFilteredChainView(*rpcConfig)
|
||||
if err != nil {
|
||||
srvrLog.Errorf("unable to create chain view: %v", err)
|
||||
return nil, err
|
||||
@ -444,7 +457,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
// live fee estimates, rather than a statically coded
|
||||
// value.
|
||||
fallBackFeeRate := chainfee.SatPerKVByte(25 * 1000)
|
||||
cc.feeEstimator, err = chainfee.NewBtcdEstimator(
|
||||
cc.FeeEstimator, err = chainfee.NewBtcdEstimator(
|
||||
*rpcConfig, fallBackFeeRate.FeePerKWeight(),
|
||||
)
|
||||
if err != nil {
|
||||
@ -465,7 +478,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
ltndLog.Infof("Using external fee estimator %v: cached=%v",
|
||||
cfg.FeeURL, cacheFees)
|
||||
|
||||
cc.feeEstimator = chainfee.NewWebAPIEstimator(
|
||||
cc.FeeEstimator = chainfee.NewWebAPIEstimator(
|
||||
chainfee.SparseConfFeeSource{
|
||||
URL: cfg.FeeURL,
|
||||
},
|
||||
@ -474,7 +487,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
}
|
||||
|
||||
// Start fee estimator.
|
||||
if err := cc.feeEstimator.Start(); err != nil {
|
||||
if err := cc.FeeEstimator.Start(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -484,10 +497,10 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cc.msgSigner = wc
|
||||
cc.signer = wc
|
||||
cc.chainIO = wc
|
||||
cc.wc = wc
|
||||
cc.MsgSigner = wc
|
||||
cc.Signer = wc
|
||||
cc.ChainIO = wc
|
||||
cc.Wc = wc
|
||||
|
||||
// Select the default channel constraints for the primary chain.
|
||||
channelConstraints := DefaultBtcChannelConstraints
|
||||
@ -498,18 +511,18 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
keyRing := keychain.NewBtcWalletKeyRing(
|
||||
wc.InternalWallet(), cfg.ActiveNetParams.CoinType,
|
||||
)
|
||||
cc.keyRing = keyRing
|
||||
cc.KeyRing = keyRing
|
||||
|
||||
// Create, and start the lnwallet, which handles the core payment
|
||||
// channel logic, and exposes control via proxy state machines.
|
||||
walletCfg := lnwallet.Config{
|
||||
Database: cfg.RemoteChanDB,
|
||||
Notifier: cc.chainNotifier,
|
||||
Notifier: cc.ChainNotifier,
|
||||
WalletController: wc,
|
||||
Signer: cc.signer,
|
||||
FeeEstimator: cc.feeEstimator,
|
||||
Signer: cc.Signer,
|
||||
FeeEstimator: cc.FeeEstimator,
|
||||
SecretKeyRing: keyRing,
|
||||
ChainIO: cc.chainIO,
|
||||
ChainIO: cc.ChainIO,
|
||||
DefaultConstraints: channelConstraints,
|
||||
NetParams: *cfg.ActiveNetParams.Params,
|
||||
}
|
||||
@ -525,7 +538,7 @@ func newChainControl(cfg *chainreg.Config) (*chainControl, error) {
|
||||
|
||||
ltndLog.Info("LightningWallet opened")
|
||||
|
||||
cc.wallet = lnWallet
|
||||
cc.Wallet = lnWallet
|
||||
|
||||
return cc, nil
|
||||
}
|
||||
@ -575,7 +588,7 @@ var (
|
||||
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.
|
||||
//
|
||||
// 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
|
||||
// struct like chaincfg.Params
|
||||
chainDNSSeeds = map[chainhash.Hash][][2]string{
|
||||
ChainDNSSeeds = map[chainhash.Hash][][2]string{
|
||||
BitcoinMainnetGenesis: {
|
||||
{
|
||||
"nodes.lightning.directory",
|
||||
@ -614,38 +627,38 @@ var (
|
||||
}
|
||||
)
|
||||
|
||||
// chainRegistry keeps track of the current chains
|
||||
type chainRegistry struct {
|
||||
// ChainRegistry keeps track of the current chains
|
||||
type ChainRegistry struct {
|
||||
sync.RWMutex
|
||||
|
||||
activeChains map[chainreg.ChainCode]*chainControl
|
||||
activeChains map[chainreg.ChainCode]*ChainControl
|
||||
netParams map[chainreg.ChainCode]*chainreg.BitcoinNetParams
|
||||
|
||||
primaryChain chainreg.ChainCode
|
||||
}
|
||||
|
||||
// newChainRegistry creates a new chainRegistry.
|
||||
func newChainRegistry() *chainRegistry {
|
||||
return &chainRegistry{
|
||||
activeChains: make(map[chainreg.ChainCode]*chainControl),
|
||||
// NewChainRegistry creates a new ChainRegistry.
|
||||
func NewChainRegistry() *ChainRegistry {
|
||||
return &ChainRegistry{
|
||||
activeChains: make(map[chainreg.ChainCode]*ChainControl),
|
||||
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.
|
||||
func (c *chainRegistry) RegisterChain(newChain chainreg.ChainCode,
|
||||
cc *chainControl) {
|
||||
func (c *ChainRegistry) RegisterChain(newChain chainreg.ChainCode,
|
||||
cc *ChainControl) {
|
||||
|
||||
c.Lock()
|
||||
c.activeChains[newChain] = cc
|
||||
c.Unlock()
|
||||
}
|
||||
|
||||
// LookupChain attempts to lookup an active chainControl instance for the
|
||||
// LookupChain attempts to lookup an active ChainControl instance for the
|
||||
// target chain.
|
||||
func (c *chainRegistry) LookupChain(targetChain chainreg.ChainCode) (
|
||||
*chainControl, bool) {
|
||||
func (c *ChainRegistry) LookupChain(targetChain chainreg.ChainCode) (
|
||||
*ChainControl, bool) {
|
||||
|
||||
c.RLock()
|
||||
cc, ok := c.activeChains[targetChain]
|
||||
@ -653,9 +666,9 @@ func (c *chainRegistry) LookupChain(targetChain chainreg.ChainCode) (
|
||||
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.
|
||||
func (c *chainRegistry) LookupChainByHash(chainHash chainhash.Hash) (*chainControl, bool) {
|
||||
func (c *ChainRegistry) LookupChainByHash(chainHash chainhash.Hash) (*ChainControl, bool) {
|
||||
c.RLock()
|
||||
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.
|
||||
func (c *chainRegistry) RegisterPrimaryChain(cc chainreg.ChainCode) {
|
||||
func (c *ChainRegistry) RegisterPrimaryChain(cc chainreg.ChainCode) {
|
||||
c.Lock()
|
||||
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
|
||||
// primary chain is considered the "home base" while the other registered
|
||||
// chains are treated as secondary chains.
|
||||
func (c *chainRegistry) PrimaryChain() chainreg.ChainCode {
|
||||
func (c *ChainRegistry) PrimaryChain() chainreg.ChainCode {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
@ -687,7 +700,7 @@ func (c *chainRegistry) PrimaryChain() chainreg.ChainCode {
|
||||
}
|
||||
|
||||
// ActiveChains returns a slice containing the active chains.
|
||||
func (c *chainRegistry) ActiveChains() []chainreg.ChainCode {
|
||||
func (c *ChainRegistry) ActiveChains() []chainreg.ChainCode {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
@ -700,7 +713,7 @@ func (c *chainRegistry) ActiveChains() []chainreg.ChainCode {
|
||||
}
|
||||
|
||||
// NumActiveChains returns the total number of active chains.
|
||||
func (c *chainRegistry) NumActiveChains() uint32 {
|
||||
func (c *ChainRegistry) NumActiveChains() uint32 {
|
||||
c.RLock()
|
||||
defer c.RUnlock()
|
||||
|
||||
|
@ -312,7 +312,7 @@ type Config struct {
|
||||
|
||||
// registeredChains keeps track of all chains that have been registered
|
||||
// with the daemon.
|
||||
registeredChains *chainRegistry
|
||||
registeredChains *ChainRegistry
|
||||
|
||||
// networkDir is the path to the directory of the currently active
|
||||
// network. This path will hold the files related to each different
|
||||
@ -452,7 +452,7 @@ func DefaultConfig() Config {
|
||||
MaxChannelFeeAllocation: htlcswitch.DefaultMaxLinkFeeAllocation,
|
||||
LogWriter: build.NewRotatingLogWriter(),
|
||||
DB: lncfg.DefaultDB(),
|
||||
registeredChains: newChainRegistry(),
|
||||
registeredChains: NewChainRegistry(),
|
||||
ActiveNetParams: chainreg.BitcoinTestNetParams,
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +358,7 @@ type fundingConfig struct {
|
||||
|
||||
// RegisteredChains keeps track of all chains that have been registered
|
||||
// with the daemon.
|
||||
RegisteredChains *chainRegistry
|
||||
RegisteredChains *ChainRegistry
|
||||
}
|
||||
|
||||
// fundingManager acts as an orchestrator/bridge between the wallet's
|
||||
|
@ -437,7 +437,7 @@ func createTestFundingManager(t *testing.T, privKey *btcec.PrivateKey,
|
||||
NotifyOpenChannelEvent: evt.NotifyOpenChannelEvent,
|
||||
OpenChannelPredicate: chainedAcceptor,
|
||||
NotifyPendingOpenChannelEvent: evt.NotifyPendingOpenChannelEvent,
|
||||
RegisteredChains: newChainRegistry(),
|
||||
RegisteredChains: NewChainRegistry(),
|
||||
}
|
||||
|
||||
for _, op := range options {
|
||||
|
22
lnd.go
22
lnd.go
@ -472,7 +472,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
FeeURL: cfg.FeeURL,
|
||||
}
|
||||
|
||||
activeChainControl, err := newChainControl(chainControlCfg)
|
||||
activeChainControl, err := NewChainControl(chainControlCfg)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to create chain control: %v", err)
|
||||
ltndLog.Error(err)
|
||||
@ -486,7 +486,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
cfg.registeredChains.RegisterChain(primaryChain, activeChainControl)
|
||||
|
||||
// TODO(roasbeef): add rotation
|
||||
idKeyDesc, err := activeChainControl.keyRing.DeriveKey(
|
||||
idKeyDesc, err := activeChainControl.KeyRing.DeriveKey(
|
||||
keychain.KeyLocator{
|
||||
Family: keychain.KeyFamilyNodeKey,
|
||||
Index: 0,
|
||||
@ -559,7 +559,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
}
|
||||
defer towerDB.Close()
|
||||
|
||||
towerKeyDesc, err := activeChainControl.keyRing.DeriveKey(
|
||||
towerKeyDesc, err := activeChainControl.KeyRing.DeriveKey(
|
||||
keychain.KeyLocator{
|
||||
Family: keychain.KeyFamilyTowerID,
|
||||
Index: 0,
|
||||
@ -572,19 +572,19 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
}
|
||||
|
||||
wtCfg := &watchtower.Config{
|
||||
BlockFetcher: activeChainControl.chainIO,
|
||||
BlockFetcher: activeChainControl.ChainIO,
|
||||
DB: towerDB,
|
||||
EpochRegistrar: activeChainControl.chainNotifier,
|
||||
EpochRegistrar: activeChainControl.ChainNotifier,
|
||||
Net: cfg.net,
|
||||
NewAddress: func() (btcutil.Address, error) {
|
||||
return activeChainControl.wallet.NewAddress(
|
||||
return activeChainControl.Wallet.NewAddress(
|
||||
lnwallet.WitnessPubKey, false,
|
||||
)
|
||||
},
|
||||
NodeKeyECDH: keychain.NewPubKeyECDH(
|
||||
towerKeyDesc, activeChainControl.keyRing,
|
||||
towerKeyDesc, activeChainControl.KeyRing,
|
||||
),
|
||||
PublishTx: activeChainControl.wallet.PublishTransaction,
|
||||
PublishTx: activeChainControl.Wallet.PublishTransaction,
|
||||
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 ||
|
||||
cfg.Litecoin.RegTest || cfg.Litecoin.SimNet) {
|
||||
|
||||
_, bestHeight, err := activeChainControl.chainIO.GetBestBlock()
|
||||
_, bestHeight, err := activeChainControl.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine chain tip: %v",
|
||||
err)
|
||||
@ -713,7 +713,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
synced, _, err := activeChainControl.wallet.IsSynced()
|
||||
synced, _, err := activeChainControl.Wallet.IsSynced()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine if "+
|
||||
"wallet is synced: %v", err)
|
||||
@ -728,7 +728,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
_, bestHeight, err = activeChainControl.chainIO.GetBestBlock()
|
||||
_, bestHeight, err = activeChainControl.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
err := fmt.Errorf("unable to determine chain tip: %v",
|
||||
err)
|
||||
|
6
pilot.go
6
pilot.go
@ -88,7 +88,7 @@ func (c *chanController) OpenChannel(target *btcec.PublicKey,
|
||||
|
||||
// With the connection established, we'll now establish our connection
|
||||
// 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,
|
||||
)
|
||||
if err != nil {
|
||||
@ -179,7 +179,7 @@ func initAutoPilot(svr *server, cfg *lncfg.AutoPilot,
|
||||
netParams: netParams,
|
||||
},
|
||||
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()),
|
||||
Constraints: atplConstraints,
|
||||
@ -290,7 +290,7 @@ func initAutoPilot(svr *server, cfg *lncfg.AutoPilot,
|
||||
Node: autopilot.NewNodeID(channel.IdentityPub),
|
||||
}, nil
|
||||
},
|
||||
SubscribeTransactions: svr.cc.wallet.SubscribeTransactions,
|
||||
SubscribeTransactions: svr.cc.Wallet.SubscribeTransactions,
|
||||
SubscribeTopology: svr.chanRouter.SubscribeTopology,
|
||||
}, nil
|
||||
}
|
||||
|
88
rpcserver.go
88
rpcserver.go
@ -1051,7 +1051,7 @@ func (r *rpcServer) sendCoinsOnChain(paymentMap map[string]int64,
|
||||
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 {
|
||||
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
|
||||
// be shown available to us.
|
||||
var utxos []*lnwallet.Utxo
|
||||
err = r.server.cc.wallet.WithCoinSelectLock(func() error {
|
||||
utxos, err = r.server.cc.wallet.ListUnspentWitness(
|
||||
err = r.server.cc.Wallet.WithCoinSelectLock(func() error {
|
||||
utxos, err = r.server.cc.Wallet.ListUnspentWitness(
|
||||
minConfs, maxConfs,
|
||||
)
|
||||
return err
|
||||
@ -1126,7 +1126,7 @@ func (r *rpcServer) EstimateFee(ctx context.Context,
|
||||
// target.
|
||||
target := in.TargetConf
|
||||
feePerKw, err := sweep.DetermineFeePerKw(
|
||||
r.server.cc.feeEstimator, sweep.FeePreference{
|
||||
r.server.cc.FeeEstimator, sweep.FeePreference{
|
||||
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
|
||||
// dryRun=true to avoid inflating the change addresses in the db.
|
||||
var tx *txauthor.AuthoredTx
|
||||
wallet := r.server.cc.wallet
|
||||
wallet := r.server.cc.Wallet
|
||||
err = wallet.WithCoinSelectLock(func() error {
|
||||
tx, err = wallet.CreateSimpleTx(outputs, feePerKw, true)
|
||||
return err
|
||||
@ -1173,7 +1173,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
||||
// appropriate fee rate for this transaction.
|
||||
satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight()
|
||||
feePerKw, err := sweep.DetermineFeePerKw(
|
||||
r.server.cc.feeEstimator, sweep.FeePreference{
|
||||
r.server.cc.FeeEstimator, sweep.FeePreference{
|
||||
ConfTarget: uint32(in.TargetConf),
|
||||
FeeRate: satPerKw,
|
||||
},
|
||||
@ -1226,7 +1226,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
||||
|
||||
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
|
||||
// coins in the wallet in a single transaction (if possible),
|
||||
@ -1240,7 +1240,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
||||
"active")
|
||||
}
|
||||
|
||||
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||
_, bestHeight, err := r.server.cc.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1252,7 +1252,7 @@ func (r *rpcServer) SendCoins(ctx context.Context,
|
||||
sweepTxPkg, err := sweep.CraftSweepAllTx(
|
||||
feePerKw, uint32(bestHeight), targetAddr, wallet,
|
||||
wallet.WalletController, wallet.WalletController,
|
||||
r.server.cc.feeEstimator, r.server.cc.signer,
|
||||
r.server.cc.FeeEstimator, r.server.cc.Signer,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1312,7 +1312,7 @@ func (r *rpcServer) SendMany(ctx context.Context,
|
||||
// appropriate fee rate for this transaction.
|
||||
satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight()
|
||||
feePerKw, err := sweep.DetermineFeePerKw(
|
||||
r.server.cc.feeEstimator, sweep.FeePreference{
|
||||
r.server.cc.FeeEstimator, sweep.FeePreference{
|
||||
ConfTarget: uint32(in.TargetConf),
|
||||
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
|
||||
// synchronize with any other ongoing coin selection attempts which
|
||||
// happen to also be concurrently executing.
|
||||
wallet := r.server.cc.wallet
|
||||
wallet := r.server.cc.Wallet
|
||||
err = wallet.WithCoinSelectLock(func() error {
|
||||
sendManyTXID, err := r.sendCoinsOnChain(
|
||||
in.AddrToAmount, feePerKw, minConfs, label,
|
||||
@ -1375,7 +1375,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
|
||||
)
|
||||
switch in.Type {
|
||||
case lnrpc.AddressType_WITNESS_PUBKEY_HASH:
|
||||
addr, err = r.server.cc.wallet.NewAddress(
|
||||
addr, err = r.server.cc.Wallet.NewAddress(
|
||||
lnwallet.WitnessPubKey, false,
|
||||
)
|
||||
if err != nil {
|
||||
@ -1383,7 +1383,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
|
||||
}
|
||||
|
||||
case lnrpc.AddressType_NESTED_PUBKEY_HASH:
|
||||
addr, err = r.server.cc.wallet.NewAddress(
|
||||
addr, err = r.server.cc.Wallet.NewAddress(
|
||||
lnwallet.NestedWitnessPubKey, false,
|
||||
)
|
||||
if err != nil {
|
||||
@ -1391,7 +1391,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
|
||||
}
|
||||
|
||||
case lnrpc.AddressType_UNUSED_WITNESS_PUBKEY_HASH:
|
||||
addr, err = r.server.cc.wallet.LastUnusedAddress(
|
||||
addr, err = r.server.cc.Wallet.LastUnusedAddress(
|
||||
lnwallet.WitnessPubKey,
|
||||
)
|
||||
if err != nil {
|
||||
@ -1399,7 +1399,7 @@ func (r *rpcServer) NewAddress(ctx context.Context,
|
||||
}
|
||||
|
||||
case lnrpc.AddressType_UNUSED_NESTED_PUBKEY_HASH:
|
||||
addr, err = r.server.cc.wallet.LastUnusedAddress(
|
||||
addr, err = r.server.cc.Wallet.LastUnusedAddress(
|
||||
lnwallet.NestedWitnessPubKey,
|
||||
)
|
||||
if err != nil {
|
||||
@ -1743,7 +1743,7 @@ func (r *rpcServer) canOpenChannel() error {
|
||||
|
||||
// Creation of channels before the wallet syncs up is currently
|
||||
// disallowed.
|
||||
isSynced, _, err := r.server.cc.wallet.IsSynced()
|
||||
isSynced, _, err := r.server.cc.Wallet.IsSynced()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -1863,7 +1863,7 @@ func (r *rpcServer) parseOpenChannelReq(in *lnrpc.OpenChannelRequest,
|
||||
// appropriate fee rate for the funding transaction.
|
||||
satPerKw := chainfee.SatPerKVByte(in.SatPerByte * 1000).FeePerKWeight()
|
||||
feeRate, err := sweep.DetermineFeePerKw(
|
||||
r.server.cc.feeEstimator, sweep.FeePreference{
|
||||
r.server.cc.FeeEstimator, sweep.FeePreference{
|
||||
ConfTarget: uint32(in.TargetConf),
|
||||
FeeRate: satPerKw,
|
||||
},
|
||||
@ -1931,7 +1931,7 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
|
||||
// to obtain the channel point details.
|
||||
copy(req.pendingChanID[:], chanPointShim.PendingChanId)
|
||||
req.chanFunder, err = newFundingShimAssembler(
|
||||
chanPointShim, true, r.server.cc.keyRing,
|
||||
chanPointShim, true, r.server.cc.KeyRing,
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
@ -1950,7 +1950,7 @@ func (r *rpcServer) OpenChannel(in *lnrpc.OpenChannelRequest,
|
||||
copy(req.pendingChanID[:], psbtShim.PendingChanId)
|
||||
req.chanFunder, err = newPsbtAssembler(
|
||||
in, req.minConfs, psbtShim,
|
||||
&r.server.cc.wallet.Cfg.NetParams,
|
||||
&r.server.cc.Wallet.Cfg.NetParams,
|
||||
)
|
||||
if err != nil {
|
||||
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
|
||||
// either closing flow.
|
||||
_, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||
_, bestHeight, err := r.server.cc.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -2202,7 +2202,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
}
|
||||
|
||||
errChan = make(chan error, 1)
|
||||
notifier := r.server.cc.chainNotifier
|
||||
notifier := r.server.cc.ChainNotifier
|
||||
go peer.WaitForChanToClose(uint32(bestHeight), notifier, errChan, chanPoint,
|
||||
&closingTxid, closingTx.TxOut[0].PkScript, func() {
|
||||
// Respond to the local subsystem which
|
||||
@ -2246,7 +2246,7 @@ func (r *rpcServer) CloseChannel(in *lnrpc.CloseChannelRequest,
|
||||
in.SatPerByte * 1000,
|
||||
).FeePerKWeight()
|
||||
feeRate, err := sweep.DetermineFeePerKw(
|
||||
r.server.cc.feeEstimator, sweep.FeePreference{
|
||||
r.server.cc.FeeEstimator, sweep.FeePreference{
|
||||
ConfTarget: uint32(in.TargetConf),
|
||||
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
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
@ -2522,12 +2522,12 @@ func (r *rpcServer) GetInfo(ctx context.Context,
|
||||
idPub := r.server.identityECDH.PubKey().SerializeCompressed()
|
||||
encodedIDPub := hex.EncodeToString(idPub)
|
||||
|
||||
bestHash, bestHeight, err := r.server.cc.chainIO.GetBestBlock()
|
||||
bestHash, bestHeight, err := r.server.cc.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
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 {
|
||||
return nil, fmt.Errorf("unable to sync PoV of the wallet "+
|
||||
"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,
|
||||
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 {
|
||||
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) {
|
||||
|
||||
// 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 {
|
||||
return nil, err
|
||||
}
|
||||
@ -2812,7 +2812,7 @@ func (r *rpcServer) WalletBalance(ctx context.Context,
|
||||
// Get confirmed balance, from txs that have >= 1 confirmations.
|
||||
// TODO(halseth): get both unconfirmed and confirmed balance in one
|
||||
// call, as this is racy.
|
||||
confirmedBal, err := r.server.cc.wallet.ConfirmedBalance(1)
|
||||
confirmedBal, err := r.server.cc.Wallet.ConfirmedBalance(1)
|
||||
if err != nil {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
@ -4880,7 +4880,7 @@ func (r *rpcServer) SubscribeInvoices(req *lnrpc.InvoiceSubscription,
|
||||
func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest,
|
||||
updateStream lnrpc.Lightning_SubscribeTransactionsServer) error {
|
||||
|
||||
txClient, err := r.server.cc.wallet.SubscribeTransactions()
|
||||
txClient, err := r.server.cc.Wallet.SubscribeTransactions()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -4946,7 +4946,7 @@ func (r *rpcServer) GetTransactions(ctx context.Context,
|
||||
endHeight = req.EndHeight
|
||||
}
|
||||
|
||||
transactions, err := r.server.cc.wallet.ListTransactionDetails(
|
||||
transactions, err := r.server.cc.Wallet.ListTransactionDetails(
|
||||
req.StartHeight, endHeight,
|
||||
)
|
||||
if err != nil {
|
||||
@ -6047,7 +6047,7 @@ func (r *rpcServer) ExportChannelBackup(ctx context.Context,
|
||||
// backup.
|
||||
packedBackups, err := chanbackup.PackStaticChanBackups(
|
||||
[]chanbackup.Single{*unpackedBackup},
|
||||
r.server.cc.keyRing,
|
||||
r.server.cc.KeyRing,
|
||||
)
|
||||
if err != nil {
|
||||
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
|
||||
// backup. If this fails, then we know the backup is invalid for
|
||||
// some reason.
|
||||
_, err := chanBackup.Unpack(r.server.cc.keyRing)
|
||||
_, err := chanBackup.Unpack(r.server.cc.KeyRing)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid single channel "+
|
||||
"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
|
||||
// know it's invalid.
|
||||
_, err := packedMulti.Unpack(r.server.cc.keyRing)
|
||||
_, err := packedMulti.Unpack(r.server.cc.KeyRing)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid multi channel backup: "+
|
||||
"%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
|
||||
// into a series of single channel backups.
|
||||
singleChanPackedBackups, err := chanbackup.PackStaticChanBackups(
|
||||
backups, r.server.cc.keyRing,
|
||||
backups, r.server.cc.KeyRing,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to pack set of chan "+
|
||||
@ -6175,7 +6175,7 @@ func (r *rpcServer) createBackupSnapshot(backups []chanbackup.Single) (
|
||||
unpackedMultiBackup := chanbackup.Multi{
|
||||
StaticBackups: backups,
|
||||
}
|
||||
err = unpackedMultiBackup.PackToWriter(&b, r.server.cc.keyRing)
|
||||
err = unpackedMultiBackup.PackToWriter(&b, r.server.cc.KeyRing)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to multi-pack backups: %v", err)
|
||||
}
|
||||
@ -6230,7 +6230,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
|
||||
// backups.
|
||||
chanRestorer := &chanDBRestorer{
|
||||
db: r.server.remoteChanDB,
|
||||
secretKeys: r.server.cc.keyRing,
|
||||
secretKeys: r.server.cc.KeyRing,
|
||||
chainArb: r.server.chainArb,
|
||||
}
|
||||
|
||||
@ -6255,7 +6255,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
|
||||
// channel peers.
|
||||
err := chanbackup.UnpackAndRecoverSingles(
|
||||
chanbackup.PackedSingles(packedBackups),
|
||||
r.server.cc.keyRing, chanRestorer, r.server,
|
||||
r.server.cc.KeyRing, chanRestorer, r.server,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to unpack single "+
|
||||
@ -6271,7 +6271,7 @@ func (r *rpcServer) RestoreChannelBackups(ctx context.Context,
|
||||
// channel peers.
|
||||
packedMulti := chanbackup.PackedMulti(packedMultiBackup)
|
||||
err := chanbackup.UnpackAndRecoverMulti(
|
||||
packedMulti, r.server.cc.keyRing, chanRestorer,
|
||||
packedMulti, r.server.cc.KeyRing, chanRestorer,
|
||||
r.server,
|
||||
)
|
||||
if err != nil {
|
||||
@ -6714,7 +6714,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
|
||||
// chanfunding.Assembler that is able to express proper
|
||||
// formulation of this expected channel.
|
||||
shimAssembler, err := newFundingShimAssembler(
|
||||
rpcShimIntent, false, r.server.cc.keyRing,
|
||||
rpcShimIntent, false, r.server.cc.KeyRing,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -6732,7 +6732,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
|
||||
// pending channel ID, then this shim will be dispatched in
|
||||
// place of our regular funding workflow.
|
||||
copy(pendingChanID[:], rpcShimIntent.PendingChanId)
|
||||
err = r.server.cc.wallet.RegisterFundingIntent(
|
||||
err = r.server.cc.Wallet.RegisterFundingIntent(
|
||||
pendingChanID, shimIntent,
|
||||
)
|
||||
if err != nil {
|
||||
@ -6756,7 +6756,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
@ -6776,7 +6776,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
|
||||
return nil, fmt.Errorf("error parsing psbt: %v", err)
|
||||
}
|
||||
|
||||
err = r.server.cc.wallet.PsbtFundingVerify(
|
||||
err = r.server.cc.Wallet.PsbtFundingVerify(
|
||||
pendingChanID, packet,
|
||||
)
|
||||
if err != nil {
|
||||
@ -6829,7 +6829,7 @@ func (r *rpcServer) FundingStateStep(ctx context.Context,
|
||||
"finalize missing")
|
||||
}
|
||||
|
||||
err = r.server.cc.wallet.PsbtFundingFinalize(
|
||||
err = r.server.cc.Wallet.PsbtFundingFinalize(
|
||||
pendingChanID, packet, rawTx,
|
||||
)
|
||||
if err != nil {
|
||||
|
120
server.go
120
server.go
@ -204,7 +204,7 @@ type server struct {
|
||||
// intended to replace it.
|
||||
scheduledPeerConnection map[string]func()
|
||||
|
||||
cc *chainControl
|
||||
cc *ChainControl
|
||||
|
||||
fundingMgr *fundingManager
|
||||
|
||||
@ -339,7 +339,7 @@ func noiseDial(idKey keychain.SingleKeyECDH,
|
||||
// passed listener address.
|
||||
func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
localChanDB, remoteChanDB *channeldb.DB,
|
||||
towerClientDB *wtdb.ClientDB, cc *chainControl,
|
||||
towerClientDB *wtdb.ClientDB, cc *ChainControl,
|
||||
nodeKeyDesc *keychain.KeyDescriptor,
|
||||
chansToRestore walletunlocker.ChannelsToRecover,
|
||||
chanPredicate chanacceptor.ChannelAcceptor,
|
||||
@ -347,9 +347,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
|
||||
var (
|
||||
err error
|
||||
nodeKeyECDH = keychain.NewPubKeyECDH(*nodeKeyDesc, cc.keyRing)
|
||||
nodeKeyECDH = keychain.NewPubKeyECDH(*nodeKeyDesc, cc.KeyRing)
|
||||
nodeKeySigner = keychain.NewPubKeyDigestSigner(
|
||||
*nodeKeyDesc, cc.keyRing,
|
||||
*nodeKeyDesc, cc.KeyRing,
|
||||
)
|
||||
)
|
||||
|
||||
@ -375,7 +375,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
sharedSecretPath := filepath.Join(
|
||||
cfg.localDatabaseDir(), defaultSphinxDbName,
|
||||
)
|
||||
replayLog := htlcswitch.NewDecayedLog(sharedSecretPath, cc.chainNotifier)
|
||||
replayLog := htlcswitch.NewDecayedLog(sharedSecretPath, cc.ChainNotifier)
|
||||
sphinxRouter := sphinx.NewRouter(
|
||||
nodeKeyECDH, cfg.ActiveNetParams.Params, replayLog,
|
||||
)
|
||||
@ -423,7 +423,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
localChanDB: localChanDB,
|
||||
remoteChanDB: remoteChanDB,
|
||||
cc: cc,
|
||||
sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.signer),
|
||||
sigPool: lnwallet.NewSigPool(cfg.Workers.Sig, cc.Signer),
|
||||
writePool: writePool,
|
||||
readPool: readPool,
|
||||
chansToRestore: chansToRestore,
|
||||
@ -469,7 +469,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
subscribers: make(map[uint64]*preimageSubscriber),
|
||||
}
|
||||
|
||||
_, currentHeight, err := s.cc.chainIO.GetBestBlock()
|
||||
_, currentHeight, err := s.cc.ChainIO.GetBestBlock()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -496,7 +496,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
SwitchPackager: channeldb.NewSwitchPackager(),
|
||||
ExtractErrorEncrypter: s.sphinx.ExtractErrorEncrypter,
|
||||
FetchLastChannelUpdate: s.fetchLastChanUpdate(),
|
||||
Notifier: s.cc.chainNotifier,
|
||||
Notifier: s.cc.ChainNotifier,
|
||||
HtlcNotifier: s.htlcNotifier,
|
||||
FwdEventTicker: ticker.New(htlcswitch.DefaultFwdEventInterval),
|
||||
LogEventTicker: ticker.New(htlcswitch.DefaultLogInterval),
|
||||
@ -753,8 +753,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
|
||||
s.chanRouter, err = routing.New(routing.Config{
|
||||
Graph: chanGraph,
|
||||
Chain: cc.chainIO,
|
||||
ChainView: cc.chainView,
|
||||
Chain: cc.ChainIO,
|
||||
ChainView: cc.ChainView,
|
||||
Payer: s.htlcSwitch,
|
||||
Control: s.controlTower,
|
||||
MissionControl: s.missionControl,
|
||||
@ -783,7 +783,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
|
||||
s.authGossiper = discovery.New(discovery.Config{
|
||||
Router: s.chanRouter,
|
||||
Notifier: s.cc.chainNotifier,
|
||||
Notifier: s.cc.ChainNotifier,
|
||||
ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
|
||||
Broadcast: s.BroadcastMessage,
|
||||
ChanSeries: chanSeries,
|
||||
@ -834,14 +834,14 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
}
|
||||
|
||||
s.sweeper = sweep.New(&sweep.UtxoSweeperConfig{
|
||||
FeeEstimator: cc.feeEstimator,
|
||||
GenSweepScript: newSweepPkScriptGen(cc.wallet),
|
||||
Signer: cc.wallet.Cfg.Signer,
|
||||
Wallet: cc.wallet,
|
||||
FeeEstimator: cc.FeeEstimator,
|
||||
GenSweepScript: newSweepPkScriptGen(cc.Wallet),
|
||||
Signer: cc.Wallet.Cfg.Signer,
|
||||
Wallet: cc.Wallet,
|
||||
NewBatchTimer: func() <-chan time.Time {
|
||||
return time.NewTimer(sweep.DefaultBatchWindowDuration).C
|
||||
},
|
||||
Notifier: cc.chainNotifier,
|
||||
Notifier: cc.ChainNotifier,
|
||||
Store: sweeperStore,
|
||||
MaxInputsPerTx: sweep.DefaultMaxInputsPerTx,
|
||||
MaxSweepAttempts: sweep.DefaultMaxSweepAttempts,
|
||||
@ -851,12 +851,12 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
})
|
||||
|
||||
s.utxoNursery = newUtxoNursery(&NurseryConfig{
|
||||
ChainIO: cc.chainIO,
|
||||
ChainIO: cc.ChainIO,
|
||||
ConfDepth: 1,
|
||||
FetchClosedChannels: remoteChanDB.FetchClosedChannels,
|
||||
FetchClosedChannel: remoteChanDB.FetchClosedChannel,
|
||||
Notifier: cc.chainNotifier,
|
||||
PublishTransaction: cc.wallet.PublishTransaction,
|
||||
Notifier: cc.ChainNotifier,
|
||||
PublishTransaction: cc.Wallet.PublishTransaction,
|
||||
Store: utxnStore,
|
||||
SweepInput: s.sweeper.SweepInput,
|
||||
})
|
||||
@ -881,8 +881,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
ChainHash: *s.cfg.ActiveNetParams.GenesisHash,
|
||||
IncomingBroadcastDelta: lncfg.DefaultIncomingBroadcastDelta,
|
||||
OutgoingBroadcastDelta: lncfg.DefaultOutgoingBroadcastDelta,
|
||||
NewSweepAddr: newSweepPkScriptGen(cc.wallet),
|
||||
PublishTx: cc.wallet.PublishTransaction,
|
||||
NewSweepAddr: newSweepPkScriptGen(cc.Wallet),
|
||||
PublishTx: cc.Wallet.PublishTransaction,
|
||||
DeliverResolutionMsg: func(msgs ...contractcourt.ResolutionMsg) error {
|
||||
for _, msg := range msgs {
|
||||
err := s.htlcSwitch.ProcessContractResolution(msg)
|
||||
@ -914,16 +914,16 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
)
|
||||
},
|
||||
PreimageDB: s.witnessBeacon,
|
||||
Notifier: cc.chainNotifier,
|
||||
Signer: cc.wallet.Cfg.Signer,
|
||||
FeeEstimator: cc.feeEstimator,
|
||||
ChainIO: cc.chainIO,
|
||||
Notifier: cc.ChainNotifier,
|
||||
Signer: cc.Wallet.Cfg.Signer,
|
||||
FeeEstimator: cc.FeeEstimator,
|
||||
ChainIO: cc.ChainIO,
|
||||
MarkLinkInactive: func(chanPoint wire.OutPoint) error {
|
||||
chanID := lnwire.NewChanIDFromOutPoint(&chanPoint)
|
||||
s.htlcSwitch.RemoveLink(chanID)
|
||||
return nil
|
||||
},
|
||||
IsOurAddress: cc.wallet.IsOurAddress,
|
||||
IsOurAddress: cc.Wallet.IsOurAddress,
|
||||
ContractBreach: func(chanPoint wire.OutPoint,
|
||||
breachRet *lnwallet.BreachRetribution) error {
|
||||
event := &ContractBreachEvent{
|
||||
@ -960,12 +960,12 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
s.breachArbiter = newBreachArbiter(&BreachConfig{
|
||||
CloseLink: closeLink,
|
||||
DB: remoteChanDB,
|
||||
Estimator: s.cc.feeEstimator,
|
||||
GenSweepScript: newSweepPkScriptGen(cc.wallet),
|
||||
Notifier: cc.chainNotifier,
|
||||
PublishTransaction: cc.wallet.PublishTransaction,
|
||||
Estimator: s.cc.FeeEstimator,
|
||||
GenSweepScript: newSweepPkScriptGen(cc.Wallet),
|
||||
Notifier: cc.ChainNotifier,
|
||||
PublishTransaction: cc.Wallet.PublishTransaction,
|
||||
ContractBreaches: contractBreaches,
|
||||
Signer: cc.wallet.Cfg.Signer,
|
||||
Signer: cc.Wallet.Cfg.Signer,
|
||||
Store: newRetributionStore(remoteChanDB),
|
||||
})
|
||||
|
||||
@ -989,13 +989,13 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
s.fundingMgr, err = newFundingManager(fundingConfig{
|
||||
NoWumboChans: !cfg.ProtocolOptions.Wumbo(),
|
||||
IDKey: nodeKeyECDH.PubKey(),
|
||||
Wallet: cc.wallet,
|
||||
PublishTransaction: cc.wallet.PublishTransaction,
|
||||
Wallet: cc.Wallet,
|
||||
PublishTransaction: cc.Wallet.PublishTransaction,
|
||||
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,
|
||||
FeeEstimator: cc.feeEstimator,
|
||||
Notifier: cc.ChainNotifier,
|
||||
FeeEstimator: cc.FeeEstimator,
|
||||
SignMessage: func(pubKey *btcec.PublicKey,
|
||||
msg []byte) (input.Signature, error) {
|
||||
|
||||
@ -1003,7 +1003,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
return s.nodeSigner.SignMessage(pubKey, msg)
|
||||
}
|
||||
|
||||
return cc.msgSigner.SignMessage(pubKey, msg)
|
||||
return cc.MsgSigner.SignMessage(pubKey, msg)
|
||||
},
|
||||
CurrentNodeAnnouncement: func() (lnwire.NodeAnnouncement, error) {
|
||||
return s.genNodeAnnouncement(true)
|
||||
@ -1033,8 +1033,8 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
|
||||
return nil, fmt.Errorf("unable to find channel")
|
||||
},
|
||||
DefaultRoutingPolicy: cc.routingPolicy,
|
||||
DefaultMinHtlcIn: cc.minHtlcIn,
|
||||
DefaultRoutingPolicy: cc.RoutingPolicy,
|
||||
DefaultMinHtlcIn: cc.MinHtlcIn,
|
||||
NumRequiredConfs: func(chanAmt btcutil.Amount,
|
||||
pushAmt lnwire.MilliSatoshi) uint16 {
|
||||
// For large channels we increase the number
|
||||
@ -1197,7 +1197,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
return nil, err
|
||||
}
|
||||
s.chanSubSwapper, err = chanbackup.NewSubSwapper(
|
||||
startingChans, chanNotifier, s.cc.keyRing, backupFile,
|
||||
startingChans, chanNotifier, s.cc.KeyRing, backupFile,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -1250,9 +1250,9 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
}
|
||||
|
||||
s.towerClient, err = wtclient.New(&wtclient.Config{
|
||||
Signer: cc.wallet.Cfg.Signer,
|
||||
NewAddress: newSweepPkScriptGen(cc.wallet),
|
||||
SecretKeyRing: s.cc.keyRing,
|
||||
Signer: cc.Wallet.Cfg.Signer,
|
||||
NewAddress: newSweepPkScriptGen(cc.Wallet),
|
||||
SecretKeyRing: s.cc.KeyRing,
|
||||
Dial: cfg.net.Dial,
|
||||
AuthDial: authDial,
|
||||
DB: towerClientDB,
|
||||
@ -1293,7 +1293,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
||||
chainHealthCheck := healthcheck.NewObservation(
|
||||
"chain backend",
|
||||
func() error {
|
||||
_, _, err := cc.chainIO.GetBestBlock()
|
||||
_, _, err := cc.ChainIO.GetBestBlock()
|
||||
return err
|
||||
},
|
||||
cfg.HealthChecks.ChainCheck.Interval,
|
||||
@ -1413,7 +1413,7 @@ func (s *server) Start() error {
|
||||
startErr = err
|
||||
return
|
||||
}
|
||||
if err := s.cc.chainNotifier.Start(); err != nil {
|
||||
if err := s.cc.ChainNotifier.Start(); err != nil {
|
||||
startErr = err
|
||||
return
|
||||
}
|
||||
@ -1491,13 +1491,13 @@ func (s *server) Start() error {
|
||||
// recovery _before_ we even accept connections from any peers.
|
||||
chanRestorer := &chanDBRestorer{
|
||||
db: s.remoteChanDB,
|
||||
secretKeys: s.cc.keyRing,
|
||||
secretKeys: s.cc.KeyRing,
|
||||
chainArb: s.chainArb,
|
||||
}
|
||||
if len(s.chansToRestore.PackedSingleChanBackups) != 0 {
|
||||
err := chanbackup.UnpackAndRecoverSingles(
|
||||
s.chansToRestore.PackedSingleChanBackups,
|
||||
s.cc.keyRing, chanRestorer, s,
|
||||
s.cc.KeyRing, chanRestorer, s,
|
||||
)
|
||||
if err != nil {
|
||||
startErr = fmt.Errorf("unable to unpack single "+
|
||||
@ -1508,7 +1508,7 @@ func (s *server) Start() error {
|
||||
if len(s.chansToRestore.PackedMultiChanBackup) != 0 {
|
||||
err := chanbackup.UnpackAndRecoverMulti(
|
||||
s.chansToRestore.PackedMultiChanBackup,
|
||||
s.cc.keyRing, chanRestorer, s,
|
||||
s.cc.KeyRing, chanRestorer, s,
|
||||
)
|
||||
if err != nil {
|
||||
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.
|
||||
s.chanStatusMgr.Stop()
|
||||
s.cc.chainNotifier.Stop()
|
||||
s.cc.ChainNotifier.Stop()
|
||||
s.chanRouter.Stop()
|
||||
s.htlcSwitch.Stop()
|
||||
s.sphinx.Stop()
|
||||
@ -1591,10 +1591,10 @@ func (s *server) Stop() error {
|
||||
s.channelNotifier.Stop()
|
||||
s.peerNotifier.Stop()
|
||||
s.htlcNotifier.Stop()
|
||||
s.cc.wallet.Shutdown()
|
||||
s.cc.chainView.Stop()
|
||||
s.cc.Wallet.Shutdown()
|
||||
s.cc.ChainView.Stop()
|
||||
s.connMgr.Stop()
|
||||
s.cc.feeEstimator.Stop()
|
||||
s.cc.FeeEstimator.Stop()
|
||||
s.invoices.Stop()
|
||||
s.fundingMgr.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
|
||||
// sources will be the set of running DNS seeds.
|
||||
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
|
||||
// it as an additional bootstrapping source.
|
||||
@ -2965,13 +2965,13 @@ func (s *server) peerConnected(conn net.Conn, connReq *connmgr.ConnReq,
|
||||
ChainArb: s.chainArb,
|
||||
AuthGossiper: s.authGossiper,
|
||||
ChanStatusMgr: s.chanStatusMgr,
|
||||
ChainIO: s.cc.chainIO,
|
||||
FeeEstimator: s.cc.feeEstimator,
|
||||
Signer: s.cc.wallet.Cfg.Signer,
|
||||
ChainIO: s.cc.ChainIO,
|
||||
FeeEstimator: s.cc.FeeEstimator,
|
||||
Signer: s.cc.Wallet.Cfg.Signer,
|
||||
SigPool: s.sigPool,
|
||||
Wallet: s.cc.wallet,
|
||||
ChainNotifier: s.cc.chainNotifier,
|
||||
RoutingPolicy: s.cc.routingPolicy,
|
||||
Wallet: s.cc.Wallet,
|
||||
ChainNotifier: s.cc.ChainNotifier,
|
||||
RoutingPolicy: s.cc.RoutingPolicy,
|
||||
Sphinx: s.sphinx,
|
||||
WitnessBeacon: s.witnessBeacon,
|
||||
Invoices: s.invoices,
|
||||
@ -3573,7 +3573,7 @@ func (s *server) OpenChannel(
|
||||
// If the fee rate wasn't specified, then we'll use a default
|
||||
// confirmation target.
|
||||
if req.fundingFeePerKw == 0 {
|
||||
estimator := s.cc.feeEstimator
|
||||
estimator := s.cc.FeeEstimator
|
||||
feeRate, err := estimator.EstimateFeePerKW(6)
|
||||
if err != nil {
|
||||
req.err <- err
|
||||
|
@ -82,7 +82,7 @@ type subRPCServerConfigs struct {
|
||||
//
|
||||
// NOTE: This MUST be called before any callers are permitted to execute the
|
||||
// FetchConfig method.
|
||||
func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl,
|
||||
func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *ChainControl,
|
||||
networkDir string, macService *macaroons.Service,
|
||||
atpl *autopilot.Manager,
|
||||
invoiceRegistry *invoices.InvoiceRegistry,
|
||||
@ -133,10 +133,10 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl
|
||||
reflect.ValueOf(networkDir),
|
||||
)
|
||||
subCfgValue.FieldByName("Signer").Set(
|
||||
reflect.ValueOf(cc.signer),
|
||||
reflect.ValueOf(cc.Signer),
|
||||
)
|
||||
subCfgValue.FieldByName("KeyRing").Set(
|
||||
reflect.ValueOf(cc.keyRing),
|
||||
reflect.ValueOf(cc.KeyRing),
|
||||
)
|
||||
|
||||
case *walletrpc.Config:
|
||||
@ -149,22 +149,22 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl
|
||||
reflect.ValueOf(macService),
|
||||
)
|
||||
subCfgValue.FieldByName("FeeEstimator").Set(
|
||||
reflect.ValueOf(cc.feeEstimator),
|
||||
reflect.ValueOf(cc.FeeEstimator),
|
||||
)
|
||||
subCfgValue.FieldByName("Wallet").Set(
|
||||
reflect.ValueOf(cc.wallet),
|
||||
reflect.ValueOf(cc.Wallet),
|
||||
)
|
||||
subCfgValue.FieldByName("CoinSelectionLocker").Set(
|
||||
reflect.ValueOf(cc.wallet),
|
||||
reflect.ValueOf(cc.Wallet),
|
||||
)
|
||||
subCfgValue.FieldByName("KeyRing").Set(
|
||||
reflect.ValueOf(cc.keyRing),
|
||||
reflect.ValueOf(cc.KeyRing),
|
||||
)
|
||||
subCfgValue.FieldByName("Sweeper").Set(
|
||||
reflect.ValueOf(sweeper),
|
||||
)
|
||||
subCfgValue.FieldByName("Chain").Set(
|
||||
reflect.ValueOf(cc.chainIO),
|
||||
reflect.ValueOf(cc.ChainIO),
|
||||
)
|
||||
subCfgValue.FieldByName("ChainParams").Set(
|
||||
reflect.ValueOf(activeNetParams),
|
||||
@ -187,7 +187,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl
|
||||
reflect.ValueOf(macService),
|
||||
)
|
||||
subCfgValue.FieldByName("ChainNotifier").Set(
|
||||
reflect.ValueOf(cc.chainNotifier),
|
||||
reflect.ValueOf(cc.ChainNotifier),
|
||||
)
|
||||
|
||||
case *invoicesrpc.Config:
|
||||
|
Loading…
Reference in New Issue
Block a user