aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-02-09 20:23:09 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2016-02-10 19:58:19 +0100
commit00ec73e062cac5b23bc99a0010fc9ce6cd20b99e (patch)
tree52a3d7c23d91a94037b8dce77dd200ce08d647ac /src
parent827a2b6736d082a1adffa41267a374abe3fd330f (diff)
downloadbitcoin-00ec73e062cac5b23bc99a0010fc9ce6cd20b99e.tar.xz
wallet: Ignore MarkConflict if block hash is not known
If number of conflict confirms cannot be determined, this means that the block is still unknown or not yet part of the main chain, for example during a reindex. Do nothing in that case, instead of crash with an assertion. Fixes #7234. Github-Pull: #7491 Rebased-From: 40e7b61835cbe5fd471d0b4b71972526bf0e523c
Diffstat (limited to 'src')
-rw-r--r--src/wallet/wallet.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index cbc71aa16b..be70240a6c 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -847,14 +847,19 @@ void CWallet::MarkConflicted(const uint256& hashBlock, const uint256& hashTx)
{
LOCK2(cs_main, cs_wallet);
- CBlockIndex* pindex;
- assert(mapBlockIndex.count(hashBlock));
- pindex = mapBlockIndex[hashBlock];
int conflictconfirms = 0;
- if (chainActive.Contains(pindex)) {
- conflictconfirms = -(chainActive.Height() - pindex->nHeight + 1);
+ if (mapBlockIndex.count(hashBlock)) {
+ CBlockIndex* pindex = mapBlockIndex[hashBlock];
+ if (chainActive.Contains(pindex)) {
+ conflictconfirms = -(chainActive.Height() - pindex->nHeight + 1);
+ }
}
- assert(conflictconfirms < 0);
+ // If number of conflict confirms cannot be determined, this means
+ // that the block is still unknown or not yet part of the main chain,
+ // for example when loading the wallet during a reindex. Do nothing in that
+ // case.
+ if (conflictconfirms >= 0)
+ return;
// Do not flush the wallet here for performance reasons
CWalletDB walletdb(strWalletFile, "r+", false);