lnd: properly switch RPC port with target net change

With this commit, support for changing the target network (testnet,
simnet, etc) has been finalized. Previously a command line option was
present to swap networks, but the RPC port wouldn’t automatically be
updated to reflect the network.
This commit is contained in:
Olaoluwa Osuntokun
2016-07-13 18:37:50 -07:00
parent 98fae7f329
commit a56ab46e97
5 changed files with 44 additions and 19 deletions

View File

@ -9,7 +9,6 @@ import (
"strings"
flags "github.com/btcsuite/go-flags"
"github.com/roasbeef/btcd/chaincfg"
"github.com/roasbeef/btcutil"
)
@ -34,10 +33,6 @@ var (
defaultDataDir = filepath.Join(lndHomeDir, defaultDataDirname)
defaultLogDir = filepath.Join(lndHomeDir, defaultLogDirname)
// activeNetParams is a pointer to the parameters specific to the
// currently active bitcoin network.
activeNetParams = &chaincfg.SegNet4Params
btcdHomeDir = btcutil.AppDataDir("btcd", false)
defaultRPCKeyFile = filepath.Join(btcdHomeDir, "rpc.key")
defaultRPCCertFile = filepath.Join(btcdHomeDir, "rpc.cert")
@ -154,15 +149,11 @@ func loadConfig() (*config, error) {
numNets := 0
if cfg.TestNet3 {
numNets++
activeNetParams = &chaincfg.TestNet3Params
}
if cfg.SegNet {
numNets++
activeNetParams = &chaincfg.SegNet4Params
activeNetParams = testNetParams
}
if cfg.SimNet {
numNets++
activeNetParams = &chaincfg.SimNetParams
activeNetParams = simNetParams
}
if numNets > 1 {
str := "%s: The testnet, segnet, and simnet params can't be " +