elements/src/wallet
Ava Chow c4b46b4589
Merge bitcoin/bitcoin#31629: wallet: fix rescanning inconsistency
4818da809f wallet: fix rescanning inconsistency (Martin Zumsande)

Pull request description:

  If the chain advances during a rescan, ScanForWalletTransactions would previously process the new blocks without adjusting `m_last_processed_block`, which would leave the wallet in an inconsistent state temporarily, and could lead to crashes in the GUI reported in #31474.
  Fix this by not rescanning blocks beyond `m_last_processed_block` - for all blocks beyond that height, there will be pending BlockConnected notifications that will process them after the rescan is finished.

  This means that if rescanning was triggered with `cs_wallet` permanently held (`AttachChain`), additional blocks that were connected during the rescan will only be processed with the pending `blockConnected` notifications after the lock is released.
  If rescanning without a permanent `cs_wallet` lock (`RescanFromTime`), additional blocks that were connected during the rescan can be re-processed here because `m_last_processed_block` was already updated by `blockConnected`.

  Fixes #31474

ACKs for top commit:
  psgreco:
    Not that it matters much, but UTACK 4818da809f
  achow101:
    ACK 4818da809f
  furszy:
    utACK 4818da809f

Tree-SHA512: 8e7dbc9e00019aef4f80a11776f3089cd671e0eadd3c548cc6267b5c722433f80339a9b2b338ff9b611863de75ed0a817a845e1668e729b71af70c9038b075af
2025-02-14 14:42:12 -08:00
..
rpc Merge bitcoin/bitcoin#31413: rpc: Remove deprecated dummy alias for listtransactions::label 2025-02-14 13:29:17 -08:00
test Merge bitcoin/bitcoin#31242: wallet, desc spkm: Return SigningProvider only if we have the privkey 2025-01-16 17:30:36 +00:00
bdb.cpp scripted-diff: LogPrint -> LogDebug 2024-08-29 13:49:57 +02:00
bdb.h wallet: introduce active db txn listeners 2024-10-21 08:29:22 -03:00
CMakeLists.txt cmake: Add systemtap-sdt optional package support 2024-08-16 19:27:41 +01:00
coincontrol.cpp
coincontrol.h
coinselection.cpp Remove unused variable assignment 2024-12-13 21:00:07 -06:00
coinselection.h Merge bitcoin/bitcoin#29523: Wallet: Add max_tx_weight to transaction funding options (take 2) 2024-07-17 18:27:59 -04:00
context.cpp
context.h
crypter.cpp refactor: vector -> span in CCrypter 2024-08-28 19:09:51 +02:00
crypter.h refactor: vector -> span in CCrypter 2024-08-28 19:09:51 +02:00
db.cpp Merge bitcoin/bitcoin#29071: refactor: Remove Span operator==, Use std::ranges::equal 2024-08-28 10:34:47 +01:00
db.h wallet: introduce active db txn listeners 2024-10-21 08:29:22 -03:00
dump.cpp
dump.h
external_signer_scriptpubkeyman.cpp
external_signer_scriptpubkeyman.h
feebumper.cpp scripted-diff: Replace strprintf(Untranslated) with Untranslated(strprintf) 2024-12-04 15:09:05 -04:00
feebumper.h
fees.cpp
fees.h
init.cpp scripted-diff: drop config/ subdir for bitcoin-config.h, rename to bitcoin-build-config.h 2024-10-10 12:22:12 +02:00
interfaces.cpp gui: Use wallet name for wallet migration rather than WalletModel 2024-08-13 11:25:38 -04:00
load.cpp refactor: Delay translation of _() literals 2025-01-14 19:21:37 +01:00
load.h
migrate.cpp refactor: Drop unused UCharCast 2025-01-14 19:01:53 +01:00
migrate.h wallet: introduce active db txn listeners 2024-10-21 08:29:22 -03:00
receive.cpp
receive.h
salvage.cpp scripted-diff: Replace strprintf(Untranslated) with Untranslated(strprintf) 2024-12-04 15:09:05 -04:00
salvage.h
scriptpubkeyman.cpp Merge bitcoin/bitcoin#31495: wallet: Utilize IsMine() and CanProvide() in migration to cover edge cases 2025-02-13 12:30:15 -05:00
scriptpubkeyman.h Merge bitcoin/bitcoin#31495: wallet: Utilize IsMine() and CanProvide() in migration to cover edge cases 2025-02-13 12:30:15 -05:00
spend.cpp tracing: only prepare tracepoint args if attached 2024-10-28 14:27:47 +01:00
spend.h
sqlite.cpp scripted-diff: Rename PACKAGE_* variables to CLIENT_* 2024-10-28 12:36:19 +00:00
sqlite.h wallet: introduce active db txn listeners 2024-10-21 08:29:22 -03:00
transaction.cpp
transaction.h
types.h
wallet.cpp Merge bitcoin/bitcoin#31629: wallet: fix rescanning inconsistency 2025-02-14 14:42:12 -08:00
wallet.h Merge bitcoin/bitcoin#31241: wallet: remove BDB dependency from wallet migration benchmark 2025-01-24 18:21:50 -05:00
walletdb.cpp Merge bitcoin/bitcoin#28724: wallet: Cleanup accidental encryption keys in watchonly wallets 2025-01-10 15:29:47 +00:00
walletdb.h Merge bitcoin/bitcoin#28724: wallet: Cleanup accidental encryption keys in watchonly wallets 2025-01-10 15:29:47 +00:00
wallettool.cpp scripted-diff: Rename PACKAGE_* variables to CLIENT_* 2024-10-28 12:36:19 +00:00
wallettool.h
walletutil.cpp descriptors: Change Parse to return vector of descriptors 2024-08-08 12:47:22 -04:00
walletutil.h Merge bitcoin/bitcoin#22838: descriptors: Be able to specify change and receiving in a single descriptor string 2024-08-28 15:56:15 +01:00