mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-03-12 21:52:22 +00:00
371 lines
16 KiB
C++
371 lines
16 KiB
C++
// Copyright (c) 2010 Satoshi Nakamoto
|
|
// Copyright (c) 2009-2017 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <arith_uint256.h>
|
|
#include <chainparams.h>
|
|
#include <consensus/merkle.h>
|
|
|
|
#include <tinyformat.h>
|
|
#include <util.h>
|
|
#include <utilstrencodings.h>
|
|
|
|
#include <assert.h>
|
|
#include <memory>
|
|
|
|
#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)
|
|
{
|
|
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 = nNonce;
|
|
genesis.nVersion = nVersion;
|
|
genesis.vtx.push_back(MakeTransactionRef(std::move(txNew)));
|
|
genesis.hashPrevBlock.SetNull();
|
|
genesis.hashMerkleRoot = BlockMerkleRoot(genesis);
|
|
return genesis;
|
|
}
|
|
|
|
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
|
|
{
|
|
// RELEASE TODO: change timestamp
|
|
const char* pszTimestamp = "The Economist 05/Dec/2018 The US-China trade war is on hold";
|
|
const CScript genesisOutputScript = CScript() << ParseHex("a914676a24ba4bfadd458e5245b26fa57f9a62ca185087");
|
|
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
|
|
}
|
|
|
|
void CChainParams::UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
|
|
{
|
|
consensus.vDeployments[d].nStartTime = nStartTime;
|
|
consensus.vDeployments[d].nTimeout = nTimeout;
|
|
}
|
|
|
|
/**
|
|
* Main network
|
|
*/
|
|
/**
|
|
* What makes a good checkpoint block?
|
|
* + Is surrounded by blocks with reasonable timestamps
|
|
* (no blocks before with a timestamp after, none after with
|
|
* timestamp before)
|
|
* + Contains no strange transactions
|
|
*/
|
|
|
|
class CMainParams : public CChainParams {
|
|
public:
|
|
CMainParams() {
|
|
strNetworkID = "main";
|
|
consensus.nSubsidyHalvingInterval = 1050000; // 210000 * 5
|
|
consensus.BIP16Height = 1;
|
|
consensus.BIP34Height = 1;
|
|
consensus.BIP65Height = 1;
|
|
consensus.BIP66Height = 1;
|
|
consensus.powLimit = uint256S("000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
consensus.nPowTargetTimespan = 2.0 * 60; // Two minutes
|
|
consensus.nPowTargetSpacing = 2.0 * 60; // Two minutes
|
|
consensus.fPowAllowMinDifficultyBlocks = false;
|
|
consensus.fPowNoRetargeting = false;
|
|
consensus.nRuleChangeActivationThreshold = 6048; // 75% of 8064
|
|
consensus.nMinerConfirmationWindow = 8064; // nPowTargetTimespan / nPowTargetSpacing * 4
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
|
|
|
|
// Deployment of BIP68, BIP112, and BIP113.
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
|
|
//consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1485561600; // January 28, 2017
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = -1; // Consensus::BIP9Deployment::ALWAYS_ACTIVE
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1517356801; // January 31st, 2018
|
|
|
|
// Deployment of SegWit (BIP141, BIP143, and BIP147)
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
|
|
//consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1485561600; // January 28, 2017
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = -1; // Consensus::BIP9Deployment::ALWAYS_ACTIVE
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1517356801; // January 31st, 2018
|
|
|
|
// The best chain should have at least this much work.
|
|
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000100000");
|
|
|
|
// By default assume that the signatures in ancestors of this block are valid.
|
|
consensus.defaultAssumeValid = uint256S("0x66f49ad85624c33e4fd61aa45c54012509ed4a53308908dd07f56346c7939273");
|
|
|
|
/**
|
|
* The message start string is designed to be unlikely to occur in normal data.
|
|
* The characters are rarely used upper ASCII, not valid as UTF-8, and produce
|
|
* a large 32-bit integer with any alignment.
|
|
*/
|
|
pchMessageStart[0] = 0x6a;
|
|
pchMessageStart[1] = 0xc6;
|
|
pchMessageStart[2] = 0x07;
|
|
pchMessageStart[3] = 0x9a;
|
|
nDefaultPort = 9338;
|
|
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(1543789622, 3302, 0x1f0ffff0, 1, genesisBlockReward);
|
|
|
|
consensus.hashGenesisBlock = genesis.GetHash();
|
|
assert(consensus.hashGenesisBlock == uint256S("0x77c037d74bc51b535629537c8e9530340ea12272f43d261a0ee59e8f2ad0e6f6"));
|
|
assert(genesis.hashMerkleRoot == uint256S("0xb21d4680875c0e472b7dbf3dbab2aaeb2dbbb5fa8b154f978b5ea0706d1fd5b9"));
|
|
|
|
// Note that of those with the service bits flag, most only support a subset of possible options
|
|
vSeeds.emplace_back("dnsseed.kevacoin.org");
|
|
vSeeds.emplace_back("dnsseed.honourchat.com");
|
|
|
|
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,45); // K
|
|
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
|
|
base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1,70); // V
|
|
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,139); // M
|
|
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
|
|
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
|
|
base58Prefixes[KEVA_NAMESPACE] = std::vector<unsigned char>(1,53); // N
|
|
|
|
bech32_hrp = "kva";
|
|
|
|
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
|
|
|
|
fDefaultConsistencyChecks = false;
|
|
fRequireStandard = true;
|
|
fMineBlocksOnDemand = false;
|
|
|
|
checkpointData = {
|
|
{
|
|
}
|
|
};
|
|
|
|
chainTxData = ChainTxData{
|
|
};
|
|
}
|
|
|
|
int DefaultCheckKevaDB() const
|
|
{
|
|
return -1;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Testnet (v3)
|
|
*/
|
|
class CTestNetParams : public CChainParams {
|
|
public:
|
|
CTestNetParams() {
|
|
strNetworkID = "test";
|
|
consensus.nSubsidyHalvingInterval = 840000;
|
|
consensus.BIP16Height = 0; // always enforce P2SH BIP16 on regtest
|
|
consensus.BIP34Height = 1;
|
|
consensus.BIP34Hash = uint256S("0xa8dbaa66a9266348f6527fe528efea73227d51938befb81d5a1521cebd319c4a"); // Genesis
|
|
consensus.BIP65Height = 1;
|
|
consensus.BIP66Height = 1;
|
|
consensus.powLimit = uint256S("000fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
consensus.nPowTargetTimespan = 2.0 * 60; // Two minutes
|
|
consensus.nPowTargetSpacing = 2.0 * 60; // Two minutes
|
|
consensus.fPowAllowMinDifficultyBlocks = true;
|
|
consensus.fPowNoRetargeting = false;
|
|
consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains
|
|
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; // January 1, 2008
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; // December 31, 2008
|
|
|
|
// Deployment of BIP68, BIP112, and BIP113.
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
|
|
//consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 1483228800; // January 1, 2017
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = -1; // Consensus::BIP9Deployment::ALWAYS_ACTIVE
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1517356801; // January 31st, 2018
|
|
|
|
// Deployment of SegWit (BIP141, BIP143, and BIP147)
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
|
|
//consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1483228800; // January 1, 2017
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = -1; // Consensus::BIP9Deployment::ALWAYS_ACTIVE
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1517356801; // January 31st, 2018
|
|
|
|
// The best chain should have at least this much work.
|
|
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000100000");
|
|
|
|
// By default assume that the signatures in ancestors of this block are valid.
|
|
consensus.defaultAssumeValid = uint256S("0x1efb29c8187d5a496a33377941d1df415169c3ce5d8c05d055f25b683ec3f9a3");
|
|
|
|
pchMessageStart[0] = 0xfe;
|
|
pchMessageStart[1] = 0xec;
|
|
pchMessageStart[2] = 0x65;
|
|
pchMessageStart[3] = 0xe4;
|
|
nDefaultPort = 19335;
|
|
nPruneAfterHeight = 1000;
|
|
#if 1
|
|
genesis = CreateGenesisBlock(1543789622, 1592, 0x1f0ffff0, 1, 500 * COIN);
|
|
consensus.hashGenesisBlock = genesis.GetHash();
|
|
assert(consensus.hashGenesisBlock == uint256S("860764b471430b96f15c145a44fd854f89d3be6f9ae054ef46e4c8473259bae3"));
|
|
assert(genesis.hashMerkleRoot == uint256S("3cf6c3b6da3f4058853ee70369ee43d473aca91ae8fc8f44a645beb21c392d80"));
|
|
#else
|
|
genesis = CreateGenesisBlock(1550900037, 3033, 0x1f0fffff, 1, 500 * COIN);
|
|
consensus.hashGenesisBlock = genesis.GetHash();
|
|
assert(consensus.hashGenesisBlock == uint256S("584a067cf7ea6daf30c351a46c6b7403d6fdc0e6e953cf7531d11eb7d834546c"));
|
|
assert(genesis.hashMerkleRoot == uint256S("3cf6c3b6da3f4058853ee70369ee43d473aca91ae8fc8f44a645beb21c392d80"));
|
|
#endif
|
|
|
|
vFixedSeeds.clear();
|
|
vSeeds.clear();
|
|
// nodes with support for servicebits filtering should be at the top
|
|
#if 0
|
|
vSeeds.emplace_back("testnet-seed.kevacoin.org");
|
|
vSeeds.emplace_back("testnet-seed.honourchat.com");
|
|
#endif
|
|
|
|
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,55); // P
|
|
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
|
|
base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1,65); // T
|
|
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,58); // 9
|
|
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
|
|
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
|
|
base58Prefixes[KEVA_NAMESPACE] = std::vector<unsigned char>(1,53); // N
|
|
|
|
bech32_hrp = "tkva";
|
|
#if 0
|
|
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
|
|
#endif
|
|
|
|
fDefaultConsistencyChecks = false;
|
|
fRequireStandard = false;
|
|
fMineBlocksOnDemand = false;
|
|
|
|
checkpointData = (CCheckpointData) {
|
|
{
|
|
}
|
|
};
|
|
|
|
chainTxData = ChainTxData{
|
|
};
|
|
|
|
}
|
|
|
|
int DefaultCheckKevaDB() const
|
|
{
|
|
return -1;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Regression test
|
|
*/
|
|
class CRegTestParams : public CChainParams {
|
|
public:
|
|
CRegTestParams() {
|
|
strNetworkID = "regtest";
|
|
consensus.nSubsidyHalvingInterval = 150;
|
|
consensus.BIP16Height = 0; // always enforce P2SH BIP16 on regtest
|
|
consensus.BIP34Height = 100000000; // BIP34 has not activated on regtest (far in the future so block v1 are not rejected in tests)
|
|
consensus.BIP34Hash = uint256();
|
|
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in rpc activation tests)
|
|
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in rpc activation tests)
|
|
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
|
consensus.nPowTargetTimespan = 20; // 20 second
|
|
consensus.nPowTargetSpacing = 20; // 20 second
|
|
consensus.fPowAllowMinDifficultyBlocks = true;
|
|
consensus.fPowNoRetargeting = true;
|
|
consensus.nRuleChangeActivationThreshold = 108; // 75% for testchains
|
|
consensus.nMinerConfirmationWindow = 144; // Faster than normal for regtest (144 instead of 2016)
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 0;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = Consensus::BIP9Deployment::ALWAYS_ACTIVE;
|
|
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = Consensus::BIP9Deployment::NO_TIMEOUT;
|
|
|
|
// The best chain should have at least this much work.
|
|
consensus.nMinimumChainWork = uint256S("0x00");
|
|
|
|
// By default assume that the signatures in ancestors of this block are valid.
|
|
consensus.defaultAssumeValid = uint256S("0x00");
|
|
|
|
pchMessageStart[0] = 0xfa;
|
|
pchMessageStart[1] = 0xbf;
|
|
pchMessageStart[2] = 0xb5;
|
|
pchMessageStart[3] = 0xda;
|
|
nDefaultPort = 19444;
|
|
nPruneAfterHeight = 1000;
|
|
|
|
genesis = CreateGenesisBlock(1296688602, 1, 0x207fffff, 1, 50 * COIN);
|
|
consensus.hashGenesisBlock = genesis.GetHash();
|
|
assert(consensus.hashGenesisBlock == uint256S("0x8353937c85572e556dbec10555b846ddd1a812ab328c9089527f88081e1b5a11"));
|
|
assert(genesis.hashMerkleRoot == uint256S("0x13ec98c3307b8e6b67b91c605c7347916a99f9dfde7b5d88365aaef322192314"));
|
|
|
|
vFixedSeeds.clear(); //!< Regtest mode doesn't have any fixed seeds.
|
|
vSeeds.clear(); //!< Regtest mode doesn't have any DNS seeds.
|
|
|
|
fDefaultConsistencyChecks = true;
|
|
fRequireStandard = false;
|
|
fMineBlocksOnDemand = true;
|
|
|
|
checkpointData = {
|
|
{
|
|
{0, uint256S("530827f38f93b43ed12af0b3ad25a288dc02ed74d6d7857862df51fc56c416f9")},
|
|
}
|
|
};
|
|
|
|
chainTxData = ChainTxData{
|
|
0,
|
|
0,
|
|
0
|
|
};
|
|
|
|
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
|
|
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
|
|
base58Prefixes[SCRIPT_ADDRESS2] = std::vector<unsigned char>(1,58);
|
|
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,239);
|
|
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x35, 0x87, 0xCF};
|
|
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x35, 0x83, 0x94};
|
|
base58Prefixes[KEVA_NAMESPACE] = std::vector<unsigned char>(1,53); // N
|
|
|
|
bech32_hrp = "rkva";
|
|
}
|
|
|
|
int DefaultCheckKevaDB() const
|
|
{
|
|
return 0;
|
|
}
|
|
};
|
|
|
|
static std::unique_ptr<CChainParams> globalChainParams;
|
|
|
|
const CChainParams &Params() {
|
|
assert(globalChainParams);
|
|
return *globalChainParams;
|
|
}
|
|
|
|
std::unique_ptr<CChainParams> CreateChainParams(const std::string& chain)
|
|
{
|
|
if (chain == CBaseChainParams::MAIN)
|
|
return std::unique_ptr<CChainParams>(new CMainParams());
|
|
else if (chain == CBaseChainParams::TESTNET)
|
|
return std::unique_ptr<CChainParams>(new CTestNetParams());
|
|
else if (chain == CBaseChainParams::REGTEST)
|
|
return std::unique_ptr<CChainParams>(new CRegTestParams());
|
|
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
|
|
}
|
|
|
|
void SelectParams(const std::string& network)
|
|
{
|
|
SelectBaseParams(network);
|
|
globalChainParams = CreateChainParams(network);
|
|
}
|
|
|
|
void UpdateVersionBitsParameters(Consensus::DeploymentPos d, int64_t nStartTime, int64_t nTimeout)
|
|
{
|
|
globalChainParams->UpdateVersionBitsParameters(d, nStartTime, nTimeout);
|
|
}
|