set chain up for 10s blocktime, prevent possible future problems
This commit is contained in:
@@ -660,18 +660,6 @@ if EMBEDDED_LEVELDB
|
||||
include Makefile.leveldb.include
|
||||
endif
|
||||
|
||||
if ENABLE_TESTS
|
||||
include Makefile.test.include
|
||||
endif
|
||||
|
||||
if ENABLE_BENCH
|
||||
include Makefile.bench.include
|
||||
endif
|
||||
|
||||
if ENABLE_QT
|
||||
include Makefile.qt.include
|
||||
endif
|
||||
|
||||
if ENABLE_QT_TESTS
|
||||
include Makefile.qttest.include
|
||||
endif
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ static const CAmount COIN = 100000000;
|
||||
* critical; in unusual circumstances like a(nother) overflow bug that allowed
|
||||
* for the creation of coins out of thin air modification could lead to a fork.
|
||||
* */
|
||||
static const CAmount MAX_MONEY = 21000000 * COIN;
|
||||
static const CAmount MAX_MONEY = 9062500000 * COIN;
|
||||
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
|
||||
|
||||
#endif // BITCOIN_AMOUNT_H
|
||||
|
||||
+3
-1
@@ -17,8 +17,10 @@
|
||||
/**
|
||||
* Maximum amount of time that a block timestamp is allowed to exceed the
|
||||
* current network-adjusted time before the block will be accepted.
|
||||
*
|
||||
* Note: Given our 10s block time, 120s is appropriate by scale (10 min/2hr bitcoin)
|
||||
*/
|
||||
static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
|
||||
static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60;
|
||||
|
||||
/**
|
||||
* Timestamp window used as a grace period by code that compares external
|
||||
|
||||
+25
-213
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <chainparams.h>
|
||||
|
||||
#include <arith_uint256.h>
|
||||
#include <chainparamsseeds.h>
|
||||
#include <consensus/merkle.h>
|
||||
#include <tinyformat.h>
|
||||
@@ -51,7 +52,7 @@ static CBlock CreateGenesisBlock(const char* pszTimestamp, const CScript& genesi
|
||||
*/
|
||||
static CBlock CreateGenesisBlock(uint32_t nTime, uint32_t nNonce, uint32_t nBits, int32_t nVersion, const CAmount& genesisReward)
|
||||
{
|
||||
const char* pszTimestamp = "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks";
|
||||
const char* pszTimestamp = "nyc3 2019";
|
||||
const CScript genesisOutputScript = CScript() << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f") << OP_CHECKSIG;
|
||||
return CreateGenesisBlock(pszTimestamp, genesisOutputScript, nTime, nNonce, nBits, nVersion, genesisReward);
|
||||
}
|
||||
@@ -63,19 +64,13 @@ class CMainParams : public CChainParams {
|
||||
public:
|
||||
CMainParams() {
|
||||
strNetworkID = "main";
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
consensus.BIP16Exception = uint256S("0x00000000000002dc756eebf4f49723ed8d30cc28a5f108eb94b1ba88ac4f9c22");
|
||||
consensus.BIP34Height = 227931;
|
||||
consensus.BIP34Hash = uint256S("0x000000000000024b89b42a942fe0d9fea3bb44ab7bd1b19115dd6a759c0808b8");
|
||||
consensus.BIP65Height = 388381; // 000000000000000004c2b624ed5d7756c508d90fd0da2c7c679febfa6c4735f0
|
||||
consensus.BIP66Height = 363725; // 00000000000000000379eaa19dce8c9b722d46ae6a57c2f1a988119488b50931
|
||||
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
||||
consensus.nPowTargetSpacing = 10 * 60;
|
||||
consensus.powLimit = uint256S("0000fffff0000000000000000000000000000000000000000000000000000000");
|
||||
consensus.nPowTargetTimespan = 10; // you read correctly..
|
||||
consensus.nPowTargetSpacing = consensus.nPowTargetTimespan;
|
||||
consensus.fPowAllowMinDifficultyBlocks = false;
|
||||
consensus.fPowNoRetargeting = false;
|
||||
consensus.nRuleChangeActivationThreshold = 1916; // 95% of 2016
|
||||
consensus.nMinerConfirmationWindow = 2016; // nPowTargetTimespan / nPowTargetSpacing
|
||||
consensus.nRuleChangeActivationThreshold = 1916;
|
||||
consensus.nMinerConfirmationWindow = 2016;
|
||||
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
|
||||
@@ -91,51 +86,39 @@ public:
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1510704000; // November 15th, 2017.
|
||||
|
||||
// The best chain should have at least this much work.
|
||||
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000051dc8b82f450202ecb3d471");
|
||||
consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
// By default assume that the signatures in ancestors of this block are valid.
|
||||
consensus.defaultAssumeValid = uint256S("0x0000000000000000000f1c54590ee18d15ec70e68c8cd4cfbadb1b4f11697eee"); //563378
|
||||
consensus.defaultAssumeValid = uint256S("0x0000000000000000000000000000000000000000000000000000000000000000");
|
||||
|
||||
/**
|
||||
* 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] = 0xf9;
|
||||
pchMessageStart[0] = 0x1f;
|
||||
pchMessageStart[1] = 0xbe;
|
||||
pchMessageStart[2] = 0xb4;
|
||||
pchMessageStart[3] = 0xd9;
|
||||
nDefaultPort = 8333;
|
||||
pchMessageStart[2] = 0xef;
|
||||
pchMessageStart[3] = 0xf1;
|
||||
nDefaultPort = 55555;
|
||||
nPruneAfterHeight = 100000;
|
||||
m_assumed_blockchain_size = 240;
|
||||
m_assumed_chain_state_size = 3;
|
||||
|
||||
genesis = CreateGenesisBlock(1231006505, 2083236893, 0x1d00ffff, 1, 50 * COIN);
|
||||
genesis = CreateGenesisBlock(nTime, nNonce, 0x1f00ffff, 1, 0 * COIN);
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
|
||||
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
// assert(consensus.hashGenesisBlock == uint256S("0x000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"));
|
||||
// assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
|
||||
// Note that of those which support the service bits prefix, most only support a subset of
|
||||
// possible options.
|
||||
// This is fine at runtime as we'll fall back to using them as a oneshot if they don't support the
|
||||
// service bits we want, but we should get them updated to support all service bits wanted by any
|
||||
// release ASAP to avoid it where possible.
|
||||
vSeeds.emplace_back("seed.bitcoin.sipa.be"); // Pieter Wuille, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("dnsseed.bluematt.me"); // Matt Corallo, only supports x9
|
||||
vSeeds.emplace_back("dnsseed.bitcoin.dashjr.org"); // Luke Dashjr
|
||||
vSeeds.emplace_back("seed.bitcoinstats.com"); // Christian Decker, supports x1 - xf
|
||||
vSeeds.emplace_back("seed.bitcoin.jonasschnelli.ch"); // Jonas Schnelli, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("seed.btc.petertodd.org"); // Peter Todd, only supports x1, x5, x9, and xd
|
||||
vSeeds.emplace_back("seed.bitcoin.sprovoost.nl"); // Sjors Provoost
|
||||
vSeeds.emplace_back("dnsseed.emzy.de"); // Stephan Oeste
|
||||
// vSeeds.emplace_back("");
|
||||
|
||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,0);
|
||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,53);
|
||||
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,5);
|
||||
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,128);
|
||||
base58Prefixes[SECRET_KEY] = std::vector<unsigned char>(1,181);
|
||||
base58Prefixes[EXT_PUBLIC_KEY] = {0x04, 0x88, 0xB2, 0x1E};
|
||||
base58Prefixes[EXT_SECRET_KEY] = {0x04, 0x88, 0xAD, 0xE4};
|
||||
|
||||
bech32_hrp = "bc";
|
||||
bech32_hrp = "ny";
|
||||
|
||||
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_main, pnSeed6_main + ARRAYLEN(pnSeed6_main));
|
||||
|
||||
@@ -145,31 +128,18 @@ public:
|
||||
|
||||
checkpointData = {
|
||||
{
|
||||
{ 11111, uint256S("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d")},
|
||||
{ 33333, uint256S("0x000000002dd5588a74784eaa7ab0507a18ad16a236e7b1ce69f00d7ddfb5d0a6")},
|
||||
{ 74000, uint256S("0x0000000000573993a3c9e41ce34471c079dcf5f52a0e824a81e7f953b8661a20")},
|
||||
{105000, uint256S("0x00000000000291ce28027faea320c8d2b054b2e0fe44a773f3eefb151d6bdc97")},
|
||||
{134444, uint256S("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe")},
|
||||
{168000, uint256S("0x000000000000099e61ea72015e79632f216fe6cb33d7899acb35b75c8303b763")},
|
||||
{193000, uint256S("0x000000000000059f452a5f7340de6682a977387c17010ff6e6c3bd83ca8b1317")},
|
||||
{210000, uint256S("0x000000000000048b95347e83192f69cf0366076336c639f9b7228e9ba171342e")},
|
||||
{216116, uint256S("0x00000000000001b4f4b433e81ee46494af945cf96014816a4e2370f11b23df4e")},
|
||||
{225430, uint256S("0x00000000000001c108384350f74090433e7fcf79a606b8e797f065b130575932")},
|
||||
{250000, uint256S("0x000000000000003887df1f29024b06fc2200b55f8af8f35453d7be294df2d214")},
|
||||
{279000, uint256S("0x0000000000000001ae8c72a0b0c301f67e3afca10e819efa9041e458e9bd7e40")},
|
||||
{295000, uint256S("0x00000000000000004d9b4ef50f0f9d686fd69db2e03af35a100370c64632a983")},
|
||||
{ 0, consensus.hashGenesisBlock }
|
||||
}
|
||||
};
|
||||
|
||||
chainTxData = ChainTxData{
|
||||
// Data from rpc: getchaintxstats 4096 0000000000000000000f1c54590ee18d15ec70e68c8cd4cfbadb1b4f11697eee
|
||||
/* nTime */ 1550374134,
|
||||
/* nTxCount */ 383732546,
|
||||
/* dTxRate */ 3.685496590998308
|
||||
/* nTime */ 1559078000,
|
||||
/* nTxCount */ 1,
|
||||
/* dTxRate */ 1,
|
||||
};
|
||||
|
||||
/* disable fallback fee on mainnet */
|
||||
m_fallback_fee_enabled = false;
|
||||
m_fallback_fee_enabled = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -180,91 +150,6 @@ class CTestNetParams : public CChainParams {
|
||||
public:
|
||||
CTestNetParams() {
|
||||
strNetworkID = "test";
|
||||
consensus.nSubsidyHalvingInterval = 210000;
|
||||
consensus.BIP16Exception = uint256S("0x00000000dd30457c001f4095d208cc1296b0eed002427aa599874af7a432b105");
|
||||
consensus.BIP34Height = 21111;
|
||||
consensus.BIP34Hash = uint256S("0x0000000023b3a96d3484e5abb3755c413e7d41500f8e2a5c3f0dd01299cd8ef8");
|
||||
consensus.BIP65Height = 581885; // 00000000007f6655f22f98e72ed80d8b06dc761d5da09df0fa1dc4be4f861eb6
|
||||
consensus.BIP66Height = 330776; // 000000002104c8c45e99a8853285a3b592602a3ccde2b832481da85e9e4ba182
|
||||
consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
||||
consensus.nPowTargetSpacing = 10 * 60;
|
||||
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 = 1456790400; // March 1st, 2016
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_CSV].nTimeout = 1493596800; // May 1st, 2017
|
||||
|
||||
// Deployment of SegWit (BIP141, BIP143, and BIP147)
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].bit = 1;
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nStartTime = 1462060800; // May 1st 2016
|
||||
consensus.vDeployments[Consensus::DEPLOYMENT_SEGWIT].nTimeout = 1493596800; // May 1st 2017
|
||||
|
||||
// The best chain should have at least this much work.
|
||||
consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000007dbe94253893cbd463");
|
||||
|
||||
// By default assume that the signatures in ancestors of this block are valid.
|
||||
consensus.defaultAssumeValid = uint256S("0x0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75"); //1354312
|
||||
|
||||
pchMessageStart[0] = 0x0b;
|
||||
pchMessageStart[1] = 0x11;
|
||||
pchMessageStart[2] = 0x09;
|
||||
pchMessageStart[3] = 0x07;
|
||||
nDefaultPort = 18333;
|
||||
nPruneAfterHeight = 1000;
|
||||
m_assumed_blockchain_size = 30;
|
||||
m_assumed_chain_state_size = 2;
|
||||
|
||||
genesis = CreateGenesisBlock(1296688602, 414098458, 0x1d00ffff, 1, 50 * COIN);
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"));
|
||||
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
|
||||
vFixedSeeds.clear();
|
||||
vSeeds.clear();
|
||||
// nodes with support for servicebits filtering should be at the top
|
||||
vSeeds.emplace_back("testnet-seed.bitcoin.jonasschnelli.ch");
|
||||
vSeeds.emplace_back("seed.tbtc.petertodd.org");
|
||||
vSeeds.emplace_back("seed.testnet.bitcoin.sprovoost.nl");
|
||||
vSeeds.emplace_back("testnet-seed.bluematt.me"); // Just a static list of stable node(s), only supports x9
|
||||
|
||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
|
||||
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
|
||||
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};
|
||||
|
||||
bech32_hrp = "tb";
|
||||
|
||||
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
|
||||
|
||||
fDefaultConsistencyChecks = false;
|
||||
fRequireStandard = false;
|
||||
fMineBlocksOnDemand = false;
|
||||
|
||||
|
||||
checkpointData = {
|
||||
{
|
||||
{546, uint256S("000000002a936ca763904c3c35fce2f3556c559c0214345d31b1bcebf76acb70")},
|
||||
}
|
||||
};
|
||||
|
||||
chainTxData = ChainTxData{
|
||||
// Data from rpc: getchaintxstats 4096 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75
|
||||
/* nTime */ 1531929919,
|
||||
/* nTxCount */ 19438708,
|
||||
/* dTxRate */ 0.626
|
||||
};
|
||||
|
||||
/* enable fallback fee on testnet */
|
||||
m_fallback_fee_enabled = true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -275,80 +160,7 @@ class CRegTestParams : public CChainParams {
|
||||
public:
|
||||
explicit CRegTestParams(const ArgsManager& args) {
|
||||
strNetworkID = "regtest";
|
||||
consensus.nSubsidyHalvingInterval = 150;
|
||||
consensus.BIP16Exception = uint256();
|
||||
consensus.BIP34Height = 500; // BIP34 activated on regtest (Used in functional tests)
|
||||
consensus.BIP34Hash = uint256();
|
||||
consensus.BIP65Height = 1351; // BIP65 activated on regtest (Used in functional tests)
|
||||
consensus.BIP66Height = 1251; // BIP66 activated on regtest (Used in functional tests)
|
||||
consensus.powLimit = uint256S("7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
||||
consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks
|
||||
consensus.nPowTargetSpacing = 10 * 60;
|
||||
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 = 18444;
|
||||
nPruneAfterHeight = 1000;
|
||||
m_assumed_blockchain_size = 0;
|
||||
m_assumed_chain_state_size = 0;
|
||||
|
||||
UpdateVersionBitsParametersFromArgs(args);
|
||||
|
||||
genesis = CreateGenesisBlock(1296688602, 2, 0x207fffff, 1, 50 * COIN);
|
||||
consensus.hashGenesisBlock = genesis.GetHash();
|
||||
assert(consensus.hashGenesisBlock == uint256S("0x0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206"));
|
||||
assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"));
|
||||
|
||||
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("0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206")},
|
||||
}
|
||||
};
|
||||
|
||||
chainTxData = ChainTxData{
|
||||
0,
|
||||
0,
|
||||
0
|
||||
};
|
||||
|
||||
base58Prefixes[PUBKEY_ADDRESS] = std::vector<unsigned char>(1,111);
|
||||
base58Prefixes[SCRIPT_ADDRESS] = std::vector<unsigned char>(1,196);
|
||||
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};
|
||||
|
||||
bech32_hrp = "bcrt";
|
||||
|
||||
/* enable fallback fee on regtest */
|
||||
m_fallback_fee_enabled = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -48,16 +48,6 @@ struct BIP9Deployment {
|
||||
*/
|
||||
struct Params {
|
||||
uint256 hashGenesisBlock;
|
||||
int nSubsidyHalvingInterval;
|
||||
/* Block hash that is excepted from BIP16 enforcement */
|
||||
uint256 BIP16Exception;
|
||||
/** Block height and hash at which BIP34 becomes active */
|
||||
int BIP34Height;
|
||||
uint256 BIP34Hash;
|
||||
/** Block height at which BIP65 becomes active */
|
||||
int BIP65Height;
|
||||
/** Block height at which BIP66 becomes active */
|
||||
int BIP66Height;
|
||||
/**
|
||||
* Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period,
|
||||
* (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments.
|
||||
|
||||
+45
-1
@@ -10,7 +10,44 @@
|
||||
#include <primitives/block.h>
|
||||
#include <uint256.h>
|
||||
|
||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||
// credit/rights go to zawy (https://github.com/zawy12) for this algorithm
|
||||
unsigned int Lwma3CalculateNextWorkRequired(const CBlockIndex* pindexLast, const Consensus::Params& params)
|
||||
{
|
||||
const int64_t T = params.nPowTargetSpacing;
|
||||
const int64_t N = 150;
|
||||
const int64_t k = N * (N + 1) * T / 2;
|
||||
const int64_t height = pindexLast->nHeight;
|
||||
const arith_uint256 powLimit = UintToArith256(params.powLimit);
|
||||
|
||||
if (height < N) { return powLimit.GetCompact(); }
|
||||
|
||||
arith_uint256 sumTarget, nextTarget;
|
||||
int64_t thisTimestamp, previousTimestamp;
|
||||
int64_t t = 0, j = 0;
|
||||
|
||||
const CBlockIndex* blockPreviousTimestamp = pindexLast->GetAncestor(height - N);
|
||||
previousTimestamp = blockPreviousTimestamp->GetBlockTime();
|
||||
|
||||
// Loop through N most recent blocks.
|
||||
for (int64_t i = height - N + 1; i <= height; i++) {
|
||||
const CBlockIndex* block = pindexLast->GetAncestor(i);
|
||||
thisTimestamp = (block->GetBlockTime() > previousTimestamp) ?
|
||||
block->GetBlockTime() : previousTimestamp + 1;
|
||||
int64_t solvetime = std::min(6 * T, thisTimestamp - previousTimestamp);
|
||||
previousTimestamp = thisTimestamp;
|
||||
j++;
|
||||
t += solvetime * j; // Weighted solvetime sum.
|
||||
arith_uint256 target;
|
||||
target.SetCompact(block->nBits);
|
||||
sumTarget += target / (k * N);
|
||||
}
|
||||
nextTarget = t * sumTarget;
|
||||
if (nextTarget > powLimit) { nextTarget = powLimit; }
|
||||
|
||||
return nextTarget.GetCompact();
|
||||
}
|
||||
|
||||
unsigned int GetNextWorkBuffer(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||
{
|
||||
assert(pindexLast != nullptr);
|
||||
unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
|
||||
@@ -46,6 +83,13 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
|
||||
return CalculateNextWorkRequired(pindexLast, pindexFirst->GetBlockTime(), params);
|
||||
}
|
||||
|
||||
unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params)
|
||||
{
|
||||
if (pindexLast->nHeight+1 <= 150)
|
||||
return GetNextWorkBuffer(pindexLast, pblock, params);
|
||||
return Lwma3CalculateNextWorkRequired(pindexLast, params);
|
||||
}
|
||||
|
||||
unsigned int CalculateNextWorkRequired(const CBlockIndex* pindexLast, int64_t nFirstBlockTime, const Consensus::Params& params)
|
||||
{
|
||||
if (params.fPowNoRetargeting)
|
||||
|
||||
+1
-14
@@ -1192,20 +1192,7 @@ static UniValue verifychain(const JSONRPCRequest& request)
|
||||
static UniValue SoftForkMajorityDesc(int version, const CBlockIndex* pindex, const Consensus::Params& consensusParams)
|
||||
{
|
||||
UniValue rv(UniValue::VOBJ);
|
||||
bool activated = false;
|
||||
switch(version)
|
||||
{
|
||||
case 2:
|
||||
activated = pindex->nHeight >= consensusParams.BIP34Height;
|
||||
break;
|
||||
case 3:
|
||||
activated = pindex->nHeight >= consensusParams.BIP66Height;
|
||||
break;
|
||||
case 4:
|
||||
activated = pindex->nHeight >= consensusParams.BIP65Height;
|
||||
break;
|
||||
}
|
||||
rv.pushKV("status", activated);
|
||||
rv.pushKV("status", true);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
+10
-29
@@ -1153,14 +1153,13 @@ bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const CBlockIndex* pindex
|
||||
|
||||
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams)
|
||||
{
|
||||
int halvings = nHeight / consensusParams.nSubsidyHalvingInterval;
|
||||
// Force block reward to zero when right shift is undefined.
|
||||
if (halvings >= 64)
|
||||
return 0;
|
||||
CAmount nSubsidy = 0 * COIN;
|
||||
|
||||
if (nHeight > 0 && nHeight <= 16)
|
||||
nSubsidy = 9062500000 * COIN;
|
||||
if (nHeight > 16)
|
||||
nSubsidy = 500 * COIN;
|
||||
|
||||
CAmount nSubsidy = 50 * COIN;
|
||||
// Subsidy is cut in half every 210,000 blocks which will occur approximately every 4 years.
|
||||
nSubsidy >>= halvings;
|
||||
return nSubsidy;
|
||||
}
|
||||
|
||||
@@ -1743,12 +1742,7 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
|
||||
// However, only one historical block violated the P2SH rules (on both
|
||||
// mainnet and testnet), so for simplicity, always leave P2SH
|
||||
// on except for the one violating block.
|
||||
if (consensusparams.BIP16Exception.IsNull() || // no bip16 exception on this chain
|
||||
pindex->phashBlock == nullptr || // this is a new candidate block, eg from TestBlockValidity()
|
||||
*pindex->phashBlock != consensusparams.BIP16Exception) // this block isn't the historical exception
|
||||
{
|
||||
flags |= SCRIPT_VERIFY_P2SH;
|
||||
}
|
||||
flags |= SCRIPT_VERIFY_P2SH;
|
||||
|
||||
// Enforce WITNESS rules whenever P2SH is in effect (and the segwit
|
||||
// deployment is defined).
|
||||
@@ -1757,12 +1751,8 @@ static unsigned int GetBlockScriptFlags(const CBlockIndex* pindex, const Consens
|
||||
}
|
||||
|
||||
// Start enforcing the DERSIG (BIP66) rule
|
||||
if (pindex->nHeight >= consensusparams.BIP66Height) {
|
||||
if (pindex->nHeight >= 1) {
|
||||
flags |= SCRIPT_VERIFY_DERSIG;
|
||||
}
|
||||
|
||||
// Start enforcing CHECKLOCKTIMEVERIFY (BIP65) rule
|
||||
if (pindex->nHeight >= consensusparams.BIP65Height) {
|
||||
flags |= SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY;
|
||||
}
|
||||
|
||||
@@ -1938,9 +1928,8 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
||||
// be reset before it reaches block 1,983,702 and starts doing unnecessary
|
||||
// BIP30 checking again.
|
||||
assert(pindex->pprev);
|
||||
CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height);
|
||||
//Only continue to enforce if we're below BIP34 activation height or the block hash at that height doesn't correspond.
|
||||
fEnforceBIP30 = fEnforceBIP30 && (!pindexBIP34height || !(pindexBIP34height->GetBlockHash() == chainparams.GetConsensus().BIP34Hash));
|
||||
fEnforceBIP30 = true;
|
||||
|
||||
// TODO: Remove BIP30 checking from block height 1,983,702 on, once we have a
|
||||
// consensus change that ensures coinbases at those heights can not
|
||||
@@ -3262,14 +3251,6 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta
|
||||
if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME)
|
||||
return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");
|
||||
|
||||
// Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded:
|
||||
// check for version 2, 3 and 4 upgrades
|
||||
if((block.nVersion < 2 && nHeight >= consensusParams.BIP34Height) ||
|
||||
(block.nVersion < 3 && nHeight >= consensusParams.BIP66Height) ||
|
||||
(block.nVersion < 4 && nHeight >= consensusParams.BIP65Height))
|
||||
return state.Invalid(false, REJECT_OBSOLETE, strprintf("bad-version(0x%08x)", block.nVersion),
|
||||
strprintf("rejected nVersion=0x%08x block", block.nVersion));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -3302,7 +3283,7 @@ static bool ContextualCheckBlock(const CBlock& block, CValidationState& state, c
|
||||
}
|
||||
|
||||
// Enforce rule that the coinbase starts with serialized block height
|
||||
if (nHeight >= consensusParams.BIP34Height)
|
||||
if (nHeight >= 1)
|
||||
{
|
||||
CScript expect = CScript() << nHeight;
|
||||
if (block.vtx[0]->vin[0].scriptSig.size() < expect.size() ||
|
||||
|
||||
Reference in New Issue
Block a user