Skip to content

Commit

Permalink
wallet: Ignore MarkConflict if block hash is not known
Browse files Browse the repository at this point in the history
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: 40e7b61
  • Loading branch information
laanwj committed Feb 10, 2016
1 parent 827a2b6 commit 00ec73e
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 00ec73e

Please sign in to comment.