HomePhabricator

wallet: Ignore chainStateFlushed notifications while attaching chain

Description

wallet: Ignore chainStateFlushed notifications while attaching chain

Summary:
When a rescan is performed during CWallet::AttachChain() (e.g. when loading an old wallet) but this is interrupted by a shutdown signal, the wallet will currently stop the rescan, receive a chainStateFlushed signal, set the saved best block to the tip and shut down. At next startup, the rescan is not continued or repeated because of this. But some blocks have never been scanned by the wallet, which could lead to an incorrect balance.

Fix this by ignoring chainStateFlushed notifications until the chain is attached. Since CWallet::chainStateFlushed is being manually called by AttachChain() anyway after finishing with the rescan, it is not a problem if intermediate notifications are ignored.

Manual rescans started / aborted by the rescanblockchain / abortrescan RPCs are not affected by this (which makes this behavior hard to test).

This is a backport of core#24984 and core#25088

Test Plan:
Check for no regressions on existing tested behavior:

ninja all check-all

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D17689

Details

Provenance
Martin Zumsande <mzumsande@gmail.com>Authored on Apr 25 2022, 20:38
PiRKCommitted on Tue, Feb 25, 11:32
PiRKPushed on Tue, Feb 25, 11:32
Reviewer
Restricted Project
Differential Revision
D17689: wallet: Ignore chainStateFlushed notifications while attaching chain
Parents
rABCc52393d22e61: doc: Improve ZMQ documentation
Branches
Unknown
Tags
Unknown