Skip to content

Commit

Permalink
Ready for mainnet.
Browse files Browse the repository at this point in the history
  • Loading branch information
jianpingw committed Jan 15, 2020
1 parent bb09e64 commit 4df2c1d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 34 deletions.
2 changes: 1 addition & 1 deletion contrib/seeds/nodes_main.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
52.38.179.128
100.21.116.119
7 changes: 0 additions & 7 deletions src/bitcoin-cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ static int AppInitRPC(int argc, char* argv[])
return EXIT_FAILURE;
}

#if 1
if (ChainNameFromCommandLine() == CBaseChainParams::MAIN) {
printf("\nMainnet is not live yet, use \"-testnet\" option to connect to the testnet.\n\n");
exit(1);
}
#endif

// Check for -testnet or -regtest parameter (BaseParams() calls are only valid after this clause)
try {
SelectBaseParams(ChainNameFromCommandLine());
Expand Down
7 changes: 0 additions & 7 deletions src/bitcoind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,6 @@ bool AppInit(int argc, char* argv[])
return false;
}

#if 1
if (ChainNameFromCommandLine() == CBaseChainParams::MAIN) {
printf("\nMainnet is not live yet, use \"-testnet\" option to connect to the testnet.\n\n");
exit(1);
}
#endif

// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
try {
SelectParams(ChainNameFromCommandLine());
Expand Down
62 changes: 51 additions & 11 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@

#include <chainparamsseeds.h>

static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
/**
* For Test net and Reg Test.
*/
static CBlock CreateGenesisBlockTest(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CMutableTransaction txNew;
txNew.nVersion = 1;
Expand All @@ -41,12 +44,50 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
return genesis;
}

static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
static CBlock CreateGenesisBlockTest(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
// RELEASE TODO: change timestamp
const char* pszTimestamp = "The Economist 27/Sept/2019 Repo-market ructions were a reminder of the financial crisis";
const CScript genesisOutputScript = CScript() << ParseHex("a914676a24ba4bfadd458e5245b26fa57f9a62ca185087");
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
return CreateGenesisBlockTest(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}

/**
* For Main net.
*/
static CBlock CreateGenesisBlockMain(const char* pszTimestamp, const CScript& genesisOutputScript, uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
CMutableTransaction txNew;
txNew.nVersion = 1;
txNew.vin.resize(1);
txNew.vout.resize(1);
txNew.vin[0].scriptSig = CScript() << 486604799 << CScriptNum(4) << std::vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
txNew.vout[0].nValue = genesisReward;
txNew.vout[0].scriptPubKey = genesisOutputScript;

CBlock genesis;
genesis.nTime = nTime;
genesis.nBits = nBits;
genesis.nNonce = 0; // Used as height.
genesis.nVersion = nVersion;
genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
genesis.hashPrevBlock.SetNull();
genesis.hashMerkleRoot = BlockMerkleRoot(genesis);

genesis.cnHeader.major_version = 10; // Cryptonight variant 4
genesis.cnHeader.minor_version = 0;
genesis.cnHeader.prev_id = genesis.GetOriginalBlockHash();
genesis.cnHeader.merkle_root = uint256S("0x09bafe2103d3588f80ef5a876f3b24fc1fc277d7105798e163600652dc02de6f");
genesis.cnHeader.nonce = nNonce;
genesis.cnHeader.timestamp = nTime;
genesis.cnHeader.nTxes = 1;
return genesis;
}

static CBlock CreateGenesisBlockMain(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
{
const char* pszTimestamp = "Thank You Satoshi 612997 2020-01-15 11:40:41 7f31f44d";
const CScript genesisOutputScript = CScript() << ParseHex("a914676a24ba4bfadd458e5245b26fa57f9a62ca185087");
return CreateGenesisBlockMain(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}

void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
Expand Down Expand Up @@ -99,7 +140,7 @@ class CMainParams : public CChainParams {
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1517356801; // January 31st, 2018

// The best chain should have at least this much work.
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000001000000");
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000000000000000FF000");

// By default assume that the signatures in ancestors of this block are valid.
consensus.defaultAssumeValid = uint256S("0x00");
Expand All @@ -117,11 +158,10 @@ class CMainParams : public CChainParams {
nPruneAfterHeight = 100000;

const uint32_t genesisBlockReward = 0.00001 * COIN; // A small reward for the core developers :-)
//TODO: target: 0x1e0fffff, update timestampe and nonce.
genesis = CreateGenesisBlock(1553145843, 1621, 0x1e0fffff, 1, genesisBlockReward);
genesis = CreateGenesisBlockMain(1579143600, 585290, 0x1e0fffff, 1, genesisBlockReward);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x2f6d82a919bfc055f9e66e82bd613050cb835f969563f217737c9ef631668f6c"));
assert(genesis.hashMerkleRoot == uint256S("0x285139132ff0b33d399aae61053d19b34fe8e483053142d530d62d90881183c9"));
assert(consensus.hashGenesisBlock == uint256S("0x70bd30ae775c691fc8a2b7d27f37279a4f505f877e3234105f22e963a618597c"));
assert(genesis.hashMerkleRoot == uint256S("0xe6104a982da24d09ccf867aba92abbd31b2ede9da636941367709c5ef24d3330"));

// Note that of those with the service bits flag, most only support a subset of possible options
vSeeds.emplace_back("dnsseed.kevacoin.org");
Expand Down Expand Up @@ -206,7 +246,7 @@ class CTestNetParams : public CChainParams {
nDefaultPort = 19335;
nPruneAfterHeight = 1000;

genesis = CreateGenesisBlock(1573082080, 11061, 0x1f0ffff0, 1, 500 * COIN);
genesis = CreateGenesisBlockTest(1573082080, 11061, 0x1f0ffff0, 1, 500 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("a540f9f5826989d09baef56b4f43ea8ef7638f99e870327c1cc552626cbf8e4e"));
assert(genesis.hashMerkleRoot == uint256S("d85a90623fbff6a5ea4b80df1dbc81b32de7f1011f484e186cfb7cf2d4292c95"));
Expand Down Expand Up @@ -291,7 +331,7 @@ class CRegTestParams : public CChainParams {
nDefaultPort = 19444;
nPruneAfterHeight = 1000;

genesis = CreateGenesisBlock(1296688602, 0, 0x207fffff, 1, 50 * COIN);
genesis = CreateGenesisBlockTest(1296688602, 0, 0x207fffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x5b2e996d458adbf5c81b381f90ca167732bc9f4e9c1c4ec8485fa74efe793ed8"));
assert(genesis.hashMerkleRoot == uint256S("0x13ec98c3307b8e6b67b91c605c7347916a99f9dfde7b5d88365aaef322192314"));
Expand Down
3 changes: 1 addition & 2 deletions src/chainparamsseeds.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
* IPv4 as well as onion addresses are wrapped inside a IPv6 address accordingly.
*/
static SeedSpec6 pnSeed6_main[] = {
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x34,0x26,0xb3,0x80}, 9338}
{{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x64,0x15,0x74,0x77}, 9338}
};

static SeedSpec6 pnSeed6_test[] = {

};

#endif // BITCOIN_CHAINPARAMSSEEDS_H
6 changes: 0 additions & 6 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1461,12 +1461,6 @@ bool AppInitMain()
break;
}

#if 1
if (ChainNameFromCommandLine() == CBaseChainParams::MAIN) {
return InitError(_("Mainnet is not live yet, use \"-testnet\" option to connect to the testnet."));
}
#endif

// If the loaded chain has a wrong genesis, bail out immediately
// (we're likely using a testnet datadir, or the other way around).
if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0)
Expand Down

0 comments on commit 4df2c1d

Please sign in to comment.