Replace COINBASE_MATURITY...

...with nCoinbaseMaturity
This commit is contained in:
lateminer
2017-12-17 15:21:59 +03:00
parent 0252c5cea3
commit f536a8126e
7 changed files with 8 additions and 6 deletions

View File

@@ -102,6 +102,7 @@ public:
consensus.nProtocolV3Time = 1444028400;
consensus.nLastPOWBlock = 10000;
consensus.nStakeTimestampMask = 0xf; // 15
consensus.nCoinbaseMaturity = 500;
consensus.nStakeMinConfirmations = 500;
consensus.nStakeMinAge = 8 * 60 * 60; // 8 hours

View File

@@ -70,6 +70,7 @@ struct Params {
unsigned int GetTargetSpacing(int nHeight) { return IsProtocolV2(nHeight) ? 64 : 60; }
int nLastPOWBlock;
int nStakeTimestampMask;
int nCoinbaseMaturity;
int nStakeMinConfirmations;
unsigned int nStakeMinAge;
};

View File

@@ -1915,7 +1915,7 @@ bool CheckTxInputs(const CTransaction& tx, CValidationState& state, const CCoins
// If prev is coinbase or coinstake, check that it's matured
if (coins->IsCoinBase() || coins->IsCoinStake()) {
if (nSpendHeight - coins->nHeight < COINBASE_MATURITY)
if (nSpendHeight - coins->nHeight < Params().nCoinbaseMaturity)
return state.Invalid(
error("CheckInputs(): tried to spend %s at depth %d", coins->IsCoinBase() ? "coinbase" : "coinstake", nSpendHeight - coins->nHeight),
REJECT_INVALID, "bad-txns-premature-spend-of-coinbase");
@@ -2476,7 +2476,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
REJECT_INVALID, "bad-cs-kernel");
// Check proof-of-stake min confirmations
if (pindex->nHeight - coins->nHeight < Params().GetConsensus().nStakeMinConfirmations)
if (pindex->nHeight - coins->nHeight < chainparams.GetConsensus().nStakeMinConfirmations)
return state.DoS(100,
error("%s: tried to stake at depth %d", __func__, pindex->nHeight - coins->nHeight),
REJECT_INVALID, "bad-cs-premature");

View File

@@ -262,7 +262,7 @@ QString TransactionDesc::toHTML(CWallet *wallet, CWalletTx &wtx, TransactionReco
if (wtx.IsCoinBase())
{
quint32 numBlocksToMaturity = COINBASE_MATURITY + 1;
quint32 numBlocksToMaturity = Params().GetConsensus().nCoinbaseMaturity + 1;
strHTML += "<br>" + 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)) + "<br>";
}

View File

@@ -101,7 +101,7 @@ TestChain100Setup::TestChain100Setup() : TestingSetup(CBaseChainParams::REGTEST)
// Generate a 100-block chain:
coinbaseKey.MakeNewKey(true);
CScript scriptPubKey = CScript() << ToByteVector(coinbaseKey.GetPubKey()) << OP_CHECKSIG;
for (int i = 0; i < COINBASE_MATURITY; i++)
for (int i = 0; i < Params().GetConsensus().nCoinbaseMaturity; i++)
{
std::vector<CMutableTransaction> noTxns;
CBlock b = CreateAndProcessBlock(noTxns, scriptPubKey);

View File

@@ -665,7 +665,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
continue;
const CCoins *coins = pcoins->AccessCoins(txin.prevout.hash);
if (nCheckFrequency != 0) assert(coins);
if (!coins || (coins->IsCoinBase() || coins->IsCoinStake() && ((signed long)nMemPoolHeight) - coins->nHeight < COINBASE_MATURITY)) {
if (!coins || (coins->IsCoinBase() || coins->IsCoinStake() && ((signed long)nMemPoolHeight) - coins->nHeight < Params().GetConsensus().nCoinbaseMaturity)) {
transactionsToRemove.push_back(tx);
break;
}

View File

@@ -3520,7 +3520,7 @@ int CMerkleTx::GetBlocksToMaturity() const
{
if (!(IsCoinBase() || IsCoinStake()))
return 0;
return max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain());
return max(0, (Params().GetConsensus().nCoinbaseMaturity+1) - GetDepthInMainChain());
}