aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2018-08-07 14:09:13 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2018-08-07 14:19:50 +0200
commit51c693d49ef1e9aabbc35669d86d952dcebeb61c (patch)
tree03c932875f401026eb8e7f08b52cd45b25ed422d
parent8c3c402a5a2da9c4c62655b64a9adceced7e9cf4 (diff)
parent93de2891fa9cb8314573ba3a6ab764bc9c52444d (diff)
Merge #13657: wallet: assert to ensure accuracy of CMerkleTx::GetBlocksToMaturity
93de2891fa9cb8314573ba3a6ab764bc9c52444d 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
-rw-r--r--src/wallet/wallet.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index bfa903ac13..2c15ff7d90 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -4378,7 +4378,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);
}