wallet: assert to ensure accuracy of CMerkleTx::GetBlocksToMaturity
According to my understanding, it should not be possible for coinbase transactions to be conflicting, thus it should not be possible for GetDepthInMainChain to return a negative result. If it did, this would also result in innacurate results for GetBlocksToMaturity due to the math therein. asserting ensures accuracy.
This commit is contained in:
parent
2ea7eb62b2
commit
93de2891fa
1 changed files with 3 additions and 1 deletions
|
@ -4397,7 +4397,9 @@ int CMerkleTx::GetBlocksToMaturity() const
|
|||
{
|
||||
if (!IsCoinBase())
|
||||
return 0;
|
||||
return std::max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain());
|
||||
int chain_depth = GetDepthInMainChain();
|
||||
assert(chain_depth >= 0); // coinbase tx should not be conflicted
|
||||
return std::max(0, (COINBASE_MATURITY+1) - chain_depth);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue