mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-07-31 20:11:23 +00:00
Remove TestNet2.
This commit is contained in:
@@ -162,12 +162,6 @@ public abstract class NetworkParameters {
|
||||
return TestNet3Params.get();
|
||||
}
|
||||
|
||||
/** Alias for TestNet2Params.get(), use that instead. */
|
||||
@Deprecated
|
||||
public static NetworkParameters testNet2() {
|
||||
return TestNet2Params.get();
|
||||
}
|
||||
|
||||
/** Alias for TestNet3Params.get(), use that instead. */
|
||||
@Deprecated
|
||||
public static NetworkParameters testNet3() {
|
||||
|
@@ -25,7 +25,7 @@ import java.util.Set;
|
||||
|
||||
/**
|
||||
* Utility class that holds all the registered NetworkParameters types used for address auto discovery.
|
||||
* By default only MainNetParams and TestNet3Params are used. If you want to use TestNet2, RegTestParams or
|
||||
* By default only MainNetParams and TestNet3Params are used. If you want to use RegTestParams or
|
||||
* UnitTestParams use the register and unregister the TestNet3Params as they don't have their own address
|
||||
* version/type code.
|
||||
*/
|
||||
|
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
* Copyright 2018 Andreas Schildbach
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,13 +26,31 @@ import static com.google.common.base.Preconditions.checkState;
|
||||
/**
|
||||
* Network parameters for the regression test mode of bitcoind in which all blocks are trivially solvable.
|
||||
*/
|
||||
public class RegTestParams extends TestNet2Params {
|
||||
public class RegTestParams extends AbstractBitcoinNetParams {
|
||||
private static final BigInteger MAX_TARGET = new BigInteger("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 16);
|
||||
|
||||
public RegTestParams() {
|
||||
super();
|
||||
packetMagic = 0xfabfb5daL;
|
||||
addressHeader = 111;
|
||||
p2shHeader = 196;
|
||||
targetTimespan = TARGET_TIMESPAN;
|
||||
dumpedPrivateKeyHeader = 239;
|
||||
segwitAddressHrp = "tb";
|
||||
genesisBlock.setTime(1296688602L);
|
||||
genesisBlock.setDifficultyTarget(0x1d07fff8L);
|
||||
genesisBlock.setNonce(384568319);
|
||||
spendableCoinbaseDepth = 100;
|
||||
String genesisHash = genesisBlock.getHashAsString();
|
||||
checkState(genesisHash.equals("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"));
|
||||
dnsSeeds = null;
|
||||
addrSeeds = null;
|
||||
bip32HeaderPub = 0x043587CF;
|
||||
bip32HeaderPriv = 0x04358394;
|
||||
|
||||
// Difficulty adjustments are disabled for regtest.
|
||||
// By setting the block interval for difficulty adjustments to Integer.MAX_VALUE we make sure difficulty never changes.
|
||||
// By setting the block interval for difficulty adjustments to Integer.MAX_VALUE we make sure difficulty never
|
||||
// changes.
|
||||
interval = Integer.MAX_VALUE;
|
||||
maxTarget = MAX_TARGET;
|
||||
subsidyDecreaseBlockCount = 150;
|
||||
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.bitcoinj.params;
|
||||
|
||||
import org.bitcoinj.core.Utils;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkState;
|
||||
|
||||
/**
|
||||
* Parameters for the old version 2 testnet. This is not useful to you - it exists only because some unit tests are
|
||||
* based on it.
|
||||
*/
|
||||
public class TestNet2Params extends AbstractBitcoinNetParams {
|
||||
public static final int TESTNET_MAJORITY_WINDOW = 100;
|
||||
public static final int TESTNET_MAJORITY_REJECT_BLOCK_OUTDATED = 75;
|
||||
public static final int TESTNET_MAJORITY_ENFORCE_BLOCK_UPGRADE = 51;
|
||||
|
||||
public TestNet2Params() {
|
||||
super();
|
||||
id = ID_TESTNET;
|
||||
packetMagic = 0xfabfb5daL;
|
||||
port = 18333;
|
||||
addressHeader = 111;
|
||||
p2shHeader = 196;
|
||||
interval = INTERVAL;
|
||||
targetTimespan = TARGET_TIMESPAN;
|
||||
maxTarget = Utils.decodeCompactBits(0x1d0fffffL);
|
||||
dumpedPrivateKeyHeader = 239;
|
||||
segwitAddressHrp = "tb";
|
||||
genesisBlock.setTime(1296688602L);
|
||||
genesisBlock.setDifficultyTarget(0x1d07fff8L);
|
||||
genesisBlock.setNonce(384568319);
|
||||
spendableCoinbaseDepth = 100;
|
||||
subsidyDecreaseBlockCount = 210000;
|
||||
String genesisHash = genesisBlock.getHashAsString();
|
||||
checkState(genesisHash.equals("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"));
|
||||
dnsSeeds = null;
|
||||
addrSeeds = null;
|
||||
bip32HeaderPub = 0x043587CF;
|
||||
bip32HeaderPriv = 0x04358394;
|
||||
|
||||
majorityEnforceBlockUpgrade = TESTNET_MAJORITY_ENFORCE_BLOCK_UPGRADE;
|
||||
majorityRejectBlockOutdated = TESTNET_MAJORITY_REJECT_BLOCK_OUTDATED;
|
||||
majorityWindow = TESTNET_MAJORITY_WINDOW;
|
||||
}
|
||||
|
||||
private static TestNet2Params instance;
|
||||
public static synchronized TestNet2Params get() {
|
||||
if (instance == null) {
|
||||
instance = new TestNet2Params();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPaymentProtocolId() {
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -35,10 +35,13 @@ import static com.google.common.base.Preconditions.checkState;
|
||||
* and testing of applications and new Bitcoin versions.
|
||||
*/
|
||||
public class TestNet3Params extends AbstractBitcoinNetParams {
|
||||
public static final int TESTNET_MAJORITY_WINDOW = 100;
|
||||
public static final int TESTNET_MAJORITY_REJECT_BLOCK_OUTDATED = 75;
|
||||
public static final int TESTNET_MAJORITY_ENFORCE_BLOCK_UPGRADE = 51;
|
||||
|
||||
public TestNet3Params() {
|
||||
super();
|
||||
id = ID_TESTNET;
|
||||
// Genesis hash is 000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943
|
||||
packetMagic = 0x0b110907;
|
||||
interval = INTERVAL;
|
||||
targetTimespan = TARGET_TIMESPAN;
|
||||
@@ -68,9 +71,9 @@ public class TestNet3Params extends AbstractBitcoinNetParams {
|
||||
bip32HeaderPub = 0x043587CF;
|
||||
bip32HeaderPriv = 0x04358394;
|
||||
|
||||
majorityEnforceBlockUpgrade = TestNet2Params.TESTNET_MAJORITY_ENFORCE_BLOCK_UPGRADE;
|
||||
majorityRejectBlockOutdated = TestNet2Params.TESTNET_MAJORITY_REJECT_BLOCK_OUTDATED;
|
||||
majorityWindow = TestNet2Params.TESTNET_MAJORITY_WINDOW;
|
||||
majorityEnforceBlockUpgrade = TESTNET_MAJORITY_ENFORCE_BLOCK_UPGRADE;
|
||||
majorityRejectBlockOutdated = TESTNET_MAJORITY_REJECT_BLOCK_OUTDATED;
|
||||
majorityWindow = TESTNET_MAJORITY_WINDOW;
|
||||
}
|
||||
|
||||
private static TestNet3Params instance;
|
||||
|
@@ -18,7 +18,7 @@
|
||||
package org.bitcoinj.core;
|
||||
|
||||
import org.bitcoinj.params.MainNetParams;
|
||||
import org.bitcoinj.params.TestNet2Params;
|
||||
import org.bitcoinj.params.TestNet3Params;
|
||||
import org.bitcoinj.params.UnitTestParams;
|
||||
import org.bitcoinj.store.BlockStore;
|
||||
import org.bitcoinj.store.MemoryBlockStore;
|
||||
@@ -59,12 +59,12 @@ public class BlockChainTest {
|
||||
private final StoredBlock[] block = new StoredBlock[1];
|
||||
private Transaction coinbaseTransaction;
|
||||
|
||||
private static class TweakableTestNet2Params extends TestNet2Params {
|
||||
private static class TweakableTestNet3Params extends TestNet3Params {
|
||||
public void setMaxTarget(BigInteger limit) {
|
||||
maxTarget = limit;
|
||||
}
|
||||
}
|
||||
private static final TweakableTestNet2Params TESTNET = new TweakableTestNet2Params();
|
||||
private static final TweakableTestNet3Params TESTNET = new TweakableTestNet3Params();
|
||||
private static final NetworkParameters UNITTEST = UnitTestParams.get();
|
||||
private static final NetworkParameters MAINNET = MainNetParams.get();
|
||||
|
||||
@@ -396,22 +396,24 @@ public class BlockChainTest {
|
||||
// Some blocks from the test net.
|
||||
private static Block getBlock2() throws Exception {
|
||||
Block b2 = new Block(TESTNET, Block.BLOCK_VERSION_GENESIS);
|
||||
b2.setMerkleRoot(Sha256Hash.wrap("addc858a17e21e68350f968ccd384d6439b64aafa6c193c8b9dd66320470838b"));
|
||||
b2.setNonce(2642058077L);
|
||||
b2.setTime(1296734343L);
|
||||
b2.setPrevBlockHash(Sha256Hash.wrap("000000033cc282bc1fa9dcae7a533263fd7fe66490f550d80076433340831604"));
|
||||
assertEquals("000000037b21cac5d30fc6fda2581cf7b2612908aed2abbcc429c45b0557a15f", b2.getHashAsString());
|
||||
b2.setMerkleRoot(Sha256Hash.wrap("20222eb90f5895556926c112bb5aa0df4ab5abc3107e21a6950aec3b2e3541e2"));
|
||||
b2.setNonce(875942400L);
|
||||
b2.setTime(1296688946L);
|
||||
b2.setDifficultyTarget(0x1d00ffff);
|
||||
b2.setPrevBlockHash(Sha256Hash.wrap("00000000b873e79784647a6c82962c70d228557d24a747ea4d1b8bbe878e1206"));
|
||||
assertEquals("000000006c02c8ea6e4ff69651f7fcde348fb9d557a06e6957b65552002a7820", b2.getHashAsString());
|
||||
b2.verifyHeader();
|
||||
return b2;
|
||||
}
|
||||
|
||||
private static Block getBlock1() throws Exception {
|
||||
Block b1 = new Block(TESTNET, Block.BLOCK_VERSION_GENESIS);
|
||||
b1.setMerkleRoot(Sha256Hash.wrap("0e8e58ecdacaa7b3c6304a35ae4ffff964816d2b80b62b58558866ce4e648c10"));
|
||||
b1.setNonce(236038445);
|
||||
b1.setTime(1296734340);
|
||||
b1.setPrevBlockHash(Sha256Hash.wrap("00000007199508e34a9ff81e6ec0c477a4cccff2a4767a8eee39c11db367b008"));
|
||||
assertEquals("000000033cc282bc1fa9dcae7a533263fd7fe66490f550d80076433340831604", b1.getHashAsString());
|
||||
b1.setMerkleRoot(Sha256Hash.wrap("f0315ffc38709d70ad5647e22048358dd3745f3ce3874223c80a7c92fab0c8ba"));
|
||||
b1.setNonce(1924588547);
|
||||
b1.setTime(1296688928);
|
||||
b1.setDifficultyTarget(0x1d00ffff);
|
||||
b1.setPrevBlockHash(Sha256Hash.wrap("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"));
|
||||
assertEquals("00000000b873e79784647a6c82962c70d228557d24a747ea4d1b8bbe878e1206", b1.getHashAsString());
|
||||
b1.verifyHeader();
|
||||
return b1;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@@ -44,6 +44,8 @@ import org.bitcoinj.utils.BriefLogFormatter;
|
||||
import org.bitcoinj.utils.Threading;
|
||||
import org.bitcoinj.wallet.DeterministicKeyChain;
|
||||
import org.bitcoinj.wallet.KeyChain;
|
||||
|
||||
import com.google.common.io.ByteStreams;
|
||||
import com.google.protobuf.ByteString;
|
||||
|
||||
import org.bitcoinj.wallet.MarriedKeyChain;
|
||||
@@ -212,7 +214,8 @@ public class WalletProtobufSerializerTest {
|
||||
assertTrue(lastSeenBlockHash.isEmpty());
|
||||
|
||||
// Create a block.
|
||||
Block block = UNITTEST.getDefaultSerializer().makeBlock(BlockTest.blockBytes);
|
||||
Block block = UNITTEST.getDefaultSerializer()
|
||||
.makeBlock(ByteStreams.toByteArray(BlockTest.class.getResourceAsStream("block_testnet700000.dat")));
|
||||
Sha256Hash blockHash = block.getHash();
|
||||
wallet.setLastBlockSeenHash(blockHash);
|
||||
wallet.setLastBlockSeenHeight(1);
|
||||
|
Binary file not shown.
Reference in New Issue
Block a user