2013-08-06 23:55:22 +02:00
|
|
|
// Copyright (c) 2013 Conformal Systems LLC.
|
|
|
|
// Use of this source code is governed by an ISC
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/conformal/btcchain"
|
|
|
|
"github.com/conformal/btcwire"
|
|
|
|
"math/big"
|
|
|
|
)
|
|
|
|
|
|
|
|
// activeNetParams is a pointer to the parameters specific to the
|
|
|
|
// currently active bitcoin network.
|
|
|
|
var activeNetParams = netParams(defaultBtcnet)
|
|
|
|
|
|
|
|
// params is used to group parameters for various networks such as the main
|
|
|
|
// network and test networks.
|
|
|
|
type params struct {
|
2013-09-15 19:08:42 +02:00
|
|
|
netName string
|
2013-08-06 23:55:22 +02:00
|
|
|
btcnet btcwire.BitcoinNet
|
|
|
|
genesisBlock *btcwire.MsgBlock
|
|
|
|
genesisHash *btcwire.ShaHash
|
|
|
|
powLimit *big.Int
|
|
|
|
powLimitBits uint32
|
|
|
|
peerPort string
|
|
|
|
listenPort string
|
|
|
|
rpcPort string
|
|
|
|
dnsSeeds []string
|
|
|
|
}
|
|
|
|
|
|
|
|
// mainNetParams contains parameters specific to the main network
|
2013-10-16 22:01:43 +02:00
|
|
|
// (btcwire.MainNet). NOTE: The RPC port is intentionally different than the
|
|
|
|
// reference implementation because btcd does not handle wallet requests. The
|
|
|
|
// separate wallet process listens on the well-known port and forwards requests
|
|
|
|
// it does not handle on to btcd. This approach allows the wallet process
|
|
|
|
// to emulate the full reference implementation RPC API.
|
2013-08-06 23:55:22 +02:00
|
|
|
var mainNetParams = params{
|
2013-09-15 19:08:42 +02:00
|
|
|
netName: "mainnet",
|
2013-08-06 23:55:22 +02:00
|
|
|
btcnet: btcwire.MainNet,
|
|
|
|
genesisBlock: btcchain.ChainParams(btcwire.MainNet).GenesisBlock,
|
|
|
|
genesisHash: btcchain.ChainParams(btcwire.MainNet).GenesisHash,
|
|
|
|
powLimit: btcchain.ChainParams(btcwire.MainNet).PowLimit,
|
|
|
|
powLimitBits: btcchain.ChainParams(btcwire.MainNet).PowLimitBits,
|
|
|
|
listenPort: btcwire.MainPort,
|
|
|
|
peerPort: btcwire.MainPort,
|
2013-10-16 22:01:43 +02:00
|
|
|
rpcPort: "8334",
|
2013-08-06 23:55:22 +02:00
|
|
|
dnsSeeds: []string{
|
|
|
|
"seed.bitcoin.sipa.be",
|
|
|
|
"dnsseed.bluematt.me",
|
|
|
|
"dnsseed.bitcoin.dashjr.org",
|
|
|
|
"bitseed.xf2.org",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// regressionParams contains parameters specific to the regression test network
|
2013-10-16 22:01:43 +02:00
|
|
|
// (btcwire.TestNet). NOTE: The RPC port is intentionally different than the
|
|
|
|
// reference implementation - see the mainNetParams comment for details.
|
2013-08-06 23:55:22 +02:00
|
|
|
var regressionParams = params{
|
2013-09-15 19:08:42 +02:00
|
|
|
netName: "regtest",
|
2013-08-06 23:55:22 +02:00
|
|
|
btcnet: btcwire.TestNet,
|
|
|
|
genesisBlock: btcchain.ChainParams(btcwire.TestNet).GenesisBlock,
|
|
|
|
genesisHash: btcchain.ChainParams(btcwire.TestNet).GenesisHash,
|
|
|
|
powLimit: btcchain.ChainParams(btcwire.TestNet).PowLimit,
|
|
|
|
powLimitBits: btcchain.ChainParams(btcwire.TestNet).PowLimitBits,
|
|
|
|
listenPort: btcwire.RegressionTestPort,
|
|
|
|
peerPort: btcwire.TestNetPort,
|
2013-10-16 22:01:43 +02:00
|
|
|
rpcPort: "18334",
|
2013-08-06 23:55:22 +02:00
|
|
|
dnsSeeds: []string{},
|
|
|
|
}
|
|
|
|
|
|
|
|
// testNet3Params contains parameters specific to the test network (version 3)
|
2013-10-16 22:01:43 +02:00
|
|
|
// (btcwire.TestNet3). NOTE: The RPC port is intentionally different than the
|
|
|
|
// reference implementation - see the mainNetParams comment for details.
|
2013-08-06 23:55:22 +02:00
|
|
|
var testNet3Params = params{
|
2013-09-15 19:08:42 +02:00
|
|
|
netName: "testnet",
|
2013-08-06 23:55:22 +02:00
|
|
|
btcnet: btcwire.TestNet3,
|
|
|
|
genesisBlock: btcchain.ChainParams(btcwire.TestNet3).GenesisBlock,
|
|
|
|
genesisHash: btcchain.ChainParams(btcwire.TestNet3).GenesisHash,
|
|
|
|
powLimit: btcchain.ChainParams(btcwire.TestNet3).PowLimit,
|
|
|
|
powLimitBits: btcchain.ChainParams(btcwire.TestNet3).PowLimitBits,
|
|
|
|
listenPort: btcwire.TestNetPort,
|
|
|
|
peerPort: btcwire.TestNetPort,
|
2013-10-16 22:01:43 +02:00
|
|
|
rpcPort: "18334",
|
2013-08-06 23:55:22 +02:00
|
|
|
dnsSeeds: []string{
|
|
|
|
"testnet-seed.bitcoin.petertodd.org",
|
|
|
|
"testnet-seed.bluematt.me",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
// netParams returns parameters specific to the passed bitcoin network.
|
|
|
|
func netParams(btcnet btcwire.BitcoinNet) *params {
|
|
|
|
switch btcnet {
|
|
|
|
case btcwire.TestNet:
|
|
|
|
return ®ressionParams
|
|
|
|
|
|
|
|
case btcwire.TestNet3:
|
|
|
|
return &testNet3Params
|
|
|
|
|
|
|
|
// Return main net by default.
|
|
|
|
case btcwire.MainNet:
|
|
|
|
fallthrough
|
|
|
|
default:
|
|
|
|
return &mainNetParams
|
|
|
|
}
|
|
|
|
}
|