Change initialization of coin params to avoid cross influence

pull/64/head
Martin Boehm 2018-09-28 22:54:08 +02:00
parent 44da0c8c41
commit 64fbaa7bfc
8 changed files with 32 additions and 8 deletions

View File

@ -23,7 +23,7 @@ var (
TestNetParams chaincfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
@ -63,6 +63,9 @@ func NewBGoldParser(params *chaincfg.Params, c *btc.Configuration) *BGoldParser
// the regression test Bitcoin Cash network, the test Bitcoin Cash network and
// the simulation test Bitcoin Cash network, in this order
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
switch chain {
case "test":
return &TestNetParams

View File

@ -19,7 +19,7 @@ var (
RegtestParams chaincfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
@ -67,6 +67,9 @@ func NewDashParser(params *chaincfg.Params, c *btc.Configuration) *DashParser {
// the regression test Dash network, the test Dash network and
// the simulation test Dash network, in this order
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
switch chain {
case "test":
return &TestNetParams

View File

@ -18,7 +18,7 @@ var (
MainNetParams chaincfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = []byte{30}
@ -43,6 +43,9 @@ func NewDogecoinParser(params *chaincfg.Params, c *btc.Configuration) *DogecoinP
// GetChainParams contains network parameters for the main Dogecoin network,
// and the test Dogecoin network
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
switch chain {
default:
return &MainNetParams

View File

@ -18,7 +18,7 @@ var (
TestNetParams chaincfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = []byte{48}
@ -53,6 +53,9 @@ func NewLitecoinParser(params *chaincfg.Params, c *btc.Configuration) *LitecoinP
// GetChainParams contains network parameters for the main Litecoin network,
// and the test Litecoin network
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
switch chain {
case "test":
return &TestNetParams

View File

@ -26,7 +26,7 @@ var (
MonaTestParams monacoinCfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = []byte{50}
@ -71,6 +71,9 @@ func NewMonacoinParser(params *chaincfg.Params, c *btc.Configuration) *MonacoinP
// GetChainParams contains network parameters for the main Monacoin network,
// and the test Monacoin network
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
switch chain {
case "test":
return &TestNetParams

View File

@ -18,7 +18,7 @@ var (
MainNetParams chaincfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = []byte{52}
@ -43,6 +43,9 @@ func NewNamecoinParser(params *chaincfg.Params, c *btc.Configuration) *NamecoinP
// GetChainParams contains network parameters for the main Namecoin network,
// and the test Namecoin network
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
switch chain {
default:
return &MainNetParams

View File

@ -18,7 +18,7 @@ var (
TestNetParams chaincfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
MainNetParams.PubKeyHashAddrID = []byte{71}
@ -53,6 +53,9 @@ func NewVertcoinParser(params *chaincfg.Params, c *btc.Configuration) *VertcoinP
// GetChainParams contains network parameters for the main Vertcoin network,
// and the test Vertcoin network
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
switch chain {
case "test":
return &TestNetParams

View File

@ -19,7 +19,7 @@ var (
TestNetParams chaincfg.Params
)
func init() {
func initParams() {
MainNetParams = chaincfg.MainNetParams
MainNetParams.Net = MainnetMagic
@ -63,6 +63,9 @@ func NewZCashParser(params *chaincfg.Params, c *btc.Configuration) *ZCashParser
// the regression test ZCash network, the test ZCash network and
// the simulation test ZCash network, in this order
func GetChainParams(chain string) *chaincfg.Params {
if MainNetParams.Name == "" {
initParams()
}
var params *chaincfg.Params
switch chain {
case "test":