Skip to content

Commit 93de289

Browse files
committed
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.
1 parent 2ea7eb6 commit 93de289

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/wallet/wallet.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4397,7 +4397,9 @@ int CMerkleTx::GetBlocksToMaturity() const
43974397
{
43984398
if (!IsCoinBase())
43994399
return 0;
4400-
return std::max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain());
4400+
int chain_depth = GetDepthInMainChain();
4401+
assert(chain_depth >= 0); // coinbase tx should not be conflicted
4402+
return std::max(0, (COINBASE_MATURITY+1) - chain_depth);
44014403
}
44024404

44034405

0 commit comments

Comments
 (0)