neobytes/src/chainparams.cpp
2024-02-10 09:36:44 +01:00

402 lines
20 KiB
C++

// Copyright (c) 2010 Satoshi Nakamoto
// Copyright (c) 2009-2014 The Bitcoin Core developers
// Copyright (c) 2014-2017 The Dash Core developers
// Copyright (c) 2021-2024 The NeoBytes Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "chainparams.h"
#include "consensus/merkle.h"
#include "tinyformat.h"
#include "util.h"
#include "utilstrencodings.h"
#include <assert.h>
#include <boost/assign/list_of.hpp>
#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(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)
{
const char* pszTimestamp = "NeoBytes Genesis born on June 1, 2021";
const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
}
/**
* 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 = 262800; // Note: actual number of blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050)
consensus.nMasternodePaymentsStartBlock = 960; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value
consensus.nInstantSendKeepLock = 24;
consensus.nBudgetPaymentsStartBlock = 328008; // actual historical value
consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725
consensus.nBudgetPaymentsWindowBlocks = 100;
consensus.nBudgetProposalEstablishingTime = 60*60*24;
consensus.nSuperblockStartBlock = 614820;
consensus.nSuperblockCycle = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725
consensus.nGovernanceMinQuorum = 10;
consensus.nGovernanceFilterElements = 20000;
consensus.nMasternodeMinimumConfirmations = 15;
consensus.nMajorityEnforceBlockUpgrade = 750;
consensus.nMajorityRejectBlockOutdated = 950;
consensus.nMajorityWindow = 1000;
consensus.BIP34Height = 0;
consensus.BIP34Hash = uint256S("0x0000083c6edd8e5870c4f25857824125358a96c81b66dc5831ddd5e82a777758");
consensus.powLimit = uint256S("00000fffff000000000000000000000000000000000000000000000000000000");
consensus.nPowTargetTimespan = 2.5 * 24 * 60 * 60; // NeoBytes: 2.5 days
consensus.nPowTargetSpacing = 5 * 60; // NeoBytes: 5 minutes
consensus.fPowAllowMinDifficultyBlocks = false;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1815; // 90% of 2016
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 = 1486252800; // Feb 5th, 2017
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1517788800; // Feb 5th, 2018
/**
* 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] = 0x53;
pchMessageStart[1] = 0x6e;
pchMessageStart[2] = 0x6f;
pchMessageStart[3] = 0x77;
vAlertPubKey = ParseHex("04b4f241819421257b67ef1ea62fd694ee3698559ffbd4aad04ea088d5731fd45e1948580e66af2aba6a40c65a2422ce81430db739a19ad1b4d17eaf6b49e1cec2");
nDefaultPort = 11427;
nMaxTipAge = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin
nPruneAfterHeight = 100000;
/**
* NeoBytes Mainnet
* Algorithm: neoscrypt
* Genesis nTime : 1689725227
* Genesis nNoce : 1347040
* Genesis nBits : 0x1e0ffff0
* Genesis Hash : 0000083c6edd8e5870c4f25857824125358a96c81b66dc5831ddd5e82a777758
* Genesis Hash Merkle Root : a041e8d6859590ecc9baa0077724a864d9eefc06569395d82f35b6f77c12c237
*/
genesis = CreateGenesisBlock(1689725227, 1347040, 0x1e0ffff0, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x0000083c6edd8e5870c4f25857824125358a96c81b66dc5831ddd5e82a777758"));
assert(genesis.hashMerkleRoot == uint256S("0xa041e8d6859590ecc9baa0077724a864d9eefc06569395d82f35b6f77c12c237"));
vSeeds.push_back(CDNSSeedData("neobytes.network", "dnsseed.neobytes.network"));
// NeoBytes addresses start with 'N'
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,53);
// NeoBytes script addresses start with '9'
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,21);
// NeoBytes private keys start with '9' or 'N'
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,181);
// NeoBytes BIP32 pubkeys start with 'xpub' (Bitcoin defaults)
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x88)(0xB2)(0x1E).convert_to_container<std::vector<unsigned char> >();
// NeoBytes BIP32 prvkeys start with 'xprv' (Bitcoin defaults)
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();
// NeoBytes BIP44 coin type is '5'
base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x00)(0x05).convert_to_container<std::vector<unsigned char> >();
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
fMiningRequiresPeers = true;
fDefaultConsistencyChecks = false;
fRequireStandard = true;
fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = false;
nPoolMaxTransactions = 3;
nFulfilledRequestExpireTime = 60*60; // fulfilled requests expire in 1 hour
strSporkPubKey = "04a077102fb396b50757ae2197a85326327d51702c03274f8ec601ba9b48dc252314d35d5f3acda0a9cbbbe377e9c8566b657efe565f1123132638ebcdcd177ee4";
strMasternodePaymentsPubKey = "04a077102fb396b50757ae2197a85326327d51702c03274f8ec601ba9b48dc252314d35d5f3acda0a9cbbbe377e9c8566b657efe565f1123132638ebcdcd177ee4";
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 0, uint256S("0x0000083c6edd8e5870c4f25857824125358a96c81b66dc5831ddd5e82a777758")),
1689725227, // * UNIX timestamp of last checkpoint block
0, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
1500 // * estimated number of transactions per day after checkpoint
};
}
};
static CMainParams mainParams;
/**
* Testnet (v3)
*/
class CTestNetParams : public CChainParams {
public:
CTestNetParams() {
strNetworkID = "test";
consensus.nSubsidyHalvingInterval = 262800;
consensus.nMasternodePaymentsStartBlock = 10000; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 46000;
consensus.nMasternodePaymentsIncreasePeriod = 576;
consensus.nInstantSendKeepLock = 6;
consensus.nBudgetPaymentsStartBlock = 60000;
consensus.nBudgetPaymentsCycleBlocks = 50;
consensus.nBudgetPaymentsWindowBlocks = 10;
consensus.nBudgetProposalEstablishingTime = 60*20;
consensus.nSuperblockStartBlock = 61000; // NOTE: Should satisfy nSuperblockStartBlock > nBudgetPeymentsStartBlock
consensus.nSuperblockCycle = 24; // Superblocks can be issued hourly on testnet
consensus.nGovernanceMinQuorum = 1;
consensus.nGovernanceFilterElements = 500;
consensus.nMasternodeMinimumConfirmations = 1;
consensus.nMajorityEnforceBlockUpgrade = 51;
consensus.nMajorityRejectBlockOutdated = 75;
consensus.nMajorityWindow = 100;
consensus.BIP34Height = 0;
consensus.BIP34Hash = uint256S("0x0000042e5e7347b96f676974fa0cd902956ae49ce78d4ca4978d59fa90d7343c");
consensus.powLimit = uint256S("00000fffff000000000000000000000000000000000000000000000000000000");
consensus.nPowTargetTimespan = 2.5 * 24 * 60 * 60; // NeoBytes: 2.5 days
consensus.nPowTargetSpacing = 5 * 60; // NeoBytes: 5 minutes
consensus.fPowAllowMinDifficultyBlocks = true;
consensus.fPowNoRetargeting = false;
consensus.nRuleChangeActivationThreshold = 1815; // 90% 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 = 1456790400; // March 1st, 2016
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1493596800; // May 1st, 2017
pchMessageStart[0] = 0x4c;
pchMessageStart[1] = 0x75;
pchMessageStart[2] = 0x6e;
pchMessageStart[3] = 0x61;
vAlertPubKey = ParseHex("041197130efc23d878376e05809efb30a78073d5ddd7c29c4408e13ed39778f03458782aa0a803e0e90d1f21eaa8f648d8e3956a5626be12f1136d1d171846f47b");
nDefaultPort = 12427;
nMaxTipAge = 0x7fffffff; // allow mining on top of old blocks for testnet
nPruneAfterHeight = 1000;
/**
* NeoBytes Testnet
* Algorithm: neoscrypt
* Genesis nTime : 1622466128
* Genesis nNoce : 893296
* Genesis nBits : 0x1e0ffff0
* Genesis Hash : 0000042e5e7347b96f676974fa0cd902956ae49ce78d4ca4978d59fa90d7343c
* Genesis Hash Merkle Root : a041e8d6859590ecc9baa0077724a864d9eefc06569395d82f35b6f77c12c237
*/
genesis = CreateGenesisBlock(1622466128, 893296, 0x1e0ffff0, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x0000042e5e7347b96f676974fa0cd902956ae49ce78d4ca4978d59fa90d7343c"));
assert(genesis.hashMerkleRoot == uint256S("0xa041e8d6859590ecc9baa0077724a864d9eefc06569395d82f35b6f77c12c237"));
vFixedSeeds.clear();
vSeeds.clear();
vSeeds.push_back(CDNSSeedData("neobytes.network", "testnet-dnsseed1.neobytes.network"));
// Testnet NeoBytes addresses start with 'n'
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,112);
// Testnet NeoBytes script addresses start with '8'
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,18);
// Testnet private keys start with '8' or 'n'
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,240);
// Testnet NeoBytes BIP32 pubkeys start with 'tpub' (Bitcoin defaults)
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
// Testnet NeoBytes BIP32 prvkeys start with 'tprv' (Bitcoin defaults)
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
// Testnet NeoBytes BIP44 coin type is '1' (All coin's testnet default)
base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x00)(0x01).convert_to_container<std::vector<unsigned char> >();
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
fMiningRequiresPeers = true;
fDefaultConsistencyChecks = false;
fRequireStandard = false;
fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = true;
nPoolMaxTransactions = 3;
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
strSporkPubKey = "0461848c2eb849fa3a3f7062b133b076b9594d683f0981328f355fd2e88cd62ff6d575bbfc1161dce703f725b085398d89a3bfe30487153c5c7e570502794c3be2";
strMasternodePaymentsPubKey = "0461848c2eb849fa3a3f7062b133b076b9594d683f0981328f355fd2e88cd62ff6d575bbfc1161dce703f725b085398d89a3bfe30487153c5c7e570502794c3be2";
checkpointData = (CCheckpointData) {
boost::assign::map_list_of
( 0, uint256S("0x0000042e5e7347b96f676974fa0cd902956ae49ce78d4ca4978d59fa90d7343c")),
1622466128, // * UNIX timestamp of last checkpoint block
0, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
500 // * estimated number of transactions per day after checkpoint
};
}
};
static CTestNetParams testNetParams;
/**
* Regression test
*/
class CRegTestParams : public CChainParams {
public:
CRegTestParams() {
strNetworkID = "regtest";
consensus.nSubsidyHalvingInterval = 150;
consensus.nMasternodePaymentsStartBlock = 240;
consensus.nMasternodePaymentsIncreaseBlock = 350;
consensus.nMasternodePaymentsIncreasePeriod = 10;
consensus.nInstantSendKeepLock = 6;
consensus.nBudgetPaymentsStartBlock = 1000;
consensus.nBudgetPaymentsCycleBlocks = 50;
consensus.nBudgetPaymentsWindowBlocks = 10;
consensus.nBudgetProposalEstablishingTime = 60*20;
consensus.nSuperblockStartBlock = 1500;
consensus.nSuperblockCycle = 10;
consensus.nGovernanceMinQuorum = 1;
consensus.nGovernanceFilterElements = 100;
consensus.nMasternodeMinimumConfirmations = 1;
consensus.nMajorityEnforceBlockUpgrade = 750;
consensus.nMajorityRejectBlockOutdated = 950;
consensus.nMajorityWindow = 1000;
consensus.BIP34Height = -1; // BIP34 has not necessarily activated on regtest
consensus.BIP34Hash = uint256();
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
consensus.nPowTargetTimespan = 2.5 * 24 * 60 * 60; // NeoBytes: 2.5 days
consensus.nPowTargetSpacing = 5 * 60; // NeoBytes: 5 minutes
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 = 999999999999ULL;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].bit = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nStartTime = 0;
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 999999999999ULL;
pchMessageStart[0] = 0x4c;
pchMessageStart[1] = 0x75;
pchMessageStart[2] = 0x6e;
pchMessageStart[3] = 0x61;
nMaxTipAge = 6 * 60 * 60; // ~144 blocks behind -> 2 x fork detection time, was 24 * 60 * 60 in bitcoin
nDefaultPort = 12437;
nPruneAfterHeight = 1000;
/**
* NeoBytes Regnet
* AlgMineGenesis(genesis, consensus.powLimit, true);orithm: neoscrypt
* Genesis nTime : 1622466748
* Genesis nNoce : 0
* Genesis nBits : 0x207fffff
* Genesis Hash : 0668630d663da4a6fcb0fa2e1f01f8d156082e2043354707f2f73f032842752b
* Genesis Hash Merkle Root : a041e8d6859590ecc9baa0077724a864d9eefc06569395d82f35b6f77c12c237
*/
genesis = CreateGenesisBlock(1689728725, 0, 0x207fffff, 1, 50 * COIN);
consensus.hashGenesisBlock = genesis.GetHash();
assert(consensus.hashGenesisBlock == uint256S("0x0668630d663da4a6fcb0fa2e1f01f8d156082e2043354707f2f73f032842752b"));
assert(genesis.hashMerkleRoot == uint256S("0xa041e8d6859590ecc9baa0077724a864d9eefc06569395d82f35b6f77c12c237"));
vFixedSeeds.clear(); //! Regtest mode doesn't have any fixed seeds.
vSeeds.clear(); //! Regtest mode doesn't have any DNS seeds.
fMiningRequiresPeers = false;
fDefaultConsistencyChecks = true;
fRequireStandard = false;
fMineBlocksOnDemand = true;
fTestnetToBeDeprecatedFieldRPC = false;
nFulfilledRequestExpireTime = 5*60; // fulfilled requests expire in 5 minutes
checkpointData = (CCheckpointData){
boost::assign::map_list_of
( 0, uint256S("0x0668630d663da4a6fcb0fa2e1f01f8d156082e2043354707f2f73f032842752b")),
0,
0,
0
};
// Regtest NeoBytes addresses start with 'n'
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,112);
// Regtest NeoBytes script addresses start with '8'
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,18);
// Regtest private keys start with '8' or 'n'
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,240);
// Regtest NeoBytes BIP32 pubkeys start with 'tpub' (Bitcoin defaults)
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
// Regtest NeoBytes BIP32 prvkeys start with 'tprv' (Bitcoin defaults)
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
// Regtest NeoBytes BIP44 coin type is '1' (All coin's testnet default)
base58Prefixes[EXT_COIN_TYPE] = boost::assign::list_of(0x80)(0x00)(0x00)(0x01).convert_to_container<std::vector<unsigned char> >();
}
};
static CRegTestParams regTestParams;
static CChainParams *pCurrentParams = 0;
const CChainParams &Params() {
assert(pCurrentParams);
return *pCurrentParams;
}
CChainParams& Params(const std::string& chain)
{
if (chain == CBaseChainParams::MAIN)
return mainParams;
else if (chain == CBaseChainParams::TESTNET)
return testNetParams;
else if (chain == CBaseChainParams::REGTEST)
return regTestParams;
else
throw std::runtime_error(strprintf("%s: Unknown chain %s.", __func__, chain));
}
void SelectParams(const std::string& network)
{
SelectBaseParams(network);
pCurrentParams = &Params(network);
}