chainreg: export ChainCode to new pkg
Moves chainCode from the lnd package to the chainreg package, where it is exported and can be used by other packages.
This commit is contained in:
parent
afb6ad295e
commit
933b959aa8
25
chainreg/chaincode.go
Normal file
25
chainreg/chaincode.go
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package chainreg
|
||||||
|
|
||||||
|
// ChainCode is an enum-like structure for keeping track of the chains
|
||||||
|
// currently supported within lnd.
|
||||||
|
type ChainCode uint32
|
||||||
|
|
||||||
|
const (
|
||||||
|
// BitcoinChain is Bitcoin's chain.
|
||||||
|
BitcoinChain ChainCode = iota
|
||||||
|
|
||||||
|
// LitecoinChain is Litecoin's chain.
|
||||||
|
LitecoinChain
|
||||||
|
)
|
||||||
|
|
||||||
|
// String returns a string representation of the target ChainCode.
|
||||||
|
func (c ChainCode) String() string {
|
||||||
|
switch c {
|
||||||
|
case BitcoinChain:
|
||||||
|
return "bitcoin"
|
||||||
|
case LitecoinChain:
|
||||||
|
return "litecoin"
|
||||||
|
default:
|
||||||
|
return "kekcoin"
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/chainntnfs/bitcoindnotify"
|
"github.com/lightningnetwork/lnd/chainntnfs/bitcoindnotify"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
|
"github.com/lightningnetwork/lnd/chainntnfs/btcdnotify"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs/neutrinonotify"
|
"github.com/lightningnetwork/lnd/chainntnfs/neutrinonotify"
|
||||||
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/input"
|
"github.com/lightningnetwork/lnd/input"
|
||||||
@ -102,30 +103,6 @@ var defaultLtcChannelConstraints = channeldb.ChannelConstraints{
|
|||||||
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
MaxAcceptedHtlcs: input.MaxHTLCNumber / 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
// chainCode is an enum-like structure for keeping track of the chains
|
|
||||||
// currently supported within lnd.
|
|
||||||
type chainCode uint32
|
|
||||||
|
|
||||||
const (
|
|
||||||
// bitcoinChain is Bitcoin's testnet chain.
|
|
||||||
bitcoinChain chainCode = iota
|
|
||||||
|
|
||||||
// litecoinChain is Litecoin's testnet chain.
|
|
||||||
litecoinChain
|
|
||||||
)
|
|
||||||
|
|
||||||
// String returns a string representation of the target chainCode.
|
|
||||||
func (c chainCode) String() string {
|
|
||||||
switch c {
|
|
||||||
case bitcoinChain:
|
|
||||||
return "bitcoin"
|
|
||||||
case litecoinChain:
|
|
||||||
return "litecoin"
|
|
||||||
default:
|
|
||||||
return "kekcoin"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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.
|
||||||
@ -167,7 +144,7 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
|
|||||||
// 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.
|
||||||
homeChainConfig := cfg.Bitcoin
|
homeChainConfig := cfg.Bitcoin
|
||||||
if cfg.registeredChains.PrimaryChain() == litecoinChain {
|
if cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
||||||
homeChainConfig = cfg.Litecoin
|
homeChainConfig = cfg.Litecoin
|
||||||
}
|
}
|
||||||
ltndLog.Infof("Primary chain is set to: %v",
|
ltndLog.Infof("Primary chain is set to: %v",
|
||||||
@ -176,7 +153,7 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
|
|||||||
cc := &chainControl{}
|
cc := &chainControl{}
|
||||||
|
|
||||||
switch cfg.registeredChains.PrimaryChain() {
|
switch cfg.registeredChains.PrimaryChain() {
|
||||||
case 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,
|
||||||
@ -188,7 +165,7 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
|
|||||||
defaultBitcoinStaticFeePerKW,
|
defaultBitcoinStaticFeePerKW,
|
||||||
defaultBitcoinStaticMinRelayFeeRate,
|
defaultBitcoinStaticMinRelayFeeRate,
|
||||||
)
|
)
|
||||||
case 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,
|
||||||
@ -517,7 +494,7 @@ func newChainControlFromConfig(cfg *Config, localDB, remoteDB *channeldb.DB,
|
|||||||
|
|
||||||
// Select the default channel constraints for the primary chain.
|
// Select the default channel constraints for the primary chain.
|
||||||
channelConstraints := defaultBtcChannelConstraints
|
channelConstraints := defaultBtcChannelConstraints
|
||||||
if cfg.registeredChains.PrimaryChain() == litecoinChain {
|
if cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
||||||
channelConstraints = defaultLtcChannelConstraints
|
channelConstraints = defaultLtcChannelConstraints
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,13 +569,13 @@ var (
|
|||||||
})
|
})
|
||||||
|
|
||||||
// chainMap is a simple index that maps a chain's genesis hash to the
|
// chainMap is a simple index that maps a chain's genesis hash to the
|
||||||
// chainCode enum for that chain.
|
// ChainCode enum for that chain.
|
||||||
chainMap = map[chainhash.Hash]chainCode{
|
chainMap = map[chainhash.Hash]chainreg.ChainCode{
|
||||||
bitcoinTestnetGenesis: bitcoinChain,
|
bitcoinTestnetGenesis: chainreg.BitcoinChain,
|
||||||
litecoinTestnetGenesis: litecoinChain,
|
litecoinTestnetGenesis: chainreg.LitecoinChain,
|
||||||
|
|
||||||
bitcoinMainnetGenesis: bitcoinChain,
|
bitcoinMainnetGenesis: chainreg.BitcoinChain,
|
||||||
litecoinMainnetGenesis: 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
|
||||||
@ -644,23 +621,25 @@ var (
|
|||||||
type chainRegistry struct {
|
type chainRegistry struct {
|
||||||
sync.RWMutex
|
sync.RWMutex
|
||||||
|
|
||||||
activeChains map[chainCode]*chainControl
|
activeChains map[chainreg.ChainCode]*chainControl
|
||||||
netParams map[chainCode]*bitcoinNetParams
|
netParams map[chainreg.ChainCode]*bitcoinNetParams
|
||||||
|
|
||||||
primaryChain 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[chainCode]*chainControl),
|
activeChains: make(map[chainreg.ChainCode]*chainControl),
|
||||||
netParams: make(map[chainCode]*bitcoinNetParams),
|
netParams: make(map[chainreg.ChainCode]*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 chainCode, cc *chainControl) {
|
func (c *chainRegistry) RegisterChain(newChain chainreg.ChainCode,
|
||||||
|
cc *chainControl) {
|
||||||
|
|
||||||
c.Lock()
|
c.Lock()
|
||||||
c.activeChains[newChain] = cc
|
c.activeChains[newChain] = cc
|
||||||
c.Unlock()
|
c.Unlock()
|
||||||
@ -668,7 +647,9 @@ func (c *chainRegistry) RegisterChain(newChain chainCode, cc *chainControl) {
|
|||||||
|
|
||||||
// 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 chainCode) (*chainControl, bool) {
|
func (c *chainRegistry) LookupChain(targetChain chainreg.ChainCode) (
|
||||||
|
*chainControl, bool) {
|
||||||
|
|
||||||
c.RLock()
|
c.RLock()
|
||||||
cc, ok := c.activeChains[targetChain]
|
cc, ok := c.activeChains[targetChain]
|
||||||
c.RUnlock()
|
c.RUnlock()
|
||||||
@ -691,7 +672,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 chainCode) {
|
func (c *chainRegistry) RegisterPrimaryChain(cc chainreg.ChainCode) {
|
||||||
c.Lock()
|
c.Lock()
|
||||||
defer c.Unlock()
|
defer c.Unlock()
|
||||||
|
|
||||||
@ -701,7 +682,7 @@ func (c *chainRegistry) RegisterPrimaryChain(cc 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() chainCode {
|
func (c *chainRegistry) PrimaryChain() chainreg.ChainCode {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnlock()
|
defer c.RUnlock()
|
||||||
|
|
||||||
@ -709,11 +690,11 @@ func (c *chainRegistry) PrimaryChain() chainCode {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ActiveChains returns a slice containing the active chains.
|
// ActiveChains returns a slice containing the active chains.
|
||||||
func (c *chainRegistry) ActiveChains() []chainCode {
|
func (c *chainRegistry) ActiveChains() []chainreg.ChainCode {
|
||||||
c.RLock()
|
c.RLock()
|
||||||
defer c.RUnlock()
|
defer c.RUnlock()
|
||||||
|
|
||||||
chains := make([]chainCode, 0, len(c.activeChains))
|
chains := make([]chainreg.ChainCode, 0, len(c.activeChains))
|
||||||
for activeChain := range c.activeChains {
|
for activeChain := range c.activeChains {
|
||||||
chains = append(chains, activeChain)
|
chains = append(chains, activeChain)
|
||||||
}
|
}
|
||||||
|
30
config.go
30
config.go
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/lightninglabs/neutrino"
|
"github.com/lightninglabs/neutrino"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/build"
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/chanbackup"
|
"github.com/lightningnetwork/lnd/chanbackup"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/discovery"
|
"github.com/lightningnetwork/lnd/discovery"
|
||||||
@ -873,7 +874,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
|||||||
switch cfg.Litecoin.Node {
|
switch cfg.Litecoin.Node {
|
||||||
case "ltcd":
|
case "ltcd":
|
||||||
err := parseRPCParams(cfg.Litecoin, cfg.LtcdMode,
|
err := parseRPCParams(cfg.Litecoin, cfg.LtcdMode,
|
||||||
litecoinChain, funcName, cfg.ActiveNetParams)
|
chainreg.LitecoinChain, funcName, cfg.ActiveNetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("unable to load RPC "+
|
err := fmt.Errorf("unable to load RPC "+
|
||||||
"credentials for ltcd: %v", err)
|
"credentials for ltcd: %v", err)
|
||||||
@ -885,7 +886,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
|||||||
"support simnet", funcName)
|
"support simnet", funcName)
|
||||||
}
|
}
|
||||||
err := parseRPCParams(cfg.Litecoin, cfg.LitecoindMode,
|
err := parseRPCParams(cfg.Litecoin, cfg.LitecoindMode,
|
||||||
litecoinChain, funcName, cfg.ActiveNetParams)
|
chainreg.LitecoinChain, funcName, cfg.ActiveNetParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err := fmt.Errorf("unable to load RPC "+
|
err := fmt.Errorf("unable to load RPC "+
|
||||||
"credentials for litecoind: %v", err)
|
"credentials for litecoind: %v", err)
|
||||||
@ -899,11 +900,11 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
|||||||
|
|
||||||
cfg.Litecoin.ChainDir = filepath.Join(cfg.DataDir,
|
cfg.Litecoin.ChainDir = filepath.Join(cfg.DataDir,
|
||||||
defaultChainSubDirname,
|
defaultChainSubDirname,
|
||||||
litecoinChain.String())
|
chainreg.LitecoinChain.String())
|
||||||
|
|
||||||
// Finally we'll register the litecoin chain as our current
|
// Finally we'll register the litecoin chain as our current
|
||||||
// primary chain.
|
// primary chain.
|
||||||
cfg.registeredChains.RegisterPrimaryChain(litecoinChain)
|
cfg.registeredChains.RegisterPrimaryChain(chainreg.LitecoinChain)
|
||||||
MaxFundingAmount = maxLtcFundingAmount
|
MaxFundingAmount = maxLtcFundingAmount
|
||||||
|
|
||||||
case cfg.Bitcoin.Active:
|
case cfg.Bitcoin.Active:
|
||||||
@ -953,7 +954,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
|||||||
switch cfg.Bitcoin.Node {
|
switch cfg.Bitcoin.Node {
|
||||||
case "btcd":
|
case "btcd":
|
||||||
err := parseRPCParams(
|
err := parseRPCParams(
|
||||||
cfg.Bitcoin, cfg.BtcdMode, bitcoinChain, funcName,
|
cfg.Bitcoin, cfg.BtcdMode, chainreg.BitcoinChain, funcName,
|
||||||
cfg.ActiveNetParams,
|
cfg.ActiveNetParams,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -968,7 +969,7 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err := parseRPCParams(
|
err := parseRPCParams(
|
||||||
cfg.Bitcoin, cfg.BitcoindMode, bitcoinChain, funcName,
|
cfg.Bitcoin, cfg.BitcoindMode, chainreg.BitcoinChain, funcName,
|
||||||
cfg.ActiveNetParams,
|
cfg.ActiveNetParams,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -987,11 +988,11 @@ func ValidateConfig(cfg Config, usageMessage string) (*Config, error) {
|
|||||||
|
|
||||||
cfg.Bitcoin.ChainDir = filepath.Join(cfg.DataDir,
|
cfg.Bitcoin.ChainDir = filepath.Join(cfg.DataDir,
|
||||||
defaultChainSubDirname,
|
defaultChainSubDirname,
|
||||||
bitcoinChain.String())
|
chainreg.BitcoinChain.String())
|
||||||
|
|
||||||
// Finally we'll register the bitcoin chain as our current
|
// Finally we'll register the bitcoin chain as our current
|
||||||
// primary chain.
|
// primary chain.
|
||||||
cfg.registeredChains.RegisterPrimaryChain(bitcoinChain)
|
cfg.registeredChains.RegisterPrimaryChain(chainreg.BitcoinChain)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that the user didn't attempt to specify negative values for
|
// Ensure that the user didn't attempt to specify negative values for
|
||||||
@ -1312,8 +1313,9 @@ func CleanAndExpandPath(path string) string {
|
|||||||
return filepath.Clean(os.ExpandEnv(path))
|
return filepath.Clean(os.ExpandEnv(path))
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{}, net chainCode,
|
func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{},
|
||||||
funcName string, netParams bitcoinNetParams) error { // nolint:unparam
|
net chainreg.ChainCode, funcName string,
|
||||||
|
netParams bitcoinNetParams) error { // nolint:unparam
|
||||||
|
|
||||||
// First, we'll check our node config to make sure the RPC parameters
|
// First, we'll check our node config to make sure the RPC parameters
|
||||||
// were set correctly. We'll also determine the path to the conf file
|
// were set correctly. We'll also determine the path to the conf file
|
||||||
@ -1329,11 +1331,11 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{}, net chainCode,
|
|||||||
|
|
||||||
// Get the daemon name for displaying proper errors.
|
// Get the daemon name for displaying proper errors.
|
||||||
switch net {
|
switch net {
|
||||||
case bitcoinChain:
|
case chainreg.BitcoinChain:
|
||||||
daemonName = "btcd"
|
daemonName = "btcd"
|
||||||
confDir = conf.Dir
|
confDir = conf.Dir
|
||||||
confFile = "btcd"
|
confFile = "btcd"
|
||||||
case litecoinChain:
|
case chainreg.LitecoinChain:
|
||||||
daemonName = "ltcd"
|
daemonName = "ltcd"
|
||||||
confDir = conf.Dir
|
confDir = conf.Dir
|
||||||
confFile = "ltcd"
|
confFile = "ltcd"
|
||||||
@ -1376,11 +1378,11 @@ func parseRPCParams(cConfig *lncfg.Chain, nodeConfig interface{}, net chainCode,
|
|||||||
|
|
||||||
// Get the daemon name for displaying proper errors.
|
// Get the daemon name for displaying proper errors.
|
||||||
switch net {
|
switch net {
|
||||||
case bitcoinChain:
|
case chainreg.BitcoinChain:
|
||||||
daemonName = "bitcoind"
|
daemonName = "bitcoind"
|
||||||
confDir = conf.Dir
|
confDir = conf.Dir
|
||||||
confFile = "bitcoin"
|
confFile = "bitcoin"
|
||||||
case litecoinChain:
|
case chainreg.LitecoinChain:
|
||||||
daemonName = "litecoind"
|
daemonName = "litecoind"
|
||||||
confDir = conf.Dir
|
confDir = conf.Dir
|
||||||
confFile = "litecoin"
|
confFile = "litecoin"
|
||||||
|
@ -15,6 +15,7 @@ import (
|
|||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||||
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/chanacceptor"
|
"github.com/lightningnetwork/lnd/chanacceptor"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
"github.com/lightningnetwork/lnd/channeldb/kvdb"
|
||||||
@ -3060,9 +3061,9 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
|
|||||||
// We'll determine our dust limit depending on which chain is active.
|
// We'll determine our dust limit depending on which chain is active.
|
||||||
var ourDustLimit btcutil.Amount
|
var ourDustLimit btcutil.Amount
|
||||||
switch f.cfg.RegisteredChains.PrimaryChain() {
|
switch f.cfg.RegisteredChains.PrimaryChain() {
|
||||||
case bitcoinChain:
|
case chainreg.BitcoinChain:
|
||||||
ourDustLimit = lnwallet.DefaultDustLimit()
|
ourDustLimit = lnwallet.DefaultDustLimit()
|
||||||
case litecoinChain:
|
case chainreg.LitecoinChain:
|
||||||
ourDustLimit = defaultLitecoinDustLimit
|
ourDustLimit = defaultLitecoinDustLimit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
lnd.go
5
lnd.go
@ -36,6 +36,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/build"
|
"github.com/lightningnetwork/lnd/build"
|
||||||
"github.com/lightningnetwork/lnd/cert"
|
"github.com/lightningnetwork/lnd/cert"
|
||||||
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/chanacceptor"
|
"github.com/lightningnetwork/lnd/chanacceptor"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
@ -297,7 +298,7 @@ func Main(cfg *Config, lisCfg ListenerCfg, shutdownChan <-chan struct{}) error {
|
|||||||
// light client instance, if enabled, in order to allow it to sync
|
// light client instance, if enabled, in order to allow it to sync
|
||||||
// while the rest of the daemon continues startup.
|
// while the rest of the daemon continues startup.
|
||||||
mainChain := cfg.Bitcoin
|
mainChain := cfg.Bitcoin
|
||||||
if cfg.registeredChains.PrimaryChain() == litecoinChain {
|
if cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
||||||
mainChain = cfg.Litecoin
|
mainChain = cfg.Litecoin
|
||||||
}
|
}
|
||||||
var neutrinoCS *neutrino.ChainService
|
var neutrinoCS *neutrino.ChainService
|
||||||
@ -1038,7 +1039,7 @@ func waitForWalletPassword(cfg *Config, restEndpoints []net.Addr,
|
|||||||
defer grpcServer.GracefulStop()
|
defer grpcServer.GracefulStop()
|
||||||
|
|
||||||
chainConfig := cfg.Bitcoin
|
chainConfig := cfg.Bitcoin
|
||||||
if cfg.registeredChains.PrimaryChain() == litecoinChain {
|
if cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
||||||
chainConfig = cfg.Litecoin
|
chainConfig = cfg.Litecoin
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ import (
|
|||||||
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
proxy "github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/build"
|
"github.com/lightningnetwork/lnd/build"
|
||||||
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/chanacceptor"
|
"github.com/lightningnetwork/lnd/chanacceptor"
|
||||||
"github.com/lightningnetwork/lnd/chanbackup"
|
"github.com/lightningnetwork/lnd/chanbackup"
|
||||||
"github.com/lightningnetwork/lnd/chanfitness"
|
"github.com/lightningnetwork/lnd/chanfitness"
|
||||||
@ -4679,7 +4680,7 @@ func (r *rpcServer) AddInvoice(ctx context.Context,
|
|||||||
invoice *lnrpc.Invoice) (*lnrpc.AddInvoiceResponse, error) {
|
invoice *lnrpc.Invoice) (*lnrpc.AddInvoiceResponse, error) {
|
||||||
|
|
||||||
defaultDelta := r.cfg.Bitcoin.TimeLockDelta
|
defaultDelta := r.cfg.Bitcoin.TimeLockDelta
|
||||||
if r.cfg.registeredChains.PrimaryChain() == litecoinChain {
|
if r.cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
||||||
defaultDelta = r.cfg.Litecoin.TimeLockDelta
|
defaultDelta = r.cfg.Litecoin.TimeLockDelta
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ import (
|
|||||||
sphinx "github.com/lightningnetwork/lightning-onion"
|
sphinx "github.com/lightningnetwork/lightning-onion"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
"github.com/lightningnetwork/lnd/brontide"
|
"github.com/lightningnetwork/lnd/brontide"
|
||||||
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/chanacceptor"
|
"github.com/lightningnetwork/lnd/chanacceptor"
|
||||||
"github.com/lightningnetwork/lnd/chanbackup"
|
"github.com/lightningnetwork/lnd/chanbackup"
|
||||||
"github.com/lightningnetwork/lnd/chanfitness"
|
"github.com/lightningnetwork/lnd/chanfitness"
|
||||||
@ -974,7 +975,7 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
chainCfg := cfg.Bitcoin
|
chainCfg := cfg.Bitcoin
|
||||||
minRemoteDelay := minBtcRemoteDelay
|
minRemoteDelay := minBtcRemoteDelay
|
||||||
maxRemoteDelay := maxBtcRemoteDelay
|
maxRemoteDelay := maxBtcRemoteDelay
|
||||||
if primaryChain == litecoinChain {
|
if primaryChain == chainreg.LitecoinChain {
|
||||||
chainCfg = cfg.Litecoin
|
chainCfg = cfg.Litecoin
|
||||||
minRemoteDelay = minLtcRemoteDelay
|
minRemoteDelay = minLtcRemoteDelay
|
||||||
maxRemoteDelay = maxLtcRemoteDelay
|
maxRemoteDelay = maxLtcRemoteDelay
|
||||||
|
@ -7,6 +7,7 @@ import (
|
|||||||
"github.com/btcsuite/btcd/chaincfg"
|
"github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btclog"
|
"github.com/btcsuite/btclog"
|
||||||
"github.com/lightningnetwork/lnd/autopilot"
|
"github.com/lightningnetwork/lnd/autopilot"
|
||||||
|
"github.com/lightningnetwork/lnd/chainreg"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||||
"github.com/lightningnetwork/lnd/invoices"
|
"github.com/lightningnetwork/lnd/invoices"
|
||||||
@ -211,7 +212,7 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config, cc *chainControl
|
|||||||
reflect.ValueOf(nodeSigner),
|
reflect.ValueOf(nodeSigner),
|
||||||
)
|
)
|
||||||
defaultDelta := cfg.Bitcoin.TimeLockDelta
|
defaultDelta := cfg.Bitcoin.TimeLockDelta
|
||||||
if cfg.registeredChains.PrimaryChain() == litecoinChain {
|
if cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
||||||
defaultDelta = cfg.Litecoin.TimeLockDelta
|
defaultDelta = cfg.Litecoin.TimeLockDelta
|
||||||
}
|
}
|
||||||
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
|
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
|
||||||
|
Loading…
Reference in New Issue
Block a user