From 13cf1f7715ede79f4a6b039c63e96e72a25580ef Mon Sep 17 00:00:00 2001
From: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com>
Date: Tue, 8 Oct 2019 12:59:54 +0300
Subject: [PATCH] [NOD-360] Renamed TestNet3 to TestNet. (#426)
---
CHANGES | 4 +--
apiserver/config/config.go | 2 +-
blockdag/fullblocktests/params.go | 2 +-
cmd/addblock/config.go | 27 +++-----------------
cmd/addsubnetwork/config.go | 2 +-
cmd/btcctl/config.go | 10 ++++----
cmd/findcheckpoint/config.go | 27 +++-----------------
config/config.go | 6 ++---
dagconfig/README.md | 2 +-
dagconfig/doc.go | 6 ++---
dagconfig/genesis.go | 24 +++++++++---------
dagconfig/genesis_test.go | 30 +++++++++++-----------
dagconfig/params.go | 37 +++++++++++++---------------
dagconfig/register_test.go | 16 ++++++------
database/cmd/dbtool/globalconfig.go | 27 +++-----------------
dnsseeder/config.go | 2 +-
docs/json_rpc_api.md | 2 +-
integration/rpctest/rpc_harness.go | 4 +--
peer/peer.go | 4 +--
server/rpc/handle_get_info.go | 2 +-
server/rpc/handle_get_mining_info.go | 2 +-
txscript/sign_test.go | 18 +++++++-------
util/wif.go | 2 +-
util/wif_test.go | 2 +-
wire/bench_test.go | 2 +-
wire/doc.go | 4 +--
wire/message_test.go | 10 ++++----
wire/protocol.go | 18 +++++++-------
wire/protocol_test.go | 2 +-
29 files changed, 118 insertions(+), 178 deletions(-)
diff --git a/CHANGES b/CHANGES
index 6f7013e92..626601996 100644
--- a/CHANGES
+++ b/CHANGES
@@ -513,7 +513,7 @@ Changes in 0.8.0-beta (Sun May 25 2014)
- Reduce max bytes allowed for a standard nulldata transaction to 40 for
compatibility with the reference client
- Introduce a new btcnet package which houses all of the network params
- for each network (mainnet, testnet3, regtest) to ultimately enable
+ for each network (mainnet, testnet, regtest) to ultimately enable
easier addition and tweaking of networks without needing to change
several packages
- Fix several script discrepancies found by reference client test data
@@ -530,7 +530,7 @@ Changes in 0.8.0-beta (Sun May 25 2014)
- Provide options to control block template creation settings
- Support the getwork RPC
- Allow address identifiers to apply to more than one network since both
- testnet3 and the regression test network unfortunately use the same
+ testnet and the regression test network unfortunately use the same
identifier
- RPC changes:
- Set the content type for HTTP POST RPC connections to application/json
diff --git a/apiserver/config/config.go b/apiserver/config/config.go
index 257908542..5e88d96df 100644
--- a/apiserver/config/config.go
+++ b/apiserver/config/config.go
@@ -110,7 +110,7 @@ func resolveNetwork(cfg *Config) error {
activeNetParams = dagconfig.MainNetParams
switch {
case cfg.TestNet:
- activeNetParams = dagconfig.TestNet3Params
+ activeNetParams = dagconfig.TestNetParams
case cfg.SimNet:
activeNetParams = dagconfig.SimNetParams
case cfg.DevNet:
diff --git a/blockdag/fullblocktests/params.go b/blockdag/fullblocktests/params.go
index e7811f30b..585b43d75 100644
--- a/blockdag/fullblocktests/params.go
+++ b/blockdag/fullblocktests/params.go
@@ -111,7 +111,7 @@ var (
// allow them to change out from under the tests potentially invalidating them.
var regressionNetParams = &dagconfig.Params{
Name: "regtest",
- Net: wire.TestNet,
+ Net: wire.RegTest,
DefaultPort: "18444",
// DAG parameters
diff --git a/cmd/addblock/config.go b/cmd/addblock/config.go
index c8bc897ac..96eb367a0 100644
--- a/cmd/addblock/config.go
+++ b/cmd/addblock/config.go
@@ -14,7 +14,6 @@ import (
"github.com/daglabs/btcd/database"
_ "github.com/daglabs/btcd/database/ffldb"
"github.com/daglabs/btcd/util"
- "github.com/daglabs/btcd/wire"
flags "github.com/jessevdk/go-flags"
)
@@ -37,7 +36,7 @@ var (
type config struct {
DataDir string `short:"b" long:"datadir" description:"Location of the btcd data directory"`
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
- TestNet3 bool `long:"testnet" description:"Use the test network"`
+ TestNet bool `long:"testnet" description:"Use the test network"`
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
SimNet bool `long:"simnet" description:"Use the simulation test network"`
DevNet bool `long:"devnet" description:"Use the development test network"`
@@ -68,24 +67,6 @@ func validDbType(dbType string) bool {
return false
}
-// netName returns the name used when referring to a bitcoin network. At the
-// time of writing, btcd currently places blocks for testnet version 3 in the
-// data and log directory "testnet", which does not match the Name field of the
-// dagconfig parameters. This function can be used to override this directory name
-// as "testnet" when the passed active network matches wire.TestNet3.
-//
-// A proper upgrade to move the data and log directories for this network to
-// "testnet3" is planned for the future, at which point this function can be
-// removed and the network parameter's name used instead.
-func netName(chainParams *dagconfig.Params) string {
- switch chainParams.Net {
- case wire.TestNet3:
- return "testnet"
- default:
- return chainParams.Name
- }
-}
-
// loadConfig initializes and parses the config using command line options.
func loadConfig() (*config, []string, error) {
// Default config.
@@ -111,9 +92,9 @@ func loadConfig() (*config, []string, error) {
numNets := 0
// Count number of network flags passed; assign active network params
// while we're at it
- if cfg.TestNet3 {
+ if cfg.TestNet {
numNets++
- activeNetParams = &dagconfig.TestNet3Params
+ activeNetParams = &dagconfig.TestNetParams
}
if cfg.RegressionTest {
numNets++
@@ -152,7 +133,7 @@ func loadConfig() (*config, []string, error) {
// All data is specific to a network, so namespacing the data directory
// means each individual piece of serialized data does not have to
// worry about changing names per network and such.
- cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))
+ cfg.DataDir = filepath.Join(cfg.DataDir, activeNetParams.Name)
// Ensure the specified block file exists.
if !fileExists(cfg.InFile) {
diff --git a/cmd/addsubnetwork/config.go b/cmd/addsubnetwork/config.go
index 14567f431..2ce4fed98 100644
--- a/cmd/addsubnetwork/config.go
+++ b/cmd/addsubnetwork/config.go
@@ -66,7 +66,7 @@ func parseConfig() (*config, error) {
activeNetParams = dagconfig.MainNetParams
switch {
case cfg.TestNet:
- activeNetParams = dagconfig.TestNet3Params
+ activeNetParams = dagconfig.TestNetParams
case cfg.SimNet:
activeNetParams = dagconfig.SimNetParams
case cfg.DevNet:
diff --git a/cmd/btcctl/config.go b/cmd/btcctl/config.go
index 77d4aa563..c7a1b3324 100644
--- a/cmd/btcctl/config.go
+++ b/cmd/btcctl/config.go
@@ -96,7 +96,7 @@ type config struct {
Proxy string `long:"proxy" description:"Connect via SOCKS5 proxy (eg. 127.0.0.1:9050)"`
ProxyUser string `long:"proxyuser" description:"Username for proxy server"`
ProxyPass string `long:"proxypass" default-mask:"-" description:"Password for proxy server"`
- TestNet3 bool `long:"testnet" description:"Connect to testnet"`
+ TestNet bool `long:"testnet" description:"Connect to testnet"`
SimNet bool `long:"simnet" description:"Connect to the simulation test network"`
DevNet bool `long:"devnet" description:"Connect to the development test network"`
TLSSkipVerify bool `long:"skipverify" description:"Do not verify tls certificates (not recommended!)"`
@@ -104,14 +104,14 @@ type config struct {
// normalizeAddress returns addr with the passed default port appended if
// there is not already a port specified.
-func normalizeAddress(addr string, useTestNet3, useSimNet, useDevNet bool) string {
+func normalizeAddress(addr string, useTestNet, useSimNet, useDevNet bool) string {
_, _, err := net.SplitHostPort(addr)
if err != nil {
var defaultPort string
switch {
case useDevNet:
fallthrough
- case useTestNet3:
+ case useTestNet:
defaultPort = "18334"
case useSimNet:
defaultPort = "18556"
@@ -226,7 +226,7 @@ func loadConfig() (*config, []string, error) {
// Multiple networks can't be selected simultaneously.
numNets := 0
- if cfg.TestNet3 {
+ if cfg.TestNet {
numNets++
}
if cfg.SimNet {
@@ -248,7 +248,7 @@ func loadConfig() (*config, []string, error) {
// Add default port to RPC server based on --testnet and --simnet flags
// if needed.
- cfg.RPCServer = normalizeAddress(cfg.RPCServer, cfg.TestNet3,
+ cfg.RPCServer = normalizeAddress(cfg.RPCServer, cfg.TestNet,
cfg.SimNet, cfg.DevNet)
return &cfg, remainingArgs, nil
diff --git a/cmd/findcheckpoint/config.go b/cmd/findcheckpoint/config.go
index b63341cf1..bf87c0e27 100644
--- a/cmd/findcheckpoint/config.go
+++ b/cmd/findcheckpoint/config.go
@@ -14,7 +14,6 @@ import (
"github.com/daglabs/btcd/database"
_ "github.com/daglabs/btcd/database/ffldb"
"github.com/daglabs/btcd/util"
- "github.com/daglabs/btcd/wire"
flags "github.com/jessevdk/go-flags"
)
@@ -38,7 +37,7 @@ var (
type config struct {
DataDir string `short:"b" long:"datadir" description:"Location of the btcd data directory"`
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
- TestNet3 bool `long:"testnet" description:"Use the test network"`
+ TestNet bool `long:"testnet" description:"Use the test network"`
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
SimNet bool `long:"simnet" description:"Use the simulation test network"`
DevNet bool `long:"devnet" description:"Use the development test network"`
@@ -57,24 +56,6 @@ func validDbType(dbType string) bool {
return false
}
-// netName returns the name used when referring to a bitcoin network. At the
-// time of writing, btcd currently places blocks for testnet version 3 in the
-// data and log directory "testnet", which does not match the Name field of the
-// dagconfig parameters. This function can be used to override this directory name
-// as "testnet" when the passed active network matches wire.TestNet3.
-//
-// A proper upgrade to move the data and log directories for this network to
-// "testnet3" is planned for the future, at which point this function can be
-// removed and the network parameter's name used instead.
-func netName(chainParams *dagconfig.Params) string {
- switch chainParams.Net {
- case wire.TestNet3:
- return "testnet"
- default:
- return chainParams.Name
- }
-}
-
// loadConfig initializes and parses the config using command line options.
func loadConfig() (*config, []string, error) {
// Default config.
@@ -99,9 +80,9 @@ func loadConfig() (*config, []string, error) {
numNets := 0
// Count number of network flags passed; assign active network params
// while we're at it
- if cfg.TestNet3 {
+ if cfg.TestNet {
numNets++
- activeNetParams = &dagconfig.TestNet3Params
+ activeNetParams = &dagconfig.TestNetParams
}
if cfg.RegressionTest {
numNets++
@@ -140,7 +121,7 @@ func loadConfig() (*config, []string, error) {
// All data is specific to a network, so namespacing the data directory
// means each individual piece of serialized data does not have to
// worry about changing names per network and such.
- cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))
+ cfg.DataDir = filepath.Join(cfg.DataDir, activeNetParams.Name)
// Validate the number of candidates.
if cfg.NumCandidates < minCandidates || cfg.NumCandidates > maxCandidates {
diff --git a/config/config.go b/config/config.go
index 1bdbd7944..dd334254f 100644
--- a/config/config.go
+++ b/config/config.go
@@ -134,7 +134,7 @@ type configFlags struct {
OnionProxyPass string `long:"onionpass" default-mask:"-" description:"Password for onion proxy server"`
NoOnion bool `long:"noonion" description:"Disable connecting to tor hidden services"`
TorIsolation bool `long:"torisolation" description:"Enable Tor stream isolation by randomizing user credentials for each connection."`
- TestNet3 bool `long:"testnet" description:"Use the test network"`
+ TestNet bool `long:"testnet" description:"Use the test network"`
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
SimNet bool `long:"simnet" description:"Use the simulation test network"`
DevNet bool `long:"devnet" description:"Use the development test network"`
@@ -428,9 +428,9 @@ func loadConfig() (*Config, []string, error) {
numNets := 0
// Count number of network flags passed; assign active network params
// while we're at it
- if cfg.TestNet3 {
+ if cfg.TestNet {
numNets++
- activeNetParams = &dagconfig.TestNet3Params
+ activeNetParams = &dagconfig.TestNetParams
}
if cfg.RegressionTest {
numNets++
diff --git a/dagconfig/README.md b/dagconfig/README.md
index dd5a0991a..e44980e00 100644
--- a/dagconfig/README.md
+++ b/dagconfig/README.md
@@ -38,7 +38,7 @@ func main() {
// Modify active network parameters if operating on testnet.
if *testnet {
- chainParams = &chaincfg.TestNet3Params
+ chainParams = &chaincfg.TestNetParams
}
// later...
diff --git a/dagconfig/doc.go b/dagconfig/doc.go
index fc1747dc4..f83c395d0 100644
--- a/dagconfig/doc.go
+++ b/dagconfig/doc.go
@@ -2,7 +2,7 @@
//
// In addition to the main Bitcoin network, which is intended for the transfer
// of monetary value, there also exists two currently active standard networks:
-// regression test and testnet (version 3). These networks are incompatible
+// regression test and testnet. These networks are incompatible
// with each other (each sharing a different genesis block) and software should
// handle errors where input intended for one network is used on an application
// instance running on a different network.
@@ -39,7 +39,7 @@
//
// // Modify active network parameters if operating on testnet.
// if *testnet {
-// chainParams = &dagconfig.TestNet3Params
+// chainParams = &dagconfig.TestNetParams
// }
//
// // later...
@@ -57,5 +57,5 @@
// a new Params struct may be created which defines the parameters for the
// non-standard network. As a general rule of thumb, all network parameters
// should be unique to the network, but parameter collisions can still occur
-// (unfortunately, this is the case with regtest and testnet3 sharing magics).
+// (unfortunately, this is the case with regtest and testnet sharing magics).
package dagconfig
diff --git a/dagconfig/genesis.go b/dagconfig/genesis.go
index c44d82b9c..381a1e986 100644
--- a/dagconfig/genesis.go
+++ b/dagconfig/genesis.go
@@ -36,7 +36,7 @@ var genesisTxPayload = []byte{
}
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
-// the main network, regression test network, and test network (version 3).
+// the main network, regression test network, and test network.
var genesisCoinbaseTx = wire.NewSubnetworkMsgTx(1, genesisTxIns, genesisTxOuts, subnetworkid.SubnetworkIDCoinbase, 0, genesisTxPayload)
// genesisHash is the hash of the first block in the block DAG for the main
@@ -86,18 +86,18 @@ var regTestGenesisMerkleRoot = genesisMerkleRoot
// as the public transaction ledger for the regression test network.
var regTestGenesisBlock = genesisBlock
-// testNet3GenesisHash is the hash of the first block in the block chain for the
-// test network (version 3).
-var testNet3GenesisHash = genesisHash
+// testNetGenesisHash is the hash of the first block in the block chain for the
+// test network.
+var testNetGenesisHash = genesisHash
-// testNet3GenesisMerkleRoot is the hash of the first transaction in the genesis
-// block for the test network (version 3). It is the same as the merkle root
-// for the main network.
-var testNet3GenesisMerkleRoot = genesisMerkleRoot
+// testNetGenesisMerkleRoot is the hash of the first transaction in the genesis
+// block for the test network. It is the same as the merkle root for the main
+// network.
+var testNetGenesisMerkleRoot = genesisMerkleRoot
-// testNet3GenesisBlock defines the genesis block of the block chain which
-// serves as the public transaction ledger for the test network (version 3).
-var testNet3GenesisBlock = genesisBlock
+// testNetGenesisBlock defines the genesis block of the block chain which
+// serves as the public transaction ledger for the test network.
+var testNetGenesisBlock = genesisBlock
// simNetGenesisHash is the hash of the first block in the block chain for the
// simulation test network.
@@ -113,7 +113,7 @@ var simNetGenesisMerkleRoot = genesisMerkleRoot
var simNetGenesisBlock = genesisBlock
// devNetGenesisCoinbaseTx is the coinbase transaction for the genesis blocks for
-// the main network, regression test network, and test network (version 3).
+// the main network, regression test network, and test network.
var devNetGenesisCoinbaseTx = genesisCoinbaseTx
// devGenesisHash is the hash of the first block in the block DAG for the development
diff --git a/dagconfig/genesis_test.go b/dagconfig/genesis_test.go
index 429a0b614..7c8d80d60 100644
--- a/dagconfig/genesis_test.go
+++ b/dagconfig/genesis_test.go
@@ -64,30 +64,30 @@ func TestRegTestGenesisBlock(t *testing.T) {
}
}
-// TestTestNet3GenesisBlock tests the genesis block of the test network (version
-// 3) for validity by checking the encoded bytes and hashes.
-func TestTestNet3GenesisBlock(t *testing.T) {
+// TestTestNetGenesisBlock tests the genesis block of the test network for
+// validity by checking the encoded bytes and hashes.
+func TestTestNetGenesisBlock(t *testing.T) {
// Encode the genesis block to raw bytes.
var buf bytes.Buffer
- err := TestNet3Params.GenesisBlock.Serialize(&buf)
+ err := TestNetParams.GenesisBlock.Serialize(&buf)
if err != nil {
- t.Fatalf("TestTestNet3GenesisBlock: %v", err)
+ t.Fatalf("TestTestNetGenesisBlock: %v", err)
}
// Ensure the encoded block matches the expected bytes.
- if !bytes.Equal(buf.Bytes(), testNet3GenesisBlockBytes) {
- t.Fatalf("TestTestNet3GenesisBlock: Genesis block does not "+
+ if !bytes.Equal(buf.Bytes(), testNetGenesisBlockBytes) {
+ t.Fatalf("TestTestNetGenesisBlock: Genesis block does not "+
"appear valid - got %v, want %v",
spew.Sdump(buf.Bytes()),
- spew.Sdump(testNet3GenesisBlockBytes))
+ spew.Sdump(testNetGenesisBlockBytes))
}
// Check hash of the block against expected hash.
- hash := TestNet3Params.GenesisBlock.BlockHash()
- if !TestNet3Params.GenesisHash.IsEqual(hash) {
- t.Fatalf("TestTestNet3GenesisBlock: Genesis block hash does "+
+ hash := TestNetParams.GenesisBlock.BlockHash()
+ if !TestNetParams.GenesisHash.IsEqual(hash) {
+ t.Fatalf("TestTestNetGenesisBlock: Genesis block hash does "+
"not appear valid - got %v, want %v", spew.Sdump(hash),
- spew.Sdump(TestNet3Params.GenesisHash))
+ spew.Sdump(TestNetParams.GenesisHash))
}
}
@@ -145,9 +145,9 @@ var genesisBlockBytes = []byte{
// the regression test network as of protocol version 60002.
var regTestGenesisBlockBytes = genesisBlockBytes
-// testNet3GenesisBlockBytes are the wire encoded bytes for the genesis block of
-// the test network (version 3) as of protocol version 60002.
-var testNet3GenesisBlockBytes = genesisBlockBytes
+// testNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
+// the test network as of protocol version 60002.
+var testNetGenesisBlockBytes = genesisBlockBytes
// simNetGenesisBlockBytes are the wire encoded bytes for the genesis block of
// the simulation test network as of protocol version 70002.
diff --git a/dagconfig/params.go b/dagconfig/params.go
index dd2d42dea..2f39defe2 100644
--- a/dagconfig/params.go
+++ b/dagconfig/params.go
@@ -20,29 +20,28 @@ import (
// These variables are the chain proof-of-work limit parameters for each default
// network.
var (
- // bigOne is 1 represented as a big.Int. It is defined here to avoid
+ // bigOne is 1 represented as a big.Int. It is defined here to avoid
// the overhead of creating it multiple times.
bigOne = big.NewInt(1)
// mainPowMax is the highest proof of work value a Bitcoin block can
- // have for the main network. It is the value 2^255 - 1.
+ // have for the main network. It is the value 2^255 - 1.
mainPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
// regressionPowMax is the highest proof of work value a Bitcoin block
- // can have for the regression test network. It is the value 2^255 - 1.
+ // can have for the regression test network. It is the value 2^255 - 1.
regressionPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
- // testNet3PowMax is the highest proof of work value a Bitcoin block
- // can have for the test network (version 3). It is the value
- // 2^255 - 1.
- testNet3PowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
+ // testNetPowMax is the highest proof of work value a Bitcoin block
+ // can have for the test network. It is the value 2^255 - 1.
+ testNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
// simNetPowMax is the highest proof of work value a Bitcoin block
- // can have for the simulation test network. It is the value 2^255 - 1.
+ // can have for the simulation test network. It is the value 2^255 - 1.
simNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 255), bigOne)
// devNetPowMax is the highest proof of work value a Bitcoin block
- // can have for the development network. It is the value
+ // can have for the development network. It is the value
// 2^239 - 1.
devNetPowMax = new(big.Int).Sub(new(big.Int).Lsh(bigOne, 239), bigOne)
)
@@ -254,7 +253,7 @@ var MainNetParams = Params{
var RegressionNetParams = Params{
K: phantomK,
Name: "regtest",
- Net: wire.TestNet,
+ Net: wire.RegTest,
RPCPort: "18334",
DefaultPort: "18444",
DNSSeeds: []string{},
@@ -308,21 +307,19 @@ var RegressionNetParams = Params{
HDCoinType: 1,
}
-// TestNet3Params defines the network parameters for the test Bitcoin network
-// (version 3). Not to be confused with the regression test network, this
-// network is sometimes simply called "testnet".
-var TestNet3Params = Params{
+// TestNetParams defines the network parameters for the test Bitcoin network.
+var TestNetParams = Params{
K: phantomK,
- Name: "testnet3",
- Net: wire.TestNet3,
+ Name: "testnet",
+ Net: wire.TestNet,
RPCPort: "18334",
DefaultPort: "18333",
DNSSeeds: []string{},
// DAG parameters
- GenesisBlock: &testNet3GenesisBlock,
- GenesisHash: &testNet3GenesisHash,
- PowMax: testNet3PowMax,
+ GenesisBlock: &testNetGenesisBlock,
+ GenesisHash: &testNetGenesisHash,
+ PowMax: testNetPowMax,
BlockCoinbaseMaturity: 100,
SubsidyReductionInterval: 210000,
TargetTimePerBlock: time.Second * 1, // 1 second
@@ -547,7 +544,7 @@ func newHashFromStr(hexStr string) *daghash.Hash {
func init() {
// Register all default networks when the package is initialized.
mustRegister(&MainNetParams)
- mustRegister(&TestNet3Params)
+ mustRegister(&TestNetParams)
mustRegister(&RegressionNetParams)
mustRegister(&SimNetParams)
}
diff --git a/dagconfig/register_test.go b/dagconfig/register_test.go
index 313b516c7..9b3a8464d 100644
--- a/dagconfig/register_test.go
+++ b/dagconfig/register_test.go
@@ -52,8 +52,8 @@ func TestRegister(t *testing.T) {
err: ErrDuplicateNet,
},
{
- name: "duplicate testnet3",
- params: &TestNet3Params,
+ name: "duplicate testnet",
+ params: &TestNetParams,
err: ErrDuplicateNet,
},
{
@@ -69,8 +69,8 @@ func TestRegister(t *testing.T) {
err: nil,
},
{
- priv: TestNet3Params.HDKeyIDPair.PrivateKeyID[:],
- want: TestNet3Params.HDKeyIDPair.PublicKeyID[:],
+ priv: TestNetParams.HDKeyIDPair.PrivateKeyID[:],
+ want: TestNetParams.HDKeyIDPair.PublicKeyID[:],
err: nil,
},
{
@@ -128,8 +128,8 @@ func TestRegister(t *testing.T) {
err: ErrDuplicateNet,
},
{
- name: "duplicate testnet3",
- params: &TestNet3Params,
+ name: "duplicate testnet",
+ params: &TestNetParams,
err: ErrDuplicateNet,
},
{
@@ -150,8 +150,8 @@ func TestRegister(t *testing.T) {
err: nil,
},
{
- priv: TestNet3Params.HDKeyIDPair.PrivateKeyID[:],
- want: TestNet3Params.HDKeyIDPair.PublicKeyID[:],
+ priv: TestNetParams.HDKeyIDPair.PrivateKeyID[:],
+ want: TestNetParams.HDKeyIDPair.PublicKeyID[:],
err: nil,
},
{
diff --git a/database/cmd/dbtool/globalconfig.go b/database/cmd/dbtool/globalconfig.go
index f6f2eccee..1819788cd 100644
--- a/database/cmd/dbtool/globalconfig.go
+++ b/database/cmd/dbtool/globalconfig.go
@@ -15,7 +15,6 @@ import (
"github.com/daglabs/btcd/database"
_ "github.com/daglabs/btcd/database/ffldb"
"github.com/daglabs/btcd/util"
- "github.com/daglabs/btcd/wire"
)
var (
@@ -34,7 +33,7 @@ var (
type config struct {
DataDir string `short:"b" long:"datadir" description:"Location of the btcd data directory"`
DbType string `long:"dbtype" description:"Database backend to use for the Block Chain"`
- TestNet3 bool `long:"testnet" description:"Use the test network"`
+ TestNet bool `long:"testnet" description:"Use the test network"`
RegressionTest bool `long:"regtest" description:"Use the regression test network"`
SimNet bool `long:"simnet" description:"Use the simulation test network"`
DevNet bool `long:"devnet" description:"Use the development test network"`
@@ -61,24 +60,6 @@ func validDbType(dbType string) bool {
return false
}
-// netName returns the name used when referring to a bitcoin network. At the
-// time of writing, btcd currently places blocks for testnet version 3 in the
-// data and log directory "testnet", which does not match the Name field of the
-// dagconfig parameters. This function can be used to override this directory name
-// as "testnet" when the passed active network matches wire.TestNet3.
-//
-// A proper upgrade to move the data and log directories for this network to
-// "testnet3" is planned for the future, at which point this function can be
-// removed and the network parameter's name used instead.
-func netName(chainParams *dagconfig.Params) string {
- switch chainParams.Net {
- case wire.TestNet3:
- return "testnet"
- default:
- return chainParams.Name
- }
-}
-
// setupGlobalConfig examine the global configuration options for any conditions
// which are invalid as well as performs any addition setup necessary after the
// initial parse.
@@ -87,9 +68,9 @@ func setupGlobalConfig() error {
// Count number of network flags passed; assign active network params
// while we're at it
numNets := 0
- if cfg.TestNet3 {
+ if cfg.TestNet {
numNets++
- activeNetParams = &dagconfig.TestNet3Params
+ activeNetParams = &dagconfig.TestNetParams
}
if cfg.RegressionTest {
numNets++
@@ -121,7 +102,7 @@ func setupGlobalConfig() error {
// All data is specific to a network, so namespacing the data directory
// means each individual piece of serialized data does not have to
// worry about changing names per network and such.
- cfg.DataDir = filepath.Join(cfg.DataDir, netName(activeNetParams))
+ cfg.DataDir = filepath.Join(cfg.DataDir, activeNetParams.Name)
return nil
}
diff --git a/dnsseeder/config.go b/dnsseeder/config.go
index a866623a9..94a2d5d12 100644
--- a/dnsseeder/config.go
+++ b/dnsseeder/config.go
@@ -129,7 +129,7 @@ func loadConfig() (*config, error) {
fmt.Fprintln(os.Stderr, err)
return nil, err
} else if cfg.TestNet {
- activeNetParams = &dagconfig.TestNet3Params
+ activeNetParams = &dagconfig.TestNetParams
} else if cfg.DevNet {
activeNetParams = &dagconfig.DevNetParams
}
diff --git a/docs/json_rpc_api.md b/docs/json_rpc_api.md
index 32a343e78..225aa5a56 100644
--- a/docs/json_rpc_api.md
+++ b/docs/json_rpc_api.md
@@ -621,7 +621,7 @@ The following is an overview of the RPC methods which are implemented by btcd, b
|Parameters|None|
|Description|Get bitcoin network btcd is running on.|
|Returns|numeric|
-|Example Return|`3652501241` (mainnet)
`118034699` (testnet3)|
+|Example Return|`3652501241` (mainnet)
`118034699` (testnet)|
[Return to Overview](#ExtMethodOverview)
***
diff --git a/integration/rpctest/rpc_harness.go b/integration/rpctest/rpc_harness.go
index 56eef57be..cace0af16 100644
--- a/integration/rpctest/rpc_harness.go
+++ b/integration/rpctest/rpc_harness.go
@@ -109,9 +109,9 @@ func New(activeNet *dagconfig.Params, handlers *rpcclient.NotificationHandlers,
switch activeNet.Net {
case wire.MainNet:
// No extra flags since mainnet is the default
- case wire.TestNet3:
- extraArgs = append(extraArgs, "--testnet")
case wire.TestNet:
+ extraArgs = append(extraArgs, "--testnet")
+ case wire.RegTest:
extraArgs = append(extraArgs, "--regtest")
case wire.SimNet:
extraArgs = append(extraArgs, "--simnet")
diff --git a/peer/peer.go b/peer/peer.go
index f1af514a9..5dba956b7 100644
--- a/peer/peer.go
+++ b/peer/peer.go
@@ -1146,7 +1146,7 @@ func (p *Peer) writeMessage(msg wire.Message) error {
// to send malformed messages without the peer being disconnected.
func (p *Peer) isAllowedReadError(err error) bool {
// Only allow read errors in regression test mode.
- if p.cfg.DAGParams.Net != wire.TestNet {
+ if p.cfg.DAGParams.Net != wire.RegTest {
return false
}
@@ -2064,7 +2064,7 @@ func newPeerBase(origCfg *Config, inbound bool) *Peer {
// Set the DAG parameters to testnet if the caller did not specify any.
if cfg.DAGParams == nil {
- cfg.DAGParams = &dagconfig.TestNet3Params
+ cfg.DAGParams = &dagconfig.TestNetParams
}
p := Peer{
diff --git a/server/rpc/handle_get_info.go b/server/rpc/handle_get_info.go
index 40206f7d4..155c9c83b 100644
--- a/server/rpc/handle_get_info.go
+++ b/server/rpc/handle_get_info.go
@@ -17,7 +17,7 @@ func handleGetInfo(s *Server, cmd interface{}, closeChan <-chan struct{}) (inter
Connections: s.cfg.ConnMgr.ConnectedCount(),
Proxy: config.MainConfig().Proxy,
Difficulty: getDifficultyRatio(s.cfg.DAG.CurrentBits(), s.cfg.DAGParams),
- TestNet: config.MainConfig().TestNet3,
+ TestNet: config.MainConfig().TestNet,
DevNet: config.MainConfig().DevNet,
RelayFee: config.MainConfig().MinRelayTxFee.ToBTC(),
}
diff --git a/server/rpc/handle_get_mining_info.go b/server/rpc/handle_get_mining_info.go
index e6443922c..2ec238a67 100644
--- a/server/rpc/handle_get_mining_info.go
+++ b/server/rpc/handle_get_mining_info.go
@@ -50,7 +50,7 @@ func handleGetMiningInfo(s *Server, cmd interface{}, closeChan <-chan struct{})
HashesPerSec: int64(s.cfg.CPUMiner.HashesPerSecond()),
NetworkHashPS: networkHashesPerSec,
PooledTx: uint64(s.cfg.TxMemPool.Count()),
- TestNet: config.MainConfig().TestNet3,
+ TestNet: config.MainConfig().TestNet,
DevNet: config.MainConfig().DevNet,
}
return &result, nil
diff --git a/txscript/sign_test.go b/txscript/sign_test.go
index ca340c6a2..b3c03480d 100644
--- a/txscript/sign_test.go
+++ b/txscript/sign_test.go
@@ -76,7 +76,7 @@ func signAndCheck(msg string, tx *wire.MsgTx, idx int, scriptPubKey []byte,
hashType SigHashType, kdb KeyDB, sdb ScriptDB,
previousScript []byte) error {
- sigScript, err := SignTxOutput(&dagconfig.TestNet3Params, tx, idx,
+ sigScript, err := SignTxOutput(&dagconfig.TestNetParams, tx, idx,
scriptPubKey, hashType, kdb, sdb, nil)
if err != nil {
return fmt.Errorf("failed to sign output %s: %v", msg, err)
@@ -199,7 +199,7 @@ func TestSignTxOutput(t *testing.T) {
"for %s: %v", msg, err)
}
- sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false},
@@ -212,7 +212,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign
// again and merge.
- sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false},
@@ -298,7 +298,7 @@ func TestSignTxOutput(t *testing.T) {
"for %s: %v", msg, err)
}
- sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true},
@@ -311,7 +311,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign
// again and merge.
- sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true},
@@ -432,7 +432,7 @@ func TestSignTxOutput(t *testing.T) {
break
}
- sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptScriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false},
@@ -447,7 +447,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign
// again and merge.
- sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptScriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, false},
@@ -569,7 +569,7 @@ func TestSignTxOutput(t *testing.T) {
break
}
- sigScript, err := SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err := SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptScriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true},
@@ -584,7 +584,7 @@ func TestSignTxOutput(t *testing.T) {
// by the above loop, this should be valid, now sign
// again and merge.
- sigScript, err = SignTxOutput(&dagconfig.TestNet3Params,
+ sigScript, err = SignTxOutput(&dagconfig.TestNetParams,
tx, i, scriptScriptPubKey, hashType,
mkGetKey(map[string]addressToKey{
address.EncodeAddress(): {key, true},
diff --git a/util/wif.go b/util/wif.go
index c07fc17ec..98366a3e2 100644
--- a/util/wif.go
+++ b/util/wif.go
@@ -64,7 +64,7 @@ func (w *WIF) IsForNet(privateKeyID byte) bool {
// sequence:
//
// * 1 byte to identify the network, must be 0x80 for mainnet or 0xef for
-// either testnet3 or the regression test network
+// either testnet or the regression test network
// * 32 bytes of a binary-encoded, big-endian, zero-padded private key
// * Optional 1 byte (equal to 0x01) if the address being imported or exported
// was created by taking the RIPEMD160 after SHA256 hash of a serialized
diff --git a/util/wif_test.go b/util/wif_test.go
index 98f99ac1c..9b41c782c 100644
--- a/util/wif_test.go
+++ b/util/wif_test.go
@@ -29,7 +29,7 @@ func TestEncodeDecodeWIF(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- wif2, err := NewWIF(priv2, dagconfig.TestNet3Params.PrivateKeyID, true)
+ wif2, err := NewWIF(priv2, dagconfig.TestNetParams.PrivateKeyID, true)
if err != nil {
t.Fatal(err)
}
diff --git a/wire/bench_test.go b/wire/bench_test.go
index 36df660b7..b232d919b 100644
--- a/wire/bench_test.go
+++ b/wire/bench_test.go
@@ -18,7 +18,7 @@ import (
)
// genesisCoinbaseTx is the coinbase transaction for the genesis blocks for
-// the main network, regression test network, and test network (version 3).
+// the main network, regression test network, and test network.
var genesisCoinbaseTxIns = []*TxIn{
{
PreviousOutpoint: Outpoint{
diff --git a/wire/doc.go b/wire/doc.go
index 989e7328e..2299a6d9e 100644
--- a/wire/doc.go
+++ b/wire/doc.go
@@ -84,8 +84,8 @@ message and which bitcoin network the message applies to. This package provides
the following constants:
wire.MainNet
- wire.TestNet (Regression test network)
- wire.TestNet3 (Test network version 3)
+ wire.RegTest (Regression test network)
+ wire.TestNet (Test network)
wire.SimNet (Simulation test network)
Determining Message Type
diff --git a/wire/message_test.go b/wire/message_test.go
index 1a972e62b..4107cde94 100644
--- a/wire/message_test.go
+++ b/wire/message_test.go
@@ -208,8 +208,8 @@ func TestReadMessageWireErrors(t *testing.T) {
testErr.Error(), wantErr)
}
- // Wire encoded bytes for main and testnet3 networks magic identifiers.
- testNet3Bytes := makeHeader(TestNet3, "", 0, 0)
+ // Wire encoded bytes for main and testnet networks magic identifiers.
+ testNetBytes := makeHeader(TestNet, "", 0, 0)
// Wire encoded bytes for a message that exceeds max overall message
// length.
@@ -267,12 +267,12 @@ func TestReadMessageWireErrors(t *testing.T) {
0,
},
- // Wrong network. Want MainNet, but giving TestNet3.
+ // Wrong network. Want MainNet, but giving TestNet.
{
- testNet3Bytes,
+ testNetBytes,
pver,
btcnet,
- len(testNet3Bytes),
+ len(testNetBytes),
&MessageError{},
24,
},
diff --git a/wire/protocol.go b/wire/protocol.go
index 5e7c53e6f..1fd5bafd3 100644
--- a/wire/protocol.go
+++ b/wire/protocol.go
@@ -100,11 +100,11 @@ const (
// MainNet represents the main bitcoin network.
MainNet BitcoinNet = 0xd9b4bef9
- // TestNet represents the regression test network.
- TestNet BitcoinNet = 0xdab5bffa
+ // TestNet represents the test network.
+ TestNet BitcoinNet = 0x0709110b
- // TestNet3 represents the test network (version 3).
- TestNet3 BitcoinNet = 0x0709110b
+ // RegTest represents the regression test network.
+ RegTest BitcoinNet = 0xdab5bffa
// SimNet represents the simulation test network.
SimNet BitcoinNet = 0x12141c16
@@ -116,11 +116,11 @@ const (
// bnStrings is a map of bitcoin networks back to their constant names for
// pretty printing.
var bnStrings = map[BitcoinNet]string{
- MainNet: "MainNet",
- TestNet: "TestNet",
- TestNet3: "TestNet3",
- SimNet: "SimNet",
- DevNet: "DevNet",
+ MainNet: "MainNet",
+ TestNet: "TestNet",
+ RegTest: "RegTest",
+ SimNet: "SimNet",
+ DevNet: "DevNet",
}
// String returns the BitcoinNet in human-readable form.
diff --git a/wire/protocol_test.go b/wire/protocol_test.go
index 79663ed1f..9b4079fc5 100644
--- a/wire/protocol_test.go
+++ b/wire/protocol_test.go
@@ -40,8 +40,8 @@ func TestBitcoinNetStringer(t *testing.T) {
want string
}{
{MainNet, "MainNet"},
+ {RegTest, "RegTest"},
{TestNet, "TestNet"},
- {TestNet3, "TestNet3"},
{SimNet, "SimNet"},
{0xffffffff, "Unknown BitcoinNet (4294967295)"},
}