diff --git a/blockchain/chain.go b/blockchain/chain.go index 7077e3e993..287b724536 100644 --- a/blockchain/chain.go +++ b/blockchain/chain.go @@ -2195,7 +2195,7 @@ func (b *BlockChain) BestSnapshot() *BestState { func (b *BlockChain) maxBlockSize(prevNode *blockNode) (int64, error) { // Hard fork voting on block size is only enabled on testnet v1 and // simnet. - if b.chainParams.Net != wire.TestNet && b.chainParams.Net != wire.SimNet { + if b.chainParams.Net != wire.SimNet { return int64(b.chainParams.MaximumBlockSizes[0]), nil } diff --git a/blockchain/stake/staketx_test.go b/blockchain/stake/staketx_test.go index 1ae64fd8db..2b42af016d 100644 --- a/blockchain/stake/staketx_test.go +++ b/blockchain/stake/staketx_test.go @@ -1359,7 +1359,7 @@ func TestVerifyRealTxs(t *testing.T) { ssrtxTx := dcrutil.NewTx(ssrtxMtx) ssrtxTypes, ssrtxAddrs, ssrtxAmts, err := - stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNetParams) + stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNet2Params) if err != nil { t.Errorf("Unexpected GetSSRtxStakeOutputInfo error: %v", err.Error()) } @@ -1394,7 +1394,7 @@ func TestVerifyRealTxs(t *testing.T) { sstxTypes, sstxAddrs, sstxAmts, _, sstxRules, sstxLimits = stake.TxSStxStakeOutputInfo(sstxTx.MsgTx()) ssrtxTypes, ssrtxAddrs, ssrtxAmts, err = - stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNetParams) + stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNet2Params) if err != nil { t.Errorf("Unexpected GetSSRtxStakeOutputInfo error: %v", err.Error()) } @@ -1420,7 +1420,7 @@ func TestVerifyRealTxs(t *testing.T) { sstxTypes, sstxAddrs, sstxAmts, _, sstxRules, sstxLimits = stake.TxSStxStakeOutputInfo(sstxTx.MsgTx()) ssrtxTypes, ssrtxAddrs, ssrtxAmts, err = - stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNetParams) + stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNet2Params) if err != nil { t.Errorf("Unexpected GetSSRtxStakeOutputInfo error: %v", err.Error()) } @@ -1451,7 +1451,7 @@ func TestVerifyRealTxs(t *testing.T) { sstxTypes, sstxAddrs, sstxAmts, _, sstxRules, sstxLimits = stake.TxSStxStakeOutputInfo(sstxTx.MsgTx()) ssrtxTypes, ssrtxAddrs, ssrtxAmts, err = - stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNetParams) + stake.TxSSRtxStakeOutputInfo(ssrtxTx.MsgTx(), &chaincfg.TestNet2Params) if err != nil { t.Errorf("Unexpected GetSSRtxStakeOutputInfo error: %v", err.Error()) } diff --git a/blockchain/stakeversion_test.go b/blockchain/stakeversion_test.go index 1b04916b77..6287e483f2 100644 --- a/blockchain/stakeversion_test.go +++ b/blockchain/stakeversion_test.go @@ -72,9 +72,9 @@ func TestCalcWantHeight(t *testing.T) { multiplier: 5000, }, { - name: "testnet params", - skip: chaincfg.TestNetParams.StakeValidationHeight, - interval: chaincfg.TestNetParams.StakeVersionInterval, + name: "testnet2 params", + skip: chaincfg.TestNet2Params.StakeValidationHeight, + interval: chaincfg.TestNet2Params.StakeVersionInterval, multiplier: 1000, }, { diff --git a/chaincfg/genesis.go b/chaincfg/genesis.go index dbaa3b2be5..5a3274a14f 100644 --- a/chaincfg/genesis.go +++ b/chaincfg/genesis.go @@ -88,8 +88,6 @@ var genesisBlock = wire.MsgBlock{ // network (genesis block). var genesisHash = genesisBlock.BlockHash() -// TestNet ------------------------------------------------------------------------ - // genesisCoinbaseTxLegacy is the coinbase transaction for the genesis block for // the test network. var genesisCoinbaseTxLegacy = wire.MsgTx{ @@ -135,30 +133,6 @@ var genesisCoinbaseTxLegacy = wire.MsgTx{ Expiry: 0, } -// testNetGenesisMerkleRoot is the hash of the first transaction in the genesis block -// for the test network. -var testNetGenesisMerkleRoot = genesisCoinbaseTxLegacy.TxHash() - -// testNetGenesisBlock defines the genesis block of the block chain which -// serves as the public transaction ledger for the test network (version 3). -var testNetGenesisBlock = wire.MsgBlock{ - Header: wire.BlockHeader{ - Version: 1, - PrevBlock: chainhash.Hash{}, - MerkleRoot: testNetGenesisMerkleRoot, - Timestamp: time.Unix(1453908222, 0), // 2016-01-27 TestNet9 - Bits: 0x1e00ffff, - SBits: 20000000, - Nonce: 0x18aea41a, - StakeVersion: 0, - }, - Transactions: []*wire.MsgTx{&genesisCoinbaseTxLegacy}, -} - -// testNetGenesisHash is the hash of the first block in the block chain for the -// test network. -var testNetGenesisHash = testNetGenesisBlock.BlockHash() - // TestNet2 ------------------------------------------------------------------------ // testNetGenesisMerkleRoot is the hash of the first transaction in the genesis block @@ -171,7 +145,7 @@ var testNet2GenesisBlock = wire.MsgBlock{ Header: wire.BlockHeader{ Version: 4, PrevBlock: chainhash.Hash{}, - MerkleRoot: testNetGenesisMerkleRoot, + MerkleRoot: testNet2GenesisMerkleRoot, Timestamp: time.Unix(1489550400, 0), // 2017-03-15 TestNet10 Bits: 0x1e00ffff, SBits: 20000000, diff --git a/chaincfg/genesis_test.go b/chaincfg/genesis_test.go index 21a58c96ed..9192b4804d 100644 --- a/chaincfg/genesis_test.go +++ b/chaincfg/genesis_test.go @@ -56,17 +56,17 @@ func TestGenesisBlock(t *testing.T) { func TestTestNetGenesisBlock(t *testing.T) { // Encode the genesis block to raw bytes. var buf bytes.Buffer - err := TestNetParams.GenesisBlock.Serialize(&buf) + err := TestNet2Params.GenesisBlock.Serialize(&buf) if err != nil { t.Fatalf("TestTestNetGenesisBlock: %v", err) } - testNetGenesisBlockBytes, _ := hex.DecodeString("0100000000000000000" + + testNetGenesisBlockBytes, _ := hex.DecodeString("0400000000000000000" + "000000000000000000000000000000000000000000000000000000571a3f8bb" + "1903091a18edd3efbc324c79876764af2424071a480d3f04ea16a2000000000" + "000000000000000000000000000000000000000000000000000000000000000" + "000000000000000000000000ffff001e002d310100000000000000000000000" + - "0fee0a8561aa4ae180000000000000000000000000000000000000000000000" + + "040bcc8581aa4ae180000000000000000000000000000000000000000000000" + "000000000000000000000000000101000000010000000000000000000000000" + "000000000000000000000000000000000000000ffffffff00ffffffff010000" + "0000000000000000434104678afdb0fe5548271967f1a67130b7105cd6a828e" + @@ -85,11 +85,11 @@ func TestTestNetGenesisBlock(t *testing.T) { } // Check hash of the block against expected hash. - hash := TestNetParams.GenesisBlock.BlockHash() - if !TestNetParams.GenesisHash.IsEqual(&hash) { + hash := TestNet2Params.GenesisBlock.BlockHash() + if !TestNet2Params.GenesisHash.IsEqual(&hash) { t.Fatalf("TestTestNetGenesisBlock: Genesis block hash does "+ "not appear valid - got %v, want %v", spew.Sdump(hash), - spew.Sdump(TestNetParams.GenesisHash)) + spew.Sdump(TestNet2Params.GenesisHash)) } } diff --git a/chaincfg/init.go b/chaincfg/init.go index a6c91dfa2e..4f23db3603 100644 --- a/chaincfg/init.go +++ b/chaincfg/init.go @@ -151,7 +151,7 @@ func validateAgendas() { case 0: params = MainNetParams case 1: - params = TestNetParams + params = TestNet2Params case 2: params = SimNetParams default: diff --git a/chaincfg/params.go b/chaincfg/params.go index 902ff82b55..c1689f0198 100644 --- a/chaincfg/params.go +++ b/chaincfg/params.go @@ -559,156 +559,6 @@ var MainNetParams = Params{ BlockOneLedger: BlockOneLedgerMainNet, } -// TestNetParams defines the network parameters for the test currency network. -// This network is sometimes simply called "testnet". -var TestNetParams = Params{ - Name: "testnet", - Net: wire.TestNet, - DefaultPort: "19108", - DNSSeeds: []string{ - "testnet-seed.decred.mindcry.org", - "testnet-seed.decred.netpurgatory.org", - "testnet.decredseed.org", - "testnet-seed.decred.org", - }, - - // Chain parameters - GenesisBlock: &testNetGenesisBlock, - GenesisHash: &testNetGenesisHash, - PowLimit: testNetPowLimit, - PowLimitBits: 0x1e00ffff, - ReduceMinDifficulty: false, - MinDiffReductionTime: 0, // Does not apply since ReduceMinDifficulty false - GenerateSupported: true, - MaximumBlockSizes: []int{1000000, 1310720}, - MaxTxSize: 1000000, - TargetTimePerBlock: time.Minute * 2, - WorkDiffAlpha: 1, - WorkDiffWindowSize: 144, - WorkDiffWindows: 20, - TargetTimespan: time.Minute * 2 * 144, // TimePerBlock * WindowSize - RetargetAdjustmentFactor: 4, - - // Subsidy parameters. - BaseSubsidy: 2500000000, // 25 Coin - MulSubsidy: 100, - DivSubsidy: 101, - SubsidyReductionInterval: 2048, - WorkRewardProportion: 6, - StakeRewardProportion: 3, - BlockTaxProportion: 1, - - // Checkpoints ordered from oldest to newest. - Checkpoints: []Checkpoint{ - {2900, newHashFromStr("000000000012475b579cd16d670f42982648e5dbf81d84960c83fd1990d84cbe")}, - {27550, newHashFromStr("00000000183a9f9b8fa6accc32c7abb2456a8e0e12baf045788a74114dbbebe3")}, - {61540, newHashFromStr("0000000003bc7461b7cd821fb258de72b9b0c7604b1a5346d29eb132d846ccb0")}, - {97110, newHashFromStr("0000000006ae0065cf97102844854966d907d6e50ab18894679fbad1dfc017b4")}, - {132220, newHashFromStr("000000000372a1bf5ad5c42361672bfeae6a513ad25ab9eaf4590f890e090c36")}, - {146740, newHashFromStr("00000000003300fa29af1b0066c688513f4f188f95edcff55dcdeb4e8f2c3b5e")}, - {162230, newHashFromStr("0000000006741ab11e44af3cebc1c52905f873b4e059a1013da63bc076a3edbb")}, - {173750, newHashFromStr("0000000000fe0a2f55589d8b75502f8adc26be95971a16d12d7ea65da5a0a507")}, - {197920, newHashFromStr("000000000174a97eed678549df66b4025a8ff4b5034e7b0fdc63d1112d4716ab")}, - {223050, newHashFromStr("00000000065827e0fd67067f2268f14890a1b7e863b1fa7dee627a3d4b7d33b5")}, - {257350, newHashFromStr("000000000265019c4f9412977efcaf4811462992e6d424e251e7a91424c454ba")}, - }, - - // Consensus rule change deployments. - // - // The miner confirmation window is defined as: - // target proof of work timespan / target proof of work spacing - RuleChangeActivationQuorum: 2520, // 10 % of RuleChangeActivationInterval * TicketsPerBlock - RuleChangeActivationMultiplier: 3, // 75% - RuleChangeActivationDivisor: 4, - RuleChangeActivationInterval: 5040, // 1 week - Deployments: map[uint32][]ConsensusDeployment{ - 4: {{ - Vote: Vote{ - Id: VoteIDMaxBlockSize, - Description: "Change maximum allowed block size from 1MB to 1.25MiB", - Mask: 0x0006, // Bits 1 and 2 - Choices: []Choice{{ - Id: "abstain", - Description: "abstain voting for change", - Bits: 0x0000, - IsIgnore: true, - IsNo: false, - }, { - Id: "no", - Description: "reject changing max allowed block size", - Bits: 0x0002, // Bit 1 - IsIgnore: false, - IsNo: true, - }, { - Id: "yes", - Description: "accept changing max allowed block size", - Bits: 0x0004, // Bit 2 - IsIgnore: false, - IsNo: false, - }}, - }, - StartTime: 1486598400, // Feb 9th, 2017 - ExpireTime: 1496966400, // Jun 9th, 2017 - }}, - }, - - // Enforce current block version once majority of the network has - // upgraded. - // 51% (51 / 100) - // Reject previous block versions once a majority of the network has - // upgraded. - // 75% (75 / 100) - BlockEnforceNumRequired: 51, - BlockRejectNumRequired: 75, - BlockUpgradeNumToCheck: 100, - - // Mempool parameters - RelayNonStdTxs: true, - - // Address encoding magics - NetworkAddressPrefix: "T", - PubKeyAddrID: [2]byte{0x28, 0xf7}, // starts with Tk - PubKeyHashAddrID: [2]byte{0x0f, 0x21}, // starts with Ts - PKHEdwardsAddrID: [2]byte{0x0f, 0x01}, // starts with Te - PKHSchnorrAddrID: [2]byte{0x0e, 0xe3}, // starts with TS - ScriptHashAddrID: [2]byte{0x0e, 0xfc}, // starts with Tc - PrivateKeyID: [2]byte{0x23, 0x0e}, // starts with Pt - - // BIP32 hierarchical deterministic extended key magics - HDPrivateKeyID: [4]byte{0x04, 0x35, 0x83, 0x97}, // starts with tprv - HDPublicKeyID: [4]byte{0x04, 0x35, 0x87, 0xd1}, // starts with tpub - - // BIP44 coin type used in the hierarchical deterministic path for - // address generation. - HDCoinType: 11, - - // Decred PoS parameters - MinimumStakeDiff: 20000000, // 0.2 Coin - TicketPoolSize: 1024, - TicketsPerBlock: 5, - TicketMaturity: 16, - TicketExpiry: 6144, // 6*TicketPoolSize - CoinbaseMaturity: 16, - SStxChangeMaturity: 1, - TicketPoolSizeWeight: 4, - StakeDiffAlpha: 1, - StakeDiffWindowSize: 144, - StakeDiffWindows: 20, - StakeVersionInterval: 144 * 2 * 7, // ~1 week - MaxFreshStakePerBlock: 20, // 4*TicketsPerBlock - StakeEnabledHeight: 16 + 16, // CoinbaseMaturity + TicketMaturity - StakeValidationHeight: 768, // Arbitrary - StakeBaseSigScript: []byte{0xDE, 0xAD, 0xBE, 0xEF}, - StakeMajorityMultiplier: 3, - StakeMajorityDivisor: 4, - - // Decred organization related parameters. - // Organization address is TcemyEtyHSg9L7jww7uihv9BJfKL6YGiZYn - OrganizationPkScript: hexDecode("a9144fa6cbd0dbe5ec407fe4c8ad374e667771fa0d4487"), - OrganizationPkScriptVersion: 0, - BlockOneLedger: BlockOneLedgerTestNet, -} - // TestNet2Params defines the network parameters for the test currency network. // This network is sometimes simply called "testnet". // This is the second public iteration of testnet. @@ -1156,7 +1006,6 @@ func (p *Params) LatestCheckpointHeight() int64 { func init() { // Register all default networks when the package is initialized. mustRegister(&MainNetParams) - mustRegister(&TestNetParams) mustRegister(&TestNet2Params) mustRegister(&SimNetParams) } diff --git a/chaincfg/register_test.go b/chaincfg/register_test.go index b07338b043..975baa8c44 100644 --- a/chaincfg/register_test.go +++ b/chaincfg/register_test.go @@ -57,7 +57,7 @@ func TestRegister(t *testing.T) { }, { name: "duplicate testnet", - params: &TestNetParams, + params: &TestNet2Params, err: ErrDuplicateNet, }, { @@ -72,7 +72,7 @@ func TestRegister(t *testing.T) { valid: true, }, { - magic: TestNetParams.PubKeyHashAddrID, + magic: TestNet2Params.PubKeyHashAddrID, valid: true, }, { @@ -94,7 +94,7 @@ func TestRegister(t *testing.T) { valid: true, }, { - magic: TestNetParams.ScriptHashAddrID, + magic: TestNet2Params.ScriptHashAddrID, valid: true, }, { @@ -117,8 +117,8 @@ func TestRegister(t *testing.T) { err: nil, }, { - priv: TestNetParams.HDPrivateKeyID[:], - want: TestNetParams.HDPublicKeyID[:], + priv: TestNet2Params.HDPrivateKeyID[:], + want: TestNet2Params.HDPublicKeyID[:], err: nil, }, { @@ -155,7 +155,7 @@ func TestRegister(t *testing.T) { valid: true, }, { - magic: TestNetParams.PubKeyHashAddrID, + magic: TestNet2Params.PubKeyHashAddrID, valid: true, }, { @@ -177,7 +177,7 @@ func TestRegister(t *testing.T) { valid: true, }, { - magic: TestNetParams.ScriptHashAddrID, + magic: TestNet2Params.ScriptHashAddrID, valid: true, }, { @@ -211,7 +211,7 @@ func TestRegister(t *testing.T) { }, { name: "duplicate testnet", - params: &TestNetParams, + params: &TestNet2Params, err: ErrDuplicateNet, }, { @@ -231,7 +231,7 @@ func TestRegister(t *testing.T) { valid: true, }, { - magic: TestNetParams.PubKeyHashAddrID, + magic: TestNet2Params.PubKeyHashAddrID, valid: true, }, { @@ -253,7 +253,7 @@ func TestRegister(t *testing.T) { valid: true, }, { - magic: TestNetParams.ScriptHashAddrID, + magic: TestNet2Params.ScriptHashAddrID, valid: true, }, { @@ -276,8 +276,8 @@ func TestRegister(t *testing.T) { err: nil, }, { - priv: TestNetParams.HDPrivateKeyID[:], - want: TestNetParams.HDPublicKeyID[:], + priv: TestNet2Params.HDPrivateKeyID[:], + want: TestNet2Params.HDPublicKeyID[:], err: nil, }, { diff --git a/cmd/addblock/config.go b/cmd/addblock/config.go index 98d86700f2..b461d164b8 100644 --- a/cmd/addblock/config.go +++ b/cmd/addblock/config.go @@ -68,18 +68,18 @@ func validDbType(dbType string) bool { } // netName returns the name used when referring to a bitcoin network. At the -// time of writing, dcrd currently places blocks for testnet version 3 in the -// data and log directory "testnet", which does not match the Name field of the +// time of writing, dcrd currently places blocks for testnet version 2 in the +// data and log directory "testnet2", which does not match the Name field of the // chaincfg parameters. This function can be used to override this directory name -// as "testnet" when the passed active network matches wire.TestNet. +// as "testnet2" when the passed active network matches wire.TestNet2. // // A proper upgrade to move the data and log directories for this network to -// "testnet" is planned for the future, at which point this function can be +// "testnet2" is planned for the future, at which point this function can be // removed and the network parameter's name used instead. func netName(chainParams *chaincfg.Params) string { switch chainParams.Net { - case wire.TestNet: - return "testnet" + case wire.TestNet2: + return "testnet2" default: return chainParams.Name } @@ -112,7 +112,7 @@ func loadConfig() (*config, []string, error) { // while we're at it if cfg.TestNet { numNets++ - activeNetParams = &chaincfg.TestNetParams + activeNetParams = &chaincfg.TestNet2Params } if cfg.SimNet { numNets++ diff --git a/cmd/findcheckpoint/config.go b/cmd/findcheckpoint/config.go index 98577ea601..05564387cf 100644 --- a/cmd/findcheckpoint/config.go +++ b/cmd/findcheckpoint/config.go @@ -56,18 +56,18 @@ func validDbType(dbType string) bool { } // netName returns the name used when referring to a decred network. At the -// time of writing, dcrd currently places blocks for testnet version 0 in the -// data and log directory "testnet", which does not match the Name field of the +// time of writing, dcrd currently places blocks for testnet version 2 in the +// data and log directory "testnet2", which does not match the Name field of the // chaincfg parameters. This function can be used to override this directory name -// as "testnet" when the passed active network matches wire.TestNet. +// as "testnet2" when the passed active network matches wire.TestNet2. // // A proper upgrade to move the data and log directories for this network to -// "testnet" is planned for the future, at which point this function can be +// "testnet2" is planned for the future, at which point this function can be // removed and the network parameter's name used instead. func netName(chainParams *chaincfg.Params) string { switch chainParams.Net { - case wire.TestNet: - return "testnet" + case wire.TestNet2: + return "testnet2" default: return chainParams.Name } @@ -99,7 +99,7 @@ func loadConfig() (*config, []string, error) { // while we're at it if cfg.TestNet { numNets++ - activeNetParams = &chaincfg.TestNetParams + activeNetParams = &chaincfg.TestNet2Params } if cfg.SimNet { numNets++ diff --git a/database/cmd/dbtool/globalconfig.go b/database/cmd/dbtool/globalconfig.go index a112f5ffef..a65b661b13 100644 --- a/database/cmd/dbtool/globalconfig.go +++ b/database/cmd/dbtool/globalconfig.go @@ -68,7 +68,7 @@ func setupGlobalConfig() error { numNets := 0 if cfg.TestNet { numNets++ - activeNetParams = &chaincfg.TestNetParams + activeNetParams = &chaincfg.TestNet2Params } if cfg.SimNet { numNets++ diff --git a/glide.lock b/glide.lock index 4d168512d0..b5581a767b 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: 807209320ff3d80af89663d3407f7d3fef4cfa67e52750c4ffa58bae790f8a16 -updated: 2017-03-08T11:08:04.404189759-05:00 +updated: 2017-03-16T14:14:43.875458414-04:00 imports: - name: github.com/btcsuite/btclog version: 73889fb79bd687870312b6e40effcecffbd57d30 @@ -47,9 +47,9 @@ imports: - name: github.com/decred/blake256 version: a840e32d7c31fe2e0218607334cb120a683951a4 - name: github.com/decred/dcrrpcclient - version: 0a9e95ce9a20a0fbf535fdc2c79169b30d613378 + version: 0476421c0f19f8540fb0f584000b04f82b906610 - name: github.com/decred/dcrutil - version: 2646ed56075e905782d7342ccaefbb8243ffcdc4 + version: ee6d002bf0de123fe47a8d2b8489f75145ce746e subpackages: - base58 - bloom diff --git a/mempool/policy_test.go b/mempool/policy_test.go index 81210b47bf..20e2487a97 100644 --- a/mempool/policy_test.go +++ b/mempool/policy_test.go @@ -292,7 +292,7 @@ func TestCheckTransactionStandard(t *testing.T) { } addrHash := [20]byte{0x01} addr, err := dcrutil.NewAddressPubKeyHash(addrHash[:], - &chaincfg.TestNetParams, chainec.ECTypeSecp256k1) + &chaincfg.TestNet2Params, chainec.ECTypeSecp256k1) if err != nil { t.Fatalf("NewAddressPubKeyHash: unexpected error: %v", err) } diff --git a/params.go b/params.go index 5e9e9c44be..3ae16a1aa6 100644 --- a/params.go +++ b/params.go @@ -32,14 +32,7 @@ var mainNetParams = params{ rpcPort: "9109", } -// testNetParams contains parameters specific to the test network (version 0) -// (wire.TestNet). -var testNetParams = params{ - Params: &chaincfg.TestNetParams, - rpcPort: "19109", -} - -// testNetParams contains parameters specific to the test network (version 2) +// testNet2Params contains parameters specific to the test network (version 2) // (wire.TestNet2). var testNet2Params = params{ Params: &chaincfg.TestNet2Params, @@ -57,15 +50,15 @@ var simNetParams = params{ // time of writing, dcrd currently places blocks for testnet version 0 in the // data and log directory "testnet", which does not match the Name field of the // chaincfg parameters. This function can be used to override this directory name -// as "testnet" when the passed active network matches wire.TestNet. +// as "testnet2" when the passed active network matches wire.TestNet2. // // A proper upgrade to move the data and log directories for this network to // "testnet" is planned for the future, at which point this function can be // removed and the network parameter's name used instead. func netName(chainParams *params) string { switch chainParams.Net { - case wire.TestNet: - return "testnet" + case wire.TestNet2: + return "testnet2" default: return chainParams.Name } diff --git a/peer/peer.go b/peer/peer.go index 65de915b0e..04300e92dc 100644 --- a/peer/peer.go +++ b/peer/peer.go @@ -2029,7 +2029,7 @@ func newPeerBase(cfg *Config, inbound bool) *Peer { // Set the chain parameters to testnet if the caller did not specify any. if cfg.ChainParams == nil { - cfg.ChainParams = &chaincfg.TestNetParams + cfg.ChainParams = &chaincfg.TestNet2Params } p := Peer{ diff --git a/peer/peer_test.go b/peer/peer_test.go index 5886e7e1e6..47ccb458de 100644 --- a/peer/peer_test.go +++ b/peer/peer_test.go @@ -625,7 +625,7 @@ func TestOutboundPeer(t *testing.T) { p1.Disconnect() // Test testnet - peerCfg.ChainParams = &chaincfg.TestNetParams + peerCfg.ChainParams = &chaincfg.TestNet2Params peerCfg.Services = wire.SFNodeBloom r2, w2 := io.Pipe() c2 := &conn{raddr: "10.0.0.1:8333", Writer: w2, Reader: r2} diff --git a/txscript/sign_test.go b/txscript/sign_test.go index f121c6575a..7c12d7f2b8 100644 --- a/txscript/sign_test.go +++ b/txscript/sign_test.go @@ -100,7 +100,7 @@ func signAndCheck(msg string, tx *wire.MsgTx, idx int, pkScript []byte, hashType txscript.SigHashType, kdb txscript.KeyDB, sdb txscript.ScriptDB, previousScript []byte, suite int) error { - sigScript, err := txscript.SignTxOutput(&chaincfg.TestNetParams, tx, + sigScript, err := txscript.SignTxOutput(&chaincfg.TestNet2Params, tx, idx, pkScript, hashType, kdb, sdb, nil, suite) if err != nil { return fmt.Errorf("failed to sign output %s: %v", msg, err) @@ -122,7 +122,7 @@ func signBadAndCheck(msg string, tx *wire.MsgTx, idx int, pkScript []byte, tx.TxIn[0].ValueIn = 1 } - sigScript, err := txscript.SignTxOutput(&chaincfg.TestNetParams, tx, + sigScript, err := txscript.SignTxOutput(&chaincfg.TestNet2Params, tx, idx, pkScript, hashType, kdb, sdb, nil, suite) if err != nil { return fmt.Errorf("failed to sign output %s: %v", msg, err) @@ -247,7 +247,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { @@ -308,7 +308,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -323,7 +323,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, false}, }), mkGetScript(nil), nil, suite) @@ -336,7 +336,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, false}, }), mkGetScript(nil), sigScript, suite) @@ -382,7 +382,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -442,7 +442,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -457,7 +457,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(nil), nil, suite) @@ -470,7 +470,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(nil), sigScript, suite) @@ -500,7 +500,7 @@ func TestSignTxOutput(t *testing.T) { pkBytes := pk.SerializeCompressed() address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, secp) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -543,7 +543,7 @@ func TestSignTxOutput(t *testing.T) { pkBytes := pk.SerializeCompressed() address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, secp) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -586,7 +586,7 @@ func TestSignTxOutput(t *testing.T) { pkBytes := pk.SerializeCompressed() address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, secp) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -629,7 +629,7 @@ func TestSignTxOutput(t *testing.T) { pkBytes := pk.SerializeCompressed() address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, secp) if err != nil { t.Errorf("failed to make address for %s: %v", @@ -673,7 +673,7 @@ func TestSignTxOutput(t *testing.T) { pkBytes := pk.SerializeUncompressed() address, err := dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -724,7 +724,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = secp256k1.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeUncompressed() address, err = dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -736,7 +736,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.Edwards.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeUncompressed() address, err = dcrutil.NewAddressEdwardsPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -748,7 +748,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.SecSchnorr.PrivKeyFromBytes(keyDB) pkBytes = pk.Serialize() address, err = dcrutil.NewAddressSecSchnorrPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -764,7 +764,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKeyPub(map[string]addressToKey{ address.String(): {&key, false}, }), mkGetScript(nil), nil, suite) @@ -777,7 +777,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKeyPub(map[string]addressToKey{ address.String(): {&key, false}, }), mkGetScript(nil), sigScript, suite) @@ -815,7 +815,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = secp256k1.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -827,7 +827,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.Edwards.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressEdwardsPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -839,7 +839,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.SecSchnorr.PrivKeyFromBytes(keyDB) pkBytes = pk.Serialize() address, err = dcrutil.NewAddressSecSchnorrPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -891,7 +891,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = secp256k1.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -903,7 +903,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.Edwards.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressEdwardsPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -915,7 +915,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.SecSchnorr.PrivKeyFromBytes(keyDB) pkBytes = pk.Serialize() address, err = dcrutil.NewAddressSecSchnorrPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -930,7 +930,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(nil), nil, suite) @@ -943,7 +943,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, pkScript, + &chaincfg.TestNet2Params, tx, i, pkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(nil), sigScript, suite) @@ -990,7 +990,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, suite) + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1005,7 +1005,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1069,7 +1069,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, suite) + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1084,7 +1084,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1100,7 +1100,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, false}, }), mkGetScript(map[string][]byte{ @@ -1115,7 +1115,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, false}, }), mkGetScript(map[string][]byte{ @@ -1163,7 +1163,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, suite) + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1177,7 +1177,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1241,7 +1241,7 @@ func TestSignTxOutput(t *testing.T) { msg := fmt.Sprintf("%d:%d:%d", hashType, i, suite) address, err := dcrutil.NewAddressPubKeyHash( - dcrutil.Hash160(pkBytes), &chaincfg.TestNetParams, suite) + dcrutil.Hash160(pkBytes), &chaincfg.TestNet2Params, suite) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1255,7 +1255,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1271,7 +1271,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(map[string][]byte{ @@ -1286,7 +1286,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(map[string][]byte{ @@ -1326,7 +1326,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = secp256k1.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeUncompressed() address, err = dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1338,7 +1338,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.Edwards.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeUncompressed() address, err = dcrutil.NewAddressEdwardsPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1350,7 +1350,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.SecSchnorr.PrivKeyFromBytes(keyDB) pkBytes = pk.Serialize() address, err = dcrutil.NewAddressSecSchnorrPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1365,7 +1365,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1421,7 +1421,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = secp256k1.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeUncompressed() address, err = dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1433,7 +1433,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.Edwards.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeUncompressed() address, err = dcrutil.NewAddressEdwardsPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1445,7 +1445,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.SecSchnorr.PrivKeyFromBytes(keyDB) pkBytes = pk.Serialize() address, err = dcrutil.NewAddressSecSchnorrPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1460,7 +1460,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1476,7 +1476,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, false}, }), mkGetScript(map[string][]byte{ @@ -1491,7 +1491,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, false}, }), mkGetScript(map[string][]byte{ @@ -1531,7 +1531,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = secp256k1.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1543,7 +1543,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.Edwards.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressEdwardsPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1555,7 +1555,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.SecSchnorr.PrivKeyFromBytes(keyDB) pkBytes = pk.Serialize() address, err = dcrutil.NewAddressSecSchnorrPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1570,7 +1570,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1626,7 +1626,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = secp256k1.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressSecpPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1638,7 +1638,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.Edwards.PrivKeyFromBytes(keyDB) pkBytes = pk.SerializeCompressed() address, err = dcrutil.NewAddressEdwardsPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1650,7 +1650,7 @@ func TestSignTxOutput(t *testing.T) { key, pk = chainec.SecSchnorr.PrivKeyFromBytes(keyDB) pkBytes = pk.Serialize() address, err = dcrutil.NewAddressSecSchnorrPubKey(pkBytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1665,7 +1665,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1681,7 +1681,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(map[string][]byte{ @@ -1696,7 +1696,7 @@ func TestSignTxOutput(t *testing.T) { // by the above loop, this should be valid, now sign // again and merge. sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address.EncodeAddress(): {&key, true}, }), mkGetScript(map[string][]byte{ @@ -1728,7 +1728,7 @@ func TestSignTxOutput(t *testing.T) { pk1Bytes := pk1.SerializeUncompressed() address1, err := dcrutil.NewAddressSecpPubKey(pk1Bytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1740,7 +1740,7 @@ func TestSignTxOutput(t *testing.T) { pk2Bytes := pk2.SerializeUncompressed() address2, err := dcrutil.NewAddressSecpPubKey(pk2Bytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address 2 for %s: %v", msg, err) @@ -1756,7 +1756,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1805,7 +1805,7 @@ func TestSignTxOutput(t *testing.T) { pk1Bytes := pk1.SerializeUncompressed() address1, err := dcrutil.NewAddressSecpPubKey(pk1Bytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1817,7 +1817,7 @@ func TestSignTxOutput(t *testing.T) { pk2Bytes := pk2.SerializeUncompressed() address2, err := dcrutil.NewAddressSecpPubKey(pk2Bytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address 2 for %s: %v", msg, err) @@ -1833,7 +1833,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1849,7 +1849,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address1.EncodeAddress(): {&key1, true}, }), mkGetScript(map[string][]byte{ @@ -1870,7 +1870,7 @@ func TestSignTxOutput(t *testing.T) { // Sign with the other key and merge sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address2.EncodeAddress(): {&key2, true}, }), mkGetScript(map[string][]byte{ @@ -1902,7 +1902,7 @@ func TestSignTxOutput(t *testing.T) { pk1Bytes := pk1.SerializeUncompressed() address1, err := dcrutil.NewAddressSecpPubKey(pk1Bytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address for %s: %v", msg, err) @@ -1914,7 +1914,7 @@ func TestSignTxOutput(t *testing.T) { pk2Bytes := pk2.SerializeUncompressed() address2, err := dcrutil.NewAddressSecpPubKey(pk2Bytes, - &chaincfg.TestNetParams) + &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make address 2 for %s: %v", msg, err) @@ -1930,7 +1930,7 @@ func TestSignTxOutput(t *testing.T) { } scriptAddr, err := dcrutil.NewAddressScriptHash( - pkScript, &chaincfg.TestNetParams) + pkScript, &chaincfg.TestNet2Params) if err != nil { t.Errorf("failed to make p2sh addr for %s: %v", msg, err) @@ -1946,7 +1946,7 @@ func TestSignTxOutput(t *testing.T) { } sigScript, err := txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address1.EncodeAddress(): {&key1, true}, }), mkGetScript(map[string][]byte{ @@ -1967,7 +1967,7 @@ func TestSignTxOutput(t *testing.T) { // Sign with the other key and merge sigScript, err = txscript.SignTxOutput( - &chaincfg.TestNetParams, tx, i, scriptPkScript, + &chaincfg.TestNet2Params, tx, i, scriptPkScript, hashType, mkGetKey(map[string]addressToKey{ address1.EncodeAddress(): {&key1, true}, address2.EncodeAddress(): {&key2, true}, @@ -2028,11 +2028,11 @@ var ( _, thisPubKey = chainec.Secp256k1.PrivKeyFromBytes(privKeyD) thisAddressUnc, _ = dcrutil.NewAddressPubKeyHash( dcrutil.Hash160(thisPubKey.SerializeUncompressed()), - &chaincfg.TestNetParams, secp) + &chaincfg.TestNet2Params, secp) uncompressedPkScript, _ = txscript.PayToAddrScript(thisAddressUnc) thisAddressCom, _ = dcrutil.NewAddressPubKeyHash( dcrutil.Hash160(thisPubKey.SerializeCompressed()), - &chaincfg.TestNetParams, secp) + &chaincfg.TestNet2Params, secp) compressedPkScript, _ = txscript.PayToAddrScript(thisAddressCom) shortPkScript = []byte{0x76, 0xa9, 0x14, 0xd1, 0x7c, 0xb5, 0xeb, 0xa4, 0x02, 0xcb, 0x68, 0xe0, 0x69, 0x56, 0xbf, 0x32, diff --git a/txscript/standard_test.go b/txscript/standard_test.go index 7da64e3dae..37ea790242 100644 --- a/txscript/standard_test.go +++ b/txscript/standard_test.go @@ -540,9 +540,9 @@ func (b *bogusAddress) DSA(chainParams *chaincfg.Params) int { return -1 } -// Net returns &chaincfg.TestNetParams. +// Net returns &chaincfg.TestNet2Params. func (b *bogusAddress) Net() *chaincfg.Params { - return &chaincfg.TestNetParams + return &chaincfg.TestNet2Params } // TestPayToAddrScript ensures the PayToAddrScript function generates the diff --git a/wire/message_test.go b/wire/message_test.go index 66da901a39..9876b37b76 100644 --- a/wire/message_test.go +++ b/wire/message_test.go @@ -213,7 +213,7 @@ func TestReadMessageWireErrors(t *testing.T) { } // Wire encoded bytes for main and testnet networks magic identifiers. - testNet3Bytes := makeHeader(TestNet, "", 0, 0) + testNet2Bytes := makeHeader(TestNet2, "", 0, 0) // Wire encoded bytes for a message that exceeds max overall message // length. @@ -271,12 +271,12 @@ func TestReadMessageWireErrors(t *testing.T) { 0, }, - // Wrong network. Want MainNet, but giving TestNet. [1] + // Wrong network. Want MainNet, but giving TestNet2. [1] { - testNet3Bytes, + testNet2Bytes, pver, dcrnet, - len(testNet3Bytes), + len(testNet2Bytes), &MessageError{}, 24, }, diff --git a/wire/protocol.go b/wire/protocol.go index f380ef11b2..cf182605e2 100644 --- a/wire/protocol.go +++ b/wire/protocol.go @@ -92,9 +92,6 @@ const ( // RegTest represents the regression test network. RegTest CurrencyNet = 0xdab500fa - // TestNet represents the test network. - TestNet CurrencyNet = 0x0709000b - // TestNet2 represents the 2nd test network. TestNet2 CurrencyNet = 0x48e7a065 @@ -106,7 +103,6 @@ const ( // pretty printing. var bnStrings = map[CurrencyNet]string{ MainNet: "MainNet", - TestNet: "TestNet", TestNet2: "TestNet2", RegTest: "RegNet", SimNet: "SimNet", diff --git a/wire/protocol_test.go b/wire/protocol_test.go index fb79849f21..b6e852d382 100644 --- a/wire/protocol_test.go +++ b/wire/protocol_test.go @@ -37,7 +37,7 @@ func TestCurrencyNetStringer(t *testing.T) { want string }{ {MainNet, "MainNet"}, - {TestNet, "TestNet"}, + {TestNet2, "TestNet2"}, {SimNet, "SimNet"}, {0xffffffff, "Unknown CurrencyNet (4294967295)"}, }