Merge pull request #2189 from sparkswap/sparkswap/litecoin-regtest

add litecoin regtest to lnd
This commit is contained in:
Conner Fromknecht 2019-04-29 15:46:15 -07:00 committed by GitHub
commit 517cdd66bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 13 deletions

@ -78,8 +78,17 @@ var litecoinMainNetParams = litecoinNetParams{
CoinType: keychain.CoinTypeLitecoin,
}
// regTestNetParams contains parameters specific to a local regtest network.
var regTestNetParams = bitcoinNetParams{
// 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{
Params: &bitcoinCfg.RegressionNetParams,
rpcPort: "18334",
CoinType: keychain.CoinTypeTestnet,

@ -256,10 +256,15 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB,
rpcPort -= 2
bitcoindHost = fmt.Sprintf("%v:%d",
bitcoindMode.RPCHost, rpcPort)
if cfg.Bitcoin.Active && cfg.Bitcoin.RegTest {
if (cfg.Bitcoin.Active && cfg.Bitcoin.RegTest) ||
(cfg.Litecoin.Active && cfg.Litecoin.RegTest) {
conn, err := net.Dial("tcp", bitcoindHost)
if err != nil || conn == nil {
rpcPort = 18443
if cfg.Bitcoin.Active && cfg.Bitcoin.RegTest {
rpcPort = 18443
} else if cfg.Litecoin.Active && cfg.Litecoin.RegTest {
rpcPort = 19443
}
bitcoindHost = fmt.Sprintf("%v:%d",
bitcoindMode.RPCHost,
rpcPort)
@ -320,7 +325,7 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB,
if err := cc.feeEstimator.Start(); err != nil {
return nil, err
}
} else if cfg.Litecoin.Active {
} else if cfg.Litecoin.Active && !cfg.Litecoin.RegTest {
ltndLog.Infof("Initializing litecoind backed fee estimator")
// Finally, we'll re-initialize the fee estimator, as

@ -591,16 +591,10 @@ func loadConfig() (*config, error) {
"litecoin.active must be set to 1 (true)", funcName)
case cfg.Litecoin.Active:
if cfg.Litecoin.RegTest {
str := "%s: regnet mode for litecoin not currently supported"
return nil, fmt.Errorf(str, funcName)
}
if cfg.Litecoin.TimeLockDelta < minTimeLockDelta {
return nil, fmt.Errorf("timelockdelta must be at least %v",
minTimeLockDelta)
}
// Multiple networks can't be selected simultaneously. Count
// number of network flags passed; assign active network params
// while we're at it.
@ -618,6 +612,15 @@ func loadConfig() (*config, error) {
numNets++
ltcParams = litecoinSimNetParams
}
if cfg.Litecoin.RegTest {
numNets++
ltcParams = litecoinRegTestNetParams
}
if cfg.Litecoin.SimNet {
numNets++
ltcParams = litecoinSimNetParams
}
if numNets > 1 {
str := "%s: The mainnet, testnet, and simnet params " +
"can't be used together -- choose one of the " +
@ -700,7 +703,7 @@ func loadConfig() (*config, error) {
}
if cfg.Bitcoin.RegTest {
numNets++
activeNetParams = regTestNetParams
activeNetParams = bitcoinRegTestNetParams
}
if cfg.Bitcoin.SimNet {
numNets++

2
lnd.go

@ -123,7 +123,7 @@ func Main() error {
case cfg.Bitcoin.SimNet || cfg.Litecoin.SimNet:
network = "simnet"
case cfg.Bitcoin.RegTest:
case cfg.Bitcoin.RegTest || cfg.Litecoin.RegTest:
network = "regtest"
}