mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-24 18:23:26 -03:00
wallet: Check last block and conflict height are valid in MarkConflicted
MarkConflicted calculates conflict confirmations incorrectly when both
the last block processed height and the conflicting height are negative
(i.e. uninitialized). If either are negative, we should not be marking
conflicts and should exit early.
Github-Pull: #28542
Rebased-From: 4660fc82a1
This commit is contained in:
parent
5e51a9cc72
commit
d63478cb50
1 changed files with 4 additions and 1 deletions
|
@ -1323,11 +1323,14 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
|
|||
{
|
||||
LOCK(cs_wallet);
|
||||
|
||||
int conflictconfirms = (m_last_block_processed_height - conflicting_height + 1) * -1;
|
||||
// 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 (m_last_block_processed_height < 0 || conflicting_height < 0) {
|
||||
return;
|
||||
}
|
||||
int conflictconfirms = (m_last_block_processed_height - conflicting_height + 1) * -1;
|
||||
if (conflictconfirms >= 0)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue