aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-02-10 18:55:31 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2016-02-10 18:56:51 +0100
commitc9da9c4bd83cfd5ffc6ea1a4af42f08a46dfceb1 (patch)
treec2e5d45c6401061c00ad1fd9c4c632d850547a42
parentd007511ebdfa87f80d7218d8df06e781f4656c68 (diff)
parent40e7b61835cbe5fd471d0b4b71972526bf0e523c (diff)
downloadbitcoin-c9da9c4bd83cfd5ffc6ea1a4af42f08a46dfceb1.tar.xz
Merge #7491: wallet: Ignore MarkConflict if block hash is not known
40e7b61 wallet: Ignore MarkConflict if block hash is not known (Wladimir J. van der Laan)
-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 ade460d6ac..65defc30aa 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -846,14 +846,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);