Skip to content

Commit 51c693d

Browse files
committed
Merge #13657: wallet: assert to ensure accuracy of CMerkleTx::GetBlocksToMaturity
93de289 wallet: assert to ensure accuracy of CMerkleTx::GetBlocksToMaturity (Ben Woosley) Pull request description: 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. Tree-SHA512: 8e71c26f09fe457cfb00c362ca27066f7f018ea2af1f395090fdc7fd9f5964b76f4317c23f7a4923776f00087558511da5c1c368095be39fb1bacc614a93c32f
2 parents 8c3c402 + 93de289 commit 51c693d

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
@@ -4378,7 +4378,9 @@ int CMerkleTx::GetBlocksToMaturity() const
43784378
{
43794379
if (!IsCoinBase())
43804380
return 0;
4381-
return std::max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain());
4381+
int chain_depth = GetDepthInMainChain();
4382+
assert(chain_depth >= 0); // coinbase tx should not be conflicted
4383+
return std::max(0, (COINBASE_MATURITY+1) - chain_depth);
43824384
}
43834385

43844386

0 commit comments

Comments
 (0)