mirror of
https://github.com/twisterarmy/twister-core.git
synced 2025-01-24 05:24:34 +00:00
Bugfix: off-by-one error in coinbase maturity check
This commit is contained in:
parent
2ef15697f8
commit
56424040a4
@ -1319,7 +1319,9 @@ bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmod
|
|||||||
if (!HaveInputs(inputs))
|
if (!HaveInputs(inputs))
|
||||||
return error("CheckInputs() : %s inputs unavailable", GetHash().ToString().substr(0,10).c_str());
|
return error("CheckInputs() : %s inputs unavailable", GetHash().ToString().substr(0,10).c_str());
|
||||||
|
|
||||||
CBlockIndex *pindexBlock = inputs.GetBestBlock();
|
// While checking, GetBestBlock() refers to the parent block.
|
||||||
|
// This is also true for mempool checks.
|
||||||
|
int nSpendHeight = inputs.GetBestBlock()->nHeight + 1;
|
||||||
int64 nValueIn = 0;
|
int64 nValueIn = 0;
|
||||||
int64 nFees = 0;
|
int64 nFees = 0;
|
||||||
for (unsigned int i = 0; i < vin.size(); i++)
|
for (unsigned int i = 0; i < vin.size(); i++)
|
||||||
@ -1329,8 +1331,8 @@ bool CTransaction::CheckInputs(CCoinsViewCache &inputs, enum CheckSig_mode csmod
|
|||||||
|
|
||||||
// If prev is coinbase, check that it's matured
|
// If prev is coinbase, check that it's matured
|
||||||
if (coins.IsCoinBase()) {
|
if (coins.IsCoinBase()) {
|
||||||
if (pindexBlock->nHeight - coins.nHeight < COINBASE_MATURITY)
|
if (nSpendHeight - coins.nHeight < COINBASE_MATURITY)
|
||||||
return error("CheckInputs() : tried to spend coinbase at depth %d", pindexBlock->nHeight - coins.nHeight);
|
return error("CheckInputs() : tried to spend coinbase at depth %d", nSpendHeight - coins.nHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for negative or overflow input values
|
// Check for negative or overflow input values
|
||||||
|
Loading…
x
Reference in New Issue
Block a user