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:
Elle Mouton
2023-08-03 17:25:13 +02:00
committed by Olaoluwa Osuntokun
parent ba93cde07a
commit 3912d5a0c6
12 changed files with 156 additions and 454 deletions

View File

@@ -1,12 +1,9 @@
package chainreg
import (
"github.com/btcsuite/btcd/chaincfg"
bitcoinCfg "github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/chaincfg/chainhash"
bitcoinWire "github.com/btcsuite/btcd/wire"
"github.com/lightningnetwork/lnd/keychain"
litecoinCfg "github.com/ltcsuite/ltcd/chaincfg"
litecoinWire "github.com/ltcsuite/ltcd/wire"
)
@@ -18,14 +15,6 @@ type BitcoinNetParams struct {
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
// test network.
var BitcoinTestNetParams = BitcoinNetParams{
@@ -57,38 +46,6 @@ var BitcoinSigNetParams = BitcoinNetParams{
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
// regtest network.
var BitcoinRegTestNetParams = BitcoinNetParams{
@@ -97,49 +54,6 @@ var BitcoinRegTestNetParams = BitcoinNetParams{
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
// parameter configuration.
func IsTestnet(params *BitcoinNetParams) bool {

View File

@@ -130,12 +130,7 @@ const (
// delta.
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
// expressed in sat/kw.
@@ -148,10 +143,6 @@ const (
// DefaultLitecoinStaticFeePerKW is the fee rate of 200 sat/vbyte
// expressed in sat/kw.
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
@@ -355,13 +346,8 @@ func NewPartialChainControl(cfg *Config) (*PartialChainControl, func(), error) {
}
case "bitcoind", "litecoind":
var bitcoindMode *lncfg.Bitcoind
switch {
case cfg.Bitcoin.Active:
bitcoindMode = cfg.BitcoindMode
case cfg.Litecoin.Active:
bitcoindMode = cfg.LitecoindMode
}
bitcoindMode := cfg.BitcoindMode
// Otherwise, we'll be speaking directly via RPC and ZMQ to a
// bitcoind node. If the specified host for the btcd/ltcd RPC
// 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
// we'll set that directly. Otherwise, we attempt to read the
// cert from the path specified in the config.
var btcdMode *lncfg.Btcd
switch {
case cfg.Bitcoin.Active:
var (
rpcCert []byte
btcdMode = cfg.BtcdMode
case cfg.Litecoin.Active:
btcdMode = cfg.LtcdMode
}
var rpcCert []byte
)
if btcdMode.RawRPCCert != "" {
rpcCert, err = hex.DecodeString(btcdMode.RawRPCCert)
if err != nil {