mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 01:43:16 +01:00
multi: remove Litecoin config options
This commit removes the `Litecoin`, `LtcMode` and `LitecoindMode` members from the main LND `Config` struct. Since only the bitcoin blockchain is now supported, this commit also deprecates the `cfg.Bitcoin.Active` config option.
This commit is contained in:
parent
ba93cde07a
commit
3912d5a0c6
@ -1,12 +1,9 @@
|
|||||||
package chainreg
|
package chainreg
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/btcsuite/btcd/chaincfg"
|
|
||||||
bitcoinCfg "github.com/btcsuite/btcd/chaincfg"
|
bitcoinCfg "github.com/btcsuite/btcd/chaincfg"
|
||||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
|
||||||
bitcoinWire "github.com/btcsuite/btcd/wire"
|
bitcoinWire "github.com/btcsuite/btcd/wire"
|
||||||
"github.com/lightningnetwork/lnd/keychain"
|
"github.com/lightningnetwork/lnd/keychain"
|
||||||
litecoinCfg "github.com/ltcsuite/ltcd/chaincfg"
|
|
||||||
litecoinWire "github.com/ltcsuite/ltcd/wire"
|
litecoinWire "github.com/ltcsuite/ltcd/wire"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,14 +15,6 @@ type BitcoinNetParams struct {
|
|||||||
CoinType uint32
|
CoinType uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// LitecoinNetParams couples the p2p parameters of a network with the
|
|
||||||
// corresponding RPC port of a daemon running on the particular network.
|
|
||||||
type LitecoinNetParams struct {
|
|
||||||
*litecoinCfg.Params
|
|
||||||
RPCPort string
|
|
||||||
CoinType uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
// BitcoinTestNetParams contains parameters specific to the 3rd version of the
|
// BitcoinTestNetParams contains parameters specific to the 3rd version of the
|
||||||
// test network.
|
// test network.
|
||||||
var BitcoinTestNetParams = BitcoinNetParams{
|
var BitcoinTestNetParams = BitcoinNetParams{
|
||||||
@ -57,38 +46,6 @@ var BitcoinSigNetParams = BitcoinNetParams{
|
|||||||
CoinType: keychain.CoinTypeTestnet,
|
CoinType: keychain.CoinTypeTestnet,
|
||||||
}
|
}
|
||||||
|
|
||||||
// LitecoinSimNetParams contains parameters specific to the simulation test
|
|
||||||
// network.
|
|
||||||
var LitecoinSimNetParams = LitecoinNetParams{
|
|
||||||
Params: &litecoinCfg.TestNet4Params,
|
|
||||||
RPCPort: "18556",
|
|
||||||
CoinType: keychain.CoinTypeTestnet,
|
|
||||||
}
|
|
||||||
|
|
||||||
// LitecoinTestNetParams contains parameters specific to the 4th version of the
|
|
||||||
// test network.
|
|
||||||
var LitecoinTestNetParams = LitecoinNetParams{
|
|
||||||
Params: &litecoinCfg.TestNet4Params,
|
|
||||||
RPCPort: "19334",
|
|
||||||
CoinType: keychain.CoinTypeTestnet,
|
|
||||||
}
|
|
||||||
|
|
||||||
// LitecoinMainNetParams contains the parameters specific to the current
|
|
||||||
// Litecoin mainnet.
|
|
||||||
var LitecoinMainNetParams = LitecoinNetParams{
|
|
||||||
Params: &litecoinCfg.MainNetParams,
|
|
||||||
RPCPort: "9334",
|
|
||||||
CoinType: keychain.CoinTypeLitecoin,
|
|
||||||
}
|
|
||||||
|
|
||||||
// LitecoinRegTestNetParams contains parameters specific to a local litecoin
|
|
||||||
// regtest network.
|
|
||||||
var LitecoinRegTestNetParams = LitecoinNetParams{
|
|
||||||
Params: &litecoinCfg.RegressionNetParams,
|
|
||||||
RPCPort: "18334",
|
|
||||||
CoinType: keychain.CoinTypeTestnet,
|
|
||||||
}
|
|
||||||
|
|
||||||
// BitcoinRegTestNetParams contains parameters specific to a local bitcoin
|
// BitcoinRegTestNetParams contains parameters specific to a local bitcoin
|
||||||
// regtest network.
|
// regtest network.
|
||||||
var BitcoinRegTestNetParams = BitcoinNetParams{
|
var BitcoinRegTestNetParams = BitcoinNetParams{
|
||||||
@ -97,49 +54,6 @@ var BitcoinRegTestNetParams = BitcoinNetParams{
|
|||||||
CoinType: keychain.CoinTypeTestnet,
|
CoinType: keychain.CoinTypeTestnet,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ApplyLitecoinParams applies the relevant chain configuration parameters that
|
|
||||||
// differ for litecoin to the chain parameters typed for btcsuite derivation.
|
|
||||||
// This function is used in place of using something like interface{} to
|
|
||||||
// abstract over _which_ chain (or fork) the parameters are for.
|
|
||||||
func ApplyLitecoinParams(params *BitcoinNetParams,
|
|
||||||
litecoinParams *LitecoinNetParams) {
|
|
||||||
|
|
||||||
params.Name = litecoinParams.Name
|
|
||||||
params.Net = bitcoinWire.BitcoinNet(litecoinParams.Net)
|
|
||||||
params.DefaultPort = litecoinParams.DefaultPort
|
|
||||||
params.CoinbaseMaturity = litecoinParams.CoinbaseMaturity
|
|
||||||
|
|
||||||
copy(params.GenesisHash[:], litecoinParams.GenesisHash[:])
|
|
||||||
|
|
||||||
// Address encoding magics
|
|
||||||
params.PubKeyHashAddrID = litecoinParams.PubKeyHashAddrID
|
|
||||||
params.ScriptHashAddrID = litecoinParams.ScriptHashAddrID
|
|
||||||
params.PrivateKeyID = litecoinParams.PrivateKeyID
|
|
||||||
params.WitnessPubKeyHashAddrID = litecoinParams.WitnessPubKeyHashAddrID
|
|
||||||
params.WitnessScriptHashAddrID = litecoinParams.WitnessScriptHashAddrID
|
|
||||||
params.Bech32HRPSegwit = litecoinParams.Bech32HRPSegwit
|
|
||||||
|
|
||||||
copy(params.HDPrivateKeyID[:], litecoinParams.HDPrivateKeyID[:])
|
|
||||||
copy(params.HDPublicKeyID[:], litecoinParams.HDPublicKeyID[:])
|
|
||||||
|
|
||||||
params.HDCoinType = litecoinParams.HDCoinType
|
|
||||||
|
|
||||||
checkPoints := make([]chaincfg.Checkpoint, len(litecoinParams.Checkpoints))
|
|
||||||
for i := 0; i < len(litecoinParams.Checkpoints); i++ {
|
|
||||||
var chainHash chainhash.Hash
|
|
||||||
copy(chainHash[:], litecoinParams.Checkpoints[i].Hash[:])
|
|
||||||
|
|
||||||
checkPoints[i] = chaincfg.Checkpoint{
|
|
||||||
Height: litecoinParams.Checkpoints[i].Height,
|
|
||||||
Hash: &chainHash,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
params.Checkpoints = checkPoints
|
|
||||||
|
|
||||||
params.RPCPort = litecoinParams.RPCPort
|
|
||||||
params.CoinType = litecoinParams.CoinType
|
|
||||||
}
|
|
||||||
|
|
||||||
// IsTestnet tests if the givern params correspond to a testnet
|
// IsTestnet tests if the givern params correspond to a testnet
|
||||||
// parameter configuration.
|
// parameter configuration.
|
||||||
func IsTestnet(params *BitcoinNetParams) bool {
|
func IsTestnet(params *BitcoinNetParams) bool {
|
||||||
|
@ -130,11 +130,6 @@ const (
|
|||||||
// delta.
|
// delta.
|
||||||
DefaultBitcoinTimeLockDelta = 80
|
DefaultBitcoinTimeLockDelta = 80
|
||||||
|
|
||||||
DefaultLitecoinMinHTLCInMSat = lnwire.MilliSatoshi(1)
|
|
||||||
DefaultLitecoinMinHTLCOutMSat = lnwire.MilliSatoshi(1000)
|
|
||||||
DefaultLitecoinBaseFeeMSat = lnwire.MilliSatoshi(1000)
|
|
||||||
DefaultLitecoinFeeRate = lnwire.MilliSatoshi(1)
|
|
||||||
DefaultLitecoinTimeLockDelta = 576
|
|
||||||
DefaultLitecoinDustLimit = btcutil.Amount(54600)
|
DefaultLitecoinDustLimit = btcutil.Amount(54600)
|
||||||
|
|
||||||
// DefaultBitcoinStaticFeePerKW is the fee rate of 50 sat/vbyte
|
// DefaultBitcoinStaticFeePerKW is the fee rate of 50 sat/vbyte
|
||||||
@ -148,10 +143,6 @@ const (
|
|||||||
// DefaultLitecoinStaticFeePerKW is the fee rate of 200 sat/vbyte
|
// DefaultLitecoinStaticFeePerKW is the fee rate of 200 sat/vbyte
|
||||||
// expressed in sat/kw.
|
// expressed in sat/kw.
|
||||||
DefaultLitecoinStaticFeePerKW = chainfee.SatPerKWeight(50000)
|
DefaultLitecoinStaticFeePerKW = chainfee.SatPerKWeight(50000)
|
||||||
|
|
||||||
// BtcToLtcConversionRate is a fixed ratio used in order to scale up
|
|
||||||
// payments when running on the Litecoin chain.
|
|
||||||
BtcToLtcConversionRate = 60
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// DefaultLtcChannelConstraints is the default set of channel constraints that
|
// DefaultLtcChannelConstraints is the default set of channel constraints that
|
||||||
@ -355,13 +346,8 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "bitcoind", "litecoind":
|
case "bitcoind", "litecoind":
|
||||||
var bitcoindMode *lncfg.Bitcoind
|
bitcoindMode := cfg.BitcoindMode
|
||||||
switch {
|
|
||||||
case cfg.Bitcoin.Active:
|
|
||||||
bitcoindMode = cfg.BitcoindMode
|
|
||||||
case cfg.Litecoin.Active:
|
|
||||||
bitcoindMode = cfg.LitecoindMode
|
|
||||||
}
|
|
||||||
// Otherwise, we'll be speaking directly via RPC and ZMQ to a
|
// Otherwise, we'll be speaking directly via RPC and ZMQ to a
|
||||||
// bitcoind node. If the specified host for the btcd/ltcd RPC
|
// bitcoind node. If the specified host for the btcd/ltcd RPC
|
||||||
// server already has a port specified, then we use that
|
// server already has a port specified, then we use that
|
||||||
@ -617,14 +603,10 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
|
|||||||
// connection. If a raw cert was specified in the config, then
|
// connection. If a raw cert was specified in the config, then
|
||||||
// we'll set that directly. Otherwise, we attempt to read the
|
// we'll set that directly. Otherwise, we attempt to read the
|
||||||
// cert from the path specified in the config.
|
// cert from the path specified in the config.
|
||||||
var btcdMode *lncfg.Btcd
|
var (
|
||||||
switch {
|
rpcCert []byte
|
||||||
case cfg.Bitcoin.Active:
|
|
||||||
btcdMode = cfg.BtcdMode
|
btcdMode = cfg.BtcdMode
|
||||||
case cfg.Litecoin.Active:
|
)
|
||||||
btcdMode = cfg.LtcdMode
|
|
||||||
}
|
|
||||||
var rpcCert []byte
|
|
||||||
if btcdMode.RawRPCCert != "" {
|
if btcdMode.RawRPCCert != "" {
|
||||||
rpcCert, err = hex.DecodeString(btcdMode.RawRPCCert)
|
rpcCert, err = hex.DecodeString(btcdMode.RawRPCCert)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
152
config.go
152
config.go
@ -252,11 +252,7 @@ var (
|
|||||||
defaultBtcdDir = btcutil.AppDataDir("btcd", false)
|
defaultBtcdDir = btcutil.AppDataDir("btcd", false)
|
||||||
defaultBtcdRPCCertFile = filepath.Join(defaultBtcdDir, "rpc.cert")
|
defaultBtcdRPCCertFile = filepath.Join(defaultBtcdDir, "rpc.cert")
|
||||||
|
|
||||||
defaultLtcdDir = btcutil.AppDataDir("ltcd", false)
|
|
||||||
defaultLtcdRPCCertFile = filepath.Join(defaultLtcdDir, "rpc.cert")
|
|
||||||
|
|
||||||
defaultBitcoindDir = btcutil.AppDataDir("bitcoin", false)
|
defaultBitcoindDir = btcutil.AppDataDir("bitcoin", false)
|
||||||
defaultLitecoindDir = btcutil.AppDataDir("litecoin", false)
|
|
||||||
|
|
||||||
defaultTorSOCKS = net.JoinHostPort("localhost", strconv.Itoa(defaultTorSOCKSPort))
|
defaultTorSOCKS = net.JoinHostPort("localhost", strconv.Itoa(defaultTorSOCKSPort))
|
||||||
defaultTorDNS = net.JoinHostPort(defaultTorDNSHost, strconv.Itoa(defaultTorDNSPort))
|
defaultTorDNS = net.JoinHostPort(defaultTorDNSHost, strconv.Itoa(defaultTorDNSPort))
|
||||||
@ -352,10 +348,6 @@ type Config struct {
|
|||||||
BitcoindMode *lncfg.Bitcoind `group:"bitcoind" namespace:"bitcoind"`
|
BitcoindMode *lncfg.Bitcoind `group:"bitcoind" namespace:"bitcoind"`
|
||||||
NeutrinoMode *lncfg.Neutrino `group:"neutrino" namespace:"neutrino"`
|
NeutrinoMode *lncfg.Neutrino `group:"neutrino" namespace:"neutrino"`
|
||||||
|
|
||||||
Litecoin *lncfg.Chain `group:"Litecoin" namespace:"litecoin"`
|
|
||||||
LtcdMode *lncfg.Btcd `group:"ltcd" namespace:"ltcd"`
|
|
||||||
LitecoindMode *lncfg.Bitcoind `group:"litecoind" namespace:"litecoind"`
|
|
||||||
|
|
||||||
BlockCacheSize uint64 `long:"blockcachesize" description:"The maximum capacity of the block cache"`
|
BlockCacheSize uint64 `long:"blockcachesize" description:"The maximum capacity of the block cache"`
|
||||||
|
|
||||||
Autopilot *lncfg.AutoPilot `group:"Autopilot" namespace:"autopilot"`
|
Autopilot *lncfg.AutoPilot `group:"Autopilot" namespace:"autopilot"`
|
||||||
@ -569,26 +561,6 @@ func DefaultConfig() Config {
|
|||||||
PrunedNodeMaxPeers: defaultPrunedNodeMaxPeers,
|
PrunedNodeMaxPeers: defaultPrunedNodeMaxPeers,
|
||||||
ZMQReadDeadline: defaultZMQReadDeadline,
|
ZMQReadDeadline: defaultZMQReadDeadline,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{
|
|
||||||
MinHTLCIn: chainreg.DefaultLitecoinMinHTLCInMSat,
|
|
||||||
MinHTLCOut: chainreg.DefaultLitecoinMinHTLCOutMSat,
|
|
||||||
BaseFee: chainreg.DefaultLitecoinBaseFeeMSat,
|
|
||||||
FeeRate: chainreg.DefaultLitecoinFeeRate,
|
|
||||||
TimeLockDelta: chainreg.DefaultLitecoinTimeLockDelta,
|
|
||||||
MaxLocalDelay: defaultMaxLocalCSVDelay,
|
|
||||||
Node: "ltcd",
|
|
||||||
},
|
|
||||||
LtcdMode: &lncfg.Btcd{
|
|
||||||
Dir: defaultLtcdDir,
|
|
||||||
RPCHost: defaultRPCHost,
|
|
||||||
RPCCert: defaultLtcdRPCCertFile,
|
|
||||||
},
|
|
||||||
LitecoindMode: &lncfg.Bitcoind{
|
|
||||||
Dir: defaultLitecoindDir,
|
|
||||||
RPCHost: defaultRPCHost,
|
|
||||||
EstimateMode: defaultBitcoindEstimateMode,
|
|
||||||
PrunedNodeMaxPeers: defaultPrunedNodeMaxPeers,
|
|
||||||
},
|
|
||||||
NeutrinoMode: &lncfg.Neutrino{
|
NeutrinoMode: &lncfg.Neutrino{
|
||||||
UserAgentName: neutrino.UserAgentName,
|
UserAgentName: neutrino.UserAgentName,
|
||||||
UserAgentVersion: neutrino.UserAgentVersion,
|
UserAgentVersion: neutrino.UserAgentVersion,
|
||||||
@ -949,19 +921,11 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
cfg.InvoiceMacPath = CleanAndExpandPath(cfg.InvoiceMacPath)
|
cfg.InvoiceMacPath = CleanAndExpandPath(cfg.InvoiceMacPath)
|
||||||
cfg.LogDir = CleanAndExpandPath(cfg.LogDir)
|
cfg.LogDir = CleanAndExpandPath(cfg.LogDir)
|
||||||
cfg.BtcdMode.Dir = CleanAndExpandPath(cfg.BtcdMode.Dir)
|
cfg.BtcdMode.Dir = CleanAndExpandPath(cfg.BtcdMode.Dir)
|
||||||
cfg.LtcdMode.Dir = CleanAndExpandPath(cfg.LtcdMode.Dir)
|
|
||||||
cfg.BitcoindMode.Dir = CleanAndExpandPath(cfg.BitcoindMode.Dir)
|
cfg.BitcoindMode.Dir = CleanAndExpandPath(cfg.BitcoindMode.Dir)
|
||||||
cfg.BitcoindMode.ConfigPath = CleanAndExpandPath(
|
cfg.BitcoindMode.ConfigPath = CleanAndExpandPath(
|
||||||
cfg.BitcoindMode.ConfigPath,
|
cfg.BitcoindMode.ConfigPath,
|
||||||
)
|
)
|
||||||
cfg.BitcoindMode.RPCCookie = CleanAndExpandPath(cfg.BitcoindMode.RPCCookie)
|
cfg.BitcoindMode.RPCCookie = CleanAndExpandPath(cfg.BitcoindMode.RPCCookie)
|
||||||
cfg.LitecoindMode.Dir = CleanAndExpandPath(cfg.LitecoindMode.Dir)
|
|
||||||
cfg.LitecoindMode.ConfigPath = CleanAndExpandPath(
|
|
||||||
cfg.LitecoindMode.ConfigPath,
|
|
||||||
)
|
|
||||||
cfg.LitecoindMode.RPCCookie = CleanAndExpandPath(
|
|
||||||
cfg.LitecoindMode.RPCCookie,
|
|
||||||
)
|
|
||||||
cfg.Tor.PrivateKeyPath = CleanAndExpandPath(cfg.Tor.PrivateKeyPath)
|
cfg.Tor.PrivateKeyPath = CleanAndExpandPath(cfg.Tor.PrivateKeyPath)
|
||||||
cfg.Tor.WatchtowerKeyPath = CleanAndExpandPath(cfg.Tor.WatchtowerKeyPath)
|
cfg.Tor.WatchtowerKeyPath = CleanAndExpandPath(cfg.Tor.WatchtowerKeyPath)
|
||||||
cfg.Watchtower.TowerDir = CleanAndExpandPath(cfg.Watchtower.TowerDir)
|
cfg.Watchtower.TowerDir = CleanAndExpandPath(cfg.Watchtower.TowerDir)
|
||||||
@ -1162,114 +1126,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
"mutually exclusive, only one should be selected")
|
"mutually exclusive, only one should be selected")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Determine the active chain configuration and its parameters.
|
|
||||||
switch {
|
|
||||||
// At this moment, multiple active chains are not supported.
|
|
||||||
case cfg.Litecoin.Active && cfg.Bitcoin.Active:
|
|
||||||
str := "Currently both Bitcoin and Litecoin cannot be " +
|
|
||||||
"active together"
|
|
||||||
return nil, mkErr(str)
|
|
||||||
|
|
||||||
// Either Bitcoin must be active, or Litecoin must be active.
|
|
||||||
// Otherwise, we don't know which chain we're on.
|
|
||||||
case !cfg.Bitcoin.Active && !cfg.Litecoin.Active:
|
|
||||||
return nil, mkErr("either bitcoin.active or " +
|
|
||||||
"litecoin.active must be set to 1 (true)")
|
|
||||||
|
|
||||||
case cfg.Litecoin.Active:
|
|
||||||
err := cfg.Litecoin.Validate(
|
|
||||||
minTimeLockDelta, funding.MinLtcRemoteDelay,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, mkErr("error validating litecoin: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Multiple networks can't be selected simultaneously. Count
|
|
||||||
// number of network flags passed; assign active network params
|
|
||||||
// while we're at it.
|
|
||||||
numNets := 0
|
|
||||||
var ltcParams chainreg.LitecoinNetParams
|
|
||||||
if cfg.Litecoin.MainNet {
|
|
||||||
numNets++
|
|
||||||
ltcParams = chainreg.LitecoinMainNetParams
|
|
||||||
}
|
|
||||||
if cfg.Litecoin.TestNet3 {
|
|
||||||
numNets++
|
|
||||||
ltcParams = chainreg.LitecoinTestNetParams
|
|
||||||
}
|
|
||||||
if cfg.Litecoin.RegTest {
|
|
||||||
numNets++
|
|
||||||
ltcParams = chainreg.LitecoinRegTestNetParams
|
|
||||||
}
|
|
||||||
if cfg.Litecoin.SimNet {
|
|
||||||
numNets++
|
|
||||||
ltcParams = chainreg.LitecoinSimNetParams
|
|
||||||
}
|
|
||||||
if cfg.Litecoin.SigNet {
|
|
||||||
return nil, mkErr("litecoin.signet is not supported")
|
|
||||||
}
|
|
||||||
|
|
||||||
if numNets > 1 {
|
|
||||||
str := "The mainnet, testnet, and simnet params " +
|
|
||||||
"can't be used together -- choose one of the " +
|
|
||||||
"three"
|
|
||||||
return nil, mkErr(str)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The target network must be provided, otherwise, we won't
|
|
||||||
// know how to initialize the daemon.
|
|
||||||
if numNets == 0 {
|
|
||||||
str := "either --litecoin.mainnet, or " +
|
|
||||||
"litecoin.testnet must be specified"
|
|
||||||
return nil, mkErr(str)
|
|
||||||
}
|
|
||||||
|
|
||||||
// The litecoin chain is the current active chain. However
|
|
||||||
// throughout the codebase we required chaincfg.Params. So as a
|
|
||||||
// temporary hack, we'll mutate the default net params for
|
|
||||||
// bitcoin with the litecoin specific information.
|
|
||||||
chainreg.ApplyLitecoinParams(&cfg.ActiveNetParams, <cParams)
|
|
||||||
|
|
||||||
switch cfg.Litecoin.Node {
|
|
||||||
case "ltcd":
|
|
||||||
err := parseRPCParams(
|
|
||||||
cfg.Litecoin, cfg.LtcdMode,
|
|
||||||
chainreg.LitecoinChain, cfg.ActiveNetParams,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, mkErr("unable to load RPC "+
|
|
||||||
"credentials for ltcd: %v", err)
|
|
||||||
}
|
|
||||||
case "litecoind":
|
|
||||||
if cfg.Litecoin.SimNet {
|
|
||||||
return nil, mkErr("litecoind does not " +
|
|
||||||
"support simnet")
|
|
||||||
}
|
|
||||||
err := parseRPCParams(
|
|
||||||
cfg.Litecoin, cfg.LitecoindMode,
|
|
||||||
chainreg.LitecoinChain, cfg.ActiveNetParams,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
return nil, mkErr("unable to load RPC "+
|
|
||||||
"credentials for litecoind: %v", err)
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
str := "only ltcd and litecoind mode supported for " +
|
|
||||||
"litecoin at this time"
|
|
||||||
return nil, mkErr(str)
|
|
||||||
}
|
|
||||||
|
|
||||||
cfg.Litecoin.ChainDir = filepath.Join(
|
|
||||||
cfg.DataDir, defaultChainSubDirname,
|
|
||||||
chainreg.LitecoinChain.String(),
|
|
||||||
)
|
|
||||||
|
|
||||||
// Finally, we'll register the litecoin chain as our current
|
|
||||||
// primary chain.
|
|
||||||
cfg.registeredChains.RegisterPrimaryChain(chainreg.LitecoinChain)
|
|
||||||
MaxFundingAmount = funding.MaxLtcFundingAmount
|
|
||||||
|
|
||||||
case cfg.Bitcoin.Active:
|
|
||||||
// Multiple networks can't be selected simultaneously. Count
|
// Multiple networks can't be selected simultaneously. Count
|
||||||
// number of network flags passed; assign active network params
|
// number of network flags passed; assign active network params
|
||||||
// while we're at it.
|
// while we're at it.
|
||||||
@ -1354,12 +1210,9 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
return nil, mkErr(str)
|
return nil, mkErr(str)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := cfg.Bitcoin.Validate(
|
err = cfg.Bitcoin.Validate(minTimeLockDelta, funding.MinBtcRemoteDelay)
|
||||||
minTimeLockDelta, funding.MinBtcRemoteDelay,
|
|
||||||
)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, mkErr("error validating bitcoin params: %v",
|
return nil, mkErr("error validating bitcoin params: %v", err)
|
||||||
err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch cfg.Bitcoin.Node {
|
switch cfg.Bitcoin.Node {
|
||||||
@ -1407,7 +1260,6 @@ func ValidateConfig(cfg Config, interceptor signal.Interceptor, fileParser,
|
|||||||
// 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(chainreg.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
|
||||||
// any of the autopilot params.
|
// any of the autopilot params.
|
||||||
|
@ -257,9 +257,6 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
|
|||||||
// 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 := d.cfg.Bitcoin
|
mainChain := d.cfg.Bitcoin
|
||||||
if d.cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
|
||||||
mainChain = d.cfg.Litecoin
|
|
||||||
}
|
|
||||||
var neutrinoCS *neutrino.ChainService
|
var neutrinoCS *neutrino.ChainService
|
||||||
if mainChain.Node == "neutrino" {
|
if mainChain.Node == "neutrino" {
|
||||||
neutrinoBackend, neutrinoCleanUp, err := initNeutrinoBackend(
|
neutrinoBackend, neutrinoCleanUp, err := initNeutrinoBackend(
|
||||||
@ -541,14 +538,11 @@ func (d *DefaultWalletImpl) BuildWalletConfig(ctx context.Context,
|
|||||||
// replicated, so we'll pass in the remote channel DB instance.
|
// replicated, so we'll pass in the remote channel DB instance.
|
||||||
chainControlCfg := &chainreg.Config{
|
chainControlCfg := &chainreg.Config{
|
||||||
Bitcoin: d.cfg.Bitcoin,
|
Bitcoin: d.cfg.Bitcoin,
|
||||||
Litecoin: d.cfg.Litecoin,
|
|
||||||
PrimaryChain: d.cfg.registeredChains.PrimaryChain,
|
PrimaryChain: d.cfg.registeredChains.PrimaryChain,
|
||||||
HeightHintCacheQueryDisable: d.cfg.HeightHintCacheQueryDisable,
|
HeightHintCacheQueryDisable: d.cfg.HeightHintCacheQueryDisable,
|
||||||
NeutrinoMode: d.cfg.NeutrinoMode,
|
NeutrinoMode: d.cfg.NeutrinoMode,
|
||||||
BitcoindMode: d.cfg.BitcoindMode,
|
BitcoindMode: d.cfg.BitcoindMode,
|
||||||
LitecoindMode: d.cfg.LitecoindMode,
|
|
||||||
BtcdMode: d.cfg.BtcdMode,
|
BtcdMode: d.cfg.BtcdMode,
|
||||||
LtcdMode: d.cfg.LtcdMode,
|
|
||||||
HeightHintDB: dbs.HeightHintDB,
|
HeightHintDB: dbs.HeightHintDB,
|
||||||
ChanStateDB: dbs.ChanStateDB.ChannelStateDB(),
|
ChanStateDB: dbs.ChanStateDB.ChannelStateDB(),
|
||||||
NeutrinoCS: neutrinoCS,
|
NeutrinoCS: neutrinoCS,
|
||||||
|
@ -74,14 +74,6 @@ const (
|
|||||||
// to use for its commitment transaction.
|
// to use for its commitment transaction.
|
||||||
MaxBtcRemoteDelay uint16 = 2016
|
MaxBtcRemoteDelay uint16 = 2016
|
||||||
|
|
||||||
// MinLtcRemoteDelay is the minimum Litecoin CSV delay we will require
|
|
||||||
// the remote to use for its commitment transaction.
|
|
||||||
MinLtcRemoteDelay uint16 = 576
|
|
||||||
|
|
||||||
// MaxLtcRemoteDelay is the maximum Litecoin CSV delay we will require
|
|
||||||
// the remote to use for its commitment transaction.
|
|
||||||
MaxLtcRemoteDelay uint16 = 8064
|
|
||||||
|
|
||||||
// MinChanFundingSize is the smallest channel that we'll allow to be
|
// MinChanFundingSize is the smallest channel that we'll allow to be
|
||||||
// created over the RPC interface.
|
// created over the RPC interface.
|
||||||
MinChanFundingSize = btcutil.Amount(20000)
|
MinChanFundingSize = btcutil.Amount(20000)
|
||||||
@ -98,12 +90,6 @@ const (
|
|||||||
// you and limitless channel size (apart from 21 million cap).
|
// you and limitless channel size (apart from 21 million cap).
|
||||||
MaxBtcFundingAmountWumbo = btcutil.Amount(1000000000)
|
MaxBtcFundingAmountWumbo = btcutil.Amount(1000000000)
|
||||||
|
|
||||||
// MaxLtcFundingAmount is a soft-limit of the maximum channel size
|
|
||||||
// currently accepted on the Litecoin chain within the Lightning
|
|
||||||
// Protocol.
|
|
||||||
MaxLtcFundingAmount = MaxBtcFundingAmount *
|
|
||||||
chainreg.BtcToLtcConversionRate
|
|
||||||
|
|
||||||
// TODO(roasbeef): tune.
|
// TODO(roasbeef): tune.
|
||||||
msgBufferSize = 50
|
msgBufferSize = 50
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
//
|
//
|
||||||
//nolint:lll
|
//nolint:lll
|
||||||
type Chain struct {
|
type Chain struct {
|
||||||
Active bool `long:"active" description:"If the chain should be active or not."`
|
Active bool `long:"active" description:"DEPRECATED: If the chain should be active or not. This field is now ignored since only the Bitcoin chain is supported"`
|
||||||
ChainDir string `long:"chaindir" description:"The directory to store the chain's data within."`
|
ChainDir string `long:"chaindir" description:"The directory to store the chain's data within."`
|
||||||
|
|
||||||
Node string `long:"node" description:"The blockchain interface to use." choice:"btcd" choice:"bitcoind" choice:"neutrino" choice:"ltcd" choice:"litecoind" choice:"nochainbackend"`
|
Node string `long:"node" description:"The blockchain interface to use." choice:"btcd" choice:"bitcoind" choice:"neutrino" choice:"ltcd" choice:"litecoind" choice:"nochainbackend"`
|
||||||
|
8
lnd.go
8
lnd.go
@ -160,16 +160,16 @@ func Main(cfg *Config, lisCfg ListenerCfg, implCfg *ImplementationCfg,
|
|||||||
|
|
||||||
var network string
|
var network string
|
||||||
switch {
|
switch {
|
||||||
case cfg.Bitcoin.TestNet3 || cfg.Litecoin.TestNet3:
|
case cfg.Bitcoin.TestNet3:
|
||||||
network = "testnet"
|
network = "testnet"
|
||||||
|
|
||||||
case cfg.Bitcoin.MainNet || cfg.Litecoin.MainNet:
|
case cfg.Bitcoin.MainNet:
|
||||||
network = "mainnet"
|
network = "mainnet"
|
||||||
|
|
||||||
case cfg.Bitcoin.SimNet || cfg.Litecoin.SimNet:
|
case cfg.Bitcoin.SimNet:
|
||||||
network = "simnet"
|
network = "simnet"
|
||||||
|
|
||||||
case cfg.Bitcoin.RegTest || cfg.Litecoin.RegTest:
|
case cfg.Bitcoin.RegTest:
|
||||||
network = "regtest"
|
network = "regtest"
|
||||||
|
|
||||||
case cfg.Bitcoin.SigNet:
|
case cfg.Bitcoin.SigNet:
|
||||||
|
@ -5570,9 +5570,6 @@ 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() == chainreg.LitecoinChain {
|
|
||||||
defaultDelta = r.cfg.Litecoin.TimeLockDelta
|
|
||||||
}
|
|
||||||
|
|
||||||
addInvoiceCfg := &invoicesrpc.AddInvoiceConfig{
|
addInvoiceCfg := &invoicesrpc.AddInvoiceConfig{
|
||||||
AddInvoice: r.server.invoices.AddInvoice,
|
AddInvoice: r.server.invoices.AddInvoice,
|
||||||
|
@ -542,8 +542,8 @@
|
|||||||
|
|
||||||
[Bitcoin]
|
[Bitcoin]
|
||||||
|
|
||||||
; If the Bitcoin chain should be active. Atm, only a single chain can be
|
; DEPRECATED: If the Bitcoin chain should be active. This field is now ignored
|
||||||
; active.
|
; since only the Bitcoin chain is supported.
|
||||||
; bitcoin.active=false
|
; bitcoin.active=false
|
||||||
|
|
||||||
; The directory to store the chain's data within.
|
; The directory to store the chain's data within.
|
||||||
|
32
server.go
32
server.go
@ -1220,17 +1220,10 @@ func newServer(cfg *Config, listenAddrs []net.Addr,
|
|||||||
HtlcNotifier: s.htlcNotifier,
|
HtlcNotifier: s.htlcNotifier,
|
||||||
}, dbs.ChanStateDB)
|
}, dbs.ChanStateDB)
|
||||||
|
|
||||||
// Select the configuration and furnding parameters for Bitcoin or
|
// Select the configuration and funding parameters for Bitcoin.
|
||||||
// Litecoin, depending on the primary registered chain.
|
|
||||||
primaryChain := cfg.registeredChains.PrimaryChain()
|
|
||||||
chainCfg := cfg.Bitcoin
|
chainCfg := cfg.Bitcoin
|
||||||
minRemoteDelay := funding.MinBtcRemoteDelay
|
minRemoteDelay := funding.MinBtcRemoteDelay
|
||||||
maxRemoteDelay := funding.MaxBtcRemoteDelay
|
maxRemoteDelay := funding.MaxBtcRemoteDelay
|
||||||
if primaryChain == chainreg.LitecoinChain {
|
|
||||||
chainCfg = cfg.Litecoin
|
|
||||||
minRemoteDelay = funding.MinLtcRemoteDelay
|
|
||||||
maxRemoteDelay = funding.MaxLtcRemoteDelay
|
|
||||||
}
|
|
||||||
|
|
||||||
var chanIDSeed [32]byte
|
var chanIDSeed [32]byte
|
||||||
if _, err := rand.Read(chanIDSeed[:]); err != nil {
|
if _, err := rand.Read(chanIDSeed[:]); err != nil {
|
||||||
@ -2182,32 +2175,25 @@ func (s *server) Start() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Let users overwrite the DNS seed nodes. We only allow them
|
// Let users overwrite the DNS seed nodes. We only allow them
|
||||||
// for bitcoin mainnet/testnet and litecoin mainnet, all other
|
// for bitcoin mainnet/testnet/signet.
|
||||||
// combinations will just be ignored.
|
if s.cfg.Bitcoin.MainNet {
|
||||||
if s.cfg.Bitcoin.Active && s.cfg.Bitcoin.MainNet {
|
|
||||||
setSeedList(
|
setSeedList(
|
||||||
s.cfg.Bitcoin.DNSSeeds,
|
s.cfg.Bitcoin.DNSSeeds,
|
||||||
chainreg.BitcoinMainnetGenesis,
|
chainreg.BitcoinMainnetGenesis,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if s.cfg.Bitcoin.Active && s.cfg.Bitcoin.TestNet3 {
|
if s.cfg.Bitcoin.TestNet3 {
|
||||||
setSeedList(
|
setSeedList(
|
||||||
s.cfg.Bitcoin.DNSSeeds,
|
s.cfg.Bitcoin.DNSSeeds,
|
||||||
chainreg.BitcoinTestnetGenesis,
|
chainreg.BitcoinTestnetGenesis,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if s.cfg.Bitcoin.Active && s.cfg.Bitcoin.SigNet {
|
if s.cfg.Bitcoin.SigNet {
|
||||||
setSeedList(
|
setSeedList(
|
||||||
s.cfg.Bitcoin.DNSSeeds,
|
s.cfg.Bitcoin.DNSSeeds,
|
||||||
chainreg.BitcoinSignetGenesis,
|
chainreg.BitcoinSignetGenesis,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
if s.cfg.Litecoin.Active && s.cfg.Litecoin.MainNet {
|
|
||||||
setSeedList(
|
|
||||||
s.cfg.Litecoin.DNSSeeds,
|
|
||||||
chainreg.LitecoinMainnetGenesis,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// If network bootstrapping hasn't been disabled, then we'll
|
// If network bootstrapping hasn't been disabled, then we'll
|
||||||
// configure the set of active bootstrappers, and launch a
|
// configure the set of active bootstrappers, and launch a
|
||||||
@ -2559,7 +2545,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 {
|
||||||
dnsSeeds, ok := chainreg.ChainDNSSeeds[*s.cfg.ActiveNetParams.GenesisHash]
|
dnsSeeds, ok := chainreg.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
|
||||||
@ -4713,9 +4699,9 @@ func newSweepPkScriptGen(
|
|||||||
// bootstrapping to actively seek our peers using the set of active network
|
// bootstrapping to actively seek our peers using the set of active network
|
||||||
// bootstrappers.
|
// bootstrappers.
|
||||||
func shouldPeerBootstrap(cfg *Config) bool {
|
func shouldPeerBootstrap(cfg *Config) bool {
|
||||||
isSimnet := (cfg.Bitcoin.SimNet || cfg.Litecoin.SimNet)
|
isSimnet := cfg.Bitcoin.SimNet
|
||||||
isSignet := (cfg.Bitcoin.SigNet || cfg.Litecoin.SigNet)
|
isSignet := cfg.Bitcoin.SigNet
|
||||||
isRegtest := (cfg.Bitcoin.RegTest || cfg.Litecoin.RegTest)
|
isRegtest := cfg.Bitcoin.RegTest
|
||||||
isDevNetwork := isSimnet || isSignet || isRegtest
|
isDevNetwork := isSimnet || isSignet || isRegtest
|
||||||
|
|
||||||
// TODO(yy): remove the check on simnet/regtest such that the itest is
|
// TODO(yy): remove the check on simnet/regtest such that the itest is
|
||||||
|
@ -21,7 +21,6 @@ func TestShouldPeerBootstrap(t *testing.T) {
|
|||||||
Bitcoin: &lncfg.Chain{
|
Bitcoin: &lncfg.Chain{
|
||||||
SimNet: true,
|
SimNet: true,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -31,7 +30,6 @@ func TestShouldPeerBootstrap(t *testing.T) {
|
|||||||
Bitcoin: &lncfg.Chain{
|
Bitcoin: &lncfg.Chain{
|
||||||
RegTest: true,
|
RegTest: true,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -41,7 +39,6 @@ func TestShouldPeerBootstrap(t *testing.T) {
|
|||||||
Bitcoin: &lncfg.Chain{
|
Bitcoin: &lncfg.Chain{
|
||||||
SigNet: true,
|
SigNet: true,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -51,7 +48,6 @@ func TestShouldPeerBootstrap(t *testing.T) {
|
|||||||
Bitcoin: &lncfg.Chain{
|
Bitcoin: &lncfg.Chain{
|
||||||
MainNet: true,
|
MainNet: true,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{},
|
|
||||||
NoNetBootstrap: true,
|
NoNetBootstrap: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -62,7 +58,6 @@ func TestShouldPeerBootstrap(t *testing.T) {
|
|||||||
Bitcoin: &lncfg.Chain{
|
Bitcoin: &lncfg.Chain{
|
||||||
MainNet: true,
|
MainNet: true,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{},
|
|
||||||
},
|
},
|
||||||
shouldBoostrap: true,
|
shouldBoostrap: true,
|
||||||
},
|
},
|
||||||
@ -73,7 +68,6 @@ func TestShouldPeerBootstrap(t *testing.T) {
|
|||||||
Bitcoin: &lncfg.Chain{
|
Bitcoin: &lncfg.Chain{
|
||||||
TestNet3: true,
|
TestNet3: true,
|
||||||
},
|
},
|
||||||
Litecoin: &lncfg.Chain{},
|
|
||||||
},
|
},
|
||||||
shouldBoostrap: true,
|
shouldBoostrap: true,
|
||||||
},
|
},
|
||||||
|
@ -244,9 +244,6 @@ func (s *subRPCServerConfigs) PopulateDependencies(cfg *Config,
|
|||||||
reflect.ValueOf(nodeSigner),
|
reflect.ValueOf(nodeSigner),
|
||||||
)
|
)
|
||||||
defaultDelta := cfg.Bitcoin.TimeLockDelta
|
defaultDelta := cfg.Bitcoin.TimeLockDelta
|
||||||
if cfg.registeredChains.PrimaryChain() == chainreg.LitecoinChain {
|
|
||||||
defaultDelta = cfg.Litecoin.TimeLockDelta
|
|
||||||
}
|
|
||||||
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
|
subCfgValue.FieldByName("DefaultCLTVExpiry").Set(
|
||||||
reflect.ValueOf(defaultDelta),
|
reflect.ValueOf(defaultDelta),
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user