diff --git a/src/auxpow.cpp b/src/auxpow.cpp
index 3c350a67a..7356d0202 100644
--- a/src/auxpow.cpp
+++ b/src/auxpow.cpp
@@ -7,6 +7,7 @@
#include "auxpow.h"
+#include "chainparams.h"
#include "consensus/validation.h"
#include "main.h"
#include "script/script.h"
@@ -89,7 +90,8 @@ int CMerkleTx::GetBlocksToMaturity() const
{
if (!IsCoinBase())
return 0;
- return std::max(0, (COINBASE_MATURITY + 1) - GetDepthInMainChain());
+ int nCoinbaseMaturity = Params().GetConsensus(chainActive.Height()).nCoinbaseMaturity;
+ return std::max(0, (nCoinbaseMaturity + 1) - GetDepthInMainChain());
}
diff --git a/src/chainparams.cpp b/src/chainparams.cpp
index 94bf5b33f..ea38b6eea 100644
--- a/src/chainparams.cpp
+++ b/src/chainparams.cpp
@@ -51,6 +51,7 @@ public:
consensus.fAllowLegacyBlocks = true;
consensus.nHeightEffective = 0;
consensus.fDigishieldDifficultyCalculation = false;
+ consensus.nCoinbaseMaturity = 30;
// Blocks 145000 - 371336 are Digishield without AuxPoW
digishieldConsensus = consensus;
@@ -58,6 +59,7 @@ public:
digishieldConsensus.fSimplifiedRewards = true;
digishieldConsensus.fDigishieldDifficultyCalculation = true;
digishieldConsensus.nPowTargetTimespan = 60; // post-digishield: 1 minute
+ digishieldConsensus.nCoinbaseMaturity = 240;
// Blocks 371337+ are AuxPoW
auxpowConsensus = digishieldConsensus;
@@ -203,6 +205,7 @@ public:
digishieldConsensus.fDigishieldDifficultyCalculation = true;
digishieldConsensus.fSimplifiedRewards = true;
digishieldConsensus.fPowAllowMinDifficultyBlocks = false;
+ digishieldConsensus.nCoinbaseMaturity = 240;
// Blocks 157500 - 158099 are Digishield with minimum difficulty on all blocks
minDifficultyConsensus = digishieldConsensus;
@@ -285,9 +288,11 @@ public:
consensus.nMajorityRejectBlockOutdated = 950;
consensus.nMajorityWindow = 1000;
consensus.nPowTargetTimespan = 4 * 60 * 60; // pre-digishield: 4 hours
+ consensus.nPowTargetSpacing = 1; // regtest: 1 second blocks
consensus.powLimit = uint256S("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); // ~uint256(0) >> 1;
consensus.fStrictChainId = true;
consensus.fAllowLegacyBlocks = false; // Never allow legacy blocks on RegTest
+ consensus.fSimplifiedRewards = true;
// Reset links before we copy parameters
consensus.pLeft = NULL;
@@ -295,7 +300,7 @@ public:
digishieldConsensus = consensus;
digishieldConsensus.nHeightEffective = 10;
- digishieldConsensus.nPowTargetTimespan = 60; // post-digishield: 1 minute
+ digishieldConsensus.nPowTargetTimespan = 1; // // regtest: also retarget every second in digishield mode, for conformity
digishieldConsensus.fDigishieldDifficultyCalculation = true;
auxpowConsensus = digishieldConsensus;
diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h
index 1bf388bef..414c509fa 100644
--- a/src/consensus/consensus.h
+++ b/src/consensus/consensus.h
@@ -10,12 +10,6 @@
static const unsigned int MAX_BLOCK_SIZE = 1000000;
/** The maximum allowed number of signature check operations in a block (network rule) */
static const unsigned int MAX_BLOCK_SIGOPS = MAX_BLOCK_SIZE/50;
-/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
-static const int COINBASE_MATURITY = 60*4; // 4 hours of blocks
-/** Coinbase maturity before block 145000 **/
-static const int COINBASE_MATURITY_OLD = 30;
-/** Block at which COINBASE_MATURITY_OLD was deprecated **/
-static const int COINBASE_MATURITY_SWITCH = 145000;
/** Threshold for nLockTime: below this value it is interpreted as block number, otherwise as UNIX timestamp. */
static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
diff --git a/src/consensus/params.h b/src/consensus/params.h
index 906599ff4..45c0bde5f 100644
--- a/src/consensus/params.h
+++ b/src/consensus/params.h
@@ -19,6 +19,7 @@ struct Params {
int nMajorityEnforceBlockUpgrade;
int nMajorityRejectBlockOutdated;
int nMajorityWindow;
+ int nCoinbaseMaturity;
/** Proof of work parameters */
uint256 powLimit;
bool fPowAllowMinDifficultyBlocks;
diff --git a/src/main.cpp b/src/main.cpp
index ee5be679c..a3d5dcc30 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1448,9 +1448,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
// If prev is coinbase, check that it's matured
if (coins->IsCoinBase()) {
// Dogecoin: Switch maturity at depth 145,000
- int nCoinbaseMaturity = coins->nHeight < COINBASE_MATURITY_SWITCH
- ? COINBASE_MATURITY_OLD
- : COINBASE_MATURITY;
+ int nCoinbaseMaturity = Params().GetConsensus(coins->nHeight).nCoinbaseMaturity;
if (nSpendHeight - coins->nHeight < nCoinbaseMaturity)
return state.Invalid(
error("CheckInputs(): tried to spend coinbase at depth %d", nSpendHeight - coins->nHeight),
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index 5662b1665..aab31f1c1 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -10,6 +10,7 @@
#include "transactionrecord.h"
#include "base58.h"
+#include "chainparams.h"
#include "consensus/consensus.h"
#include "main.h"
#include "script/script.h"
@@ -264,8 +265,8 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
if (wtx.IsCoinBase())
{
- quint32 numBlocksToMaturity = COINBASE_MATURITY + 1;
- strHTML += "
" + tr("Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.").arg(QString::number(numBlocksToMaturity)) + "
";
+ quint32 nCoinbaseMaturity = Params().GetConsensus(chainActive.Height()).nCoinbaseMaturity + 1;
+ strHTML += "
" + tr("Generated coins must mature %1 blocks before they can be spent. When you generated this block, it was broadcast to the network to be added to the block chain. If it fails to get into the chain, its state will change to \"not accepted\" and it won't be spendable. This may occasionally happen if another node generates a block within a few seconds of yours.").arg(QString::number(nCoinbaseMaturity)) + "
";
}
//
diff --git a/src/txmempool.cpp b/src/txmempool.cpp
index 1c16e2092..1502cc6d2 100644
--- a/src/txmempool.cpp
+++ b/src/txmempool.cpp
@@ -5,6 +5,7 @@
#include "txmempool.h"
+#include "chainparams.h"
#include "clientversion.h"
#include "consensus/consensus.h"
#include "consensus/validation.h"
@@ -166,7 +167,8 @@ void CTxMemPool::removeCoinbaseSpends(const CCoinsViewCache *pcoins, unsigned in
continue;
const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
if (fSanityCheck) assert(coins);
- if (!coins || (coins->IsCoinBase() && nMemPoolHeight - coins->nHeight < COINBASE_MATURITY)) {
+ int nCoinbaseMaturity = Params().GetConsensus(coins->nHeight).nCoinbaseMaturity;
+ if (!coins || (coins->IsCoinBase() && nMemPoolHeight - coins->nHeight < nCoinbaseMaturity)) {
transactionsToRemove.push_back(tx);
break;
}