mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
WIP: Move wallet overview, activity, address and receive work off the GUI thread #990
No reviewers
Labels
No labels
Android
Bug
Build system
Design suggestion
Doc
Needs design review
Needs rebase
Stage
UX
Up for grabs
Upstream
Wallet
duplicate
enhancement
good first issue
question
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml!990
Loading…
Reference in a new issue
No description provided.
Delete branch "pr/qt6-async-05-wallet-state"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Wallet balance queries, address scans and receive actions can block the GUI. Run backend reads and writes on workers and let GUI getters read cached results. Combine refresh requests and ignore stale replies.
Move label changes, message signing, payment reconciliation, CSV exports and QR file saves into background work. Show pending and failure states and preserve wallet lock state.
Regression tests cover cached reads, stale replies, failed writes, wallet closure and coin-lock changes without notifications.
Depends on #985. This draft targets
qt6, so its diff includes the earlier PRs. The wallet feature and review fixes follow #985 in the stack.The payment-status badge now follows the current received amount, including a payment replaced away to zero; historical sharing/edit restrictions remain in force. Regression coverage exercises payment, cancellation and renewed payment.
Validation at
14ef21e14a5c: full build, seven relevant non-QML CTest groups and startup/shutdown/onboarding functional checks pass. Matching LLVM 22/Bitcoin-plugin checks pass on all four inherited changed C++ files. QML sources and fixtures match3b574e1b, where all eight CTest groups, 704 QML cases and six wallet/address/Receive functional suites passed. The wallet feature and review-fix patches are unchanged.Unchanged RequestPayment sources have 61 ASan/LSan/UBSan/integer and 61 TSan passes from the preceding
8af78885validation. The new inherited options/preparation tests pass 32 strict ASan/LSan/UBSan/integer and 32 TSan cases at #981. Full sanitizer validation of this combined application is not established; #981 records an intermittent supplemental ASAN SIGINT deadline failure.The standalone checkout lacks the requested top-level CI drivers. Configured rootless Docker is available; Core-only fallback attempts are partial and do not validate parent GUI-QML. The IPC-enabled standalone GUI uses a local node factory; actual Core multiprocess IPC lifecycle remains untested and interface_gui.py is absent. Current CI.
Fixes #968
Fixes #969
Fixes #971
Fixes #972
Fixes #1042
Latest review fixes and validation
Rebased onto current
qt6and updated to Core's wallet transaction API. Unchanged unconfirmed request payments now poll only their status, avoiding full wallet scans and model resets; eviction still refreshes the request without a wallet notification. Andrea's dialog-opening lifetime fix is included with authorship preserved, so delayed deletion cannot close a subsequently opened request.Validation at
389e2f1dac: full Release build; 134 wallet-model and 75 related address/coins/request-history/activity tests pass. RequestPayment QML has 60 passes, including both new delayed-deletion cases, and four amount-validation failures also reproduced on rebased pre-fix sources (58 passes, four failures) under Qt 6.11.2. These baseline failures remain; no sanitizer result is claimed for this revision.Switching wallets away and back during a save clears the draft, so this skips clearing the address even though the request was saved. The next request can reuse it.
I reproduced this in a model test with a delayed backend: one 5,000-sat payment showed as received on both requests.
rebased
rebased
Returning the cached lock state here makes a quick Unlock → Lock silently skip the second command. CoinsListModel::setCoinsLocked() still sees the old locked row and decides there's nothing to do, leaving the coin unlocked in Core.
Reproduced through the enabled GUI buttons with a larger regtest wallet; the same sequence passed on qt6. We should send the requested lock operation to Core even when the cached row already matches it.
SendRecipient uses this value to validate amounts, but the snapshot isn't refreshed when a coinbase matures without another wallet notification.
On regtest, Core reported 50 BTC trusted while entering a fresh 1 BTC amount left Review disabled. Setting an address label triggered a refresh and made it work. qt6 branch accepts that fresh amount despite the stale display.
We need to refresh after the wallet processes a new block before relying on this cache for amount validation.
The controller can publish this model before the queued unload handler is connected. An unload in that interval loses the notification, leaving the GUI holding the wallet and unloadwallet waiting until it's manually closed.
Reproduced by delaying subscription setup. Ordinary repetitions didn't hit it. There's an earlier load/handoff race too, but this adds a window after publication.
We should connect the unload handler before publishing the model; connecting that signal doesn't require a wallet read.
If this refresh throws after saving, we tell the user the operation failed even though the request is already in Activity. Clicking Save again can create a duplicate because the draft never received its saved ID.
Reproduced with an injected refresh failure. We should keep the saved ID and report the refresh error separately so retrying doesn’t create another request.
Opened #996 with reproductions for the existing Send validation problems. This PR fixes the ordinary incoming-payment case: an existing draft becomes valid when the payment confirms.
The maturity case still needs a refresh. Core has 50 BTC spendable, but the GUI shows zero and rejects a 1 BTC amount, including one first entered after maturity. Changing an address label refreshes the balance and enables Review. We also need to refresh when funds mature without another transaction involving the wallet.
Tested
7e432cefdc77; the relevant wallet/recipient code is unchanged in the current2f8b6d43f1cerebase.Added two reproductions to the issues this PR closes:
Both reproduce on
qt6, so these are existing gaps. We should include them in this PR’s acceptance checks: refresh capabilities after imports, and check saved requests before reoffering an address from a restored preference.This is an edge case but, this can silently discard a corrected note when the wallet is busy. The second save is rejected while the first is pending, then this completion restores the first note and clears the error.
Reproduced on macOS with a fresh regtest wallet: start keypoolrefill 20000 for the same wallet, then submit “First” followed by “Second” in Address details before the refill finishes. Used automated Qt keystrokes at 250 ms per character, with 500 ms between edits.
A possible solution is to make both note editors read-only while labelChangePending, show “Saving…”, and guard duplicate submissions.
This skips address preparation without retrying when the pending operation finishes. Reproduced with a fresh regtest wallet, before visiting Receive:
keypoolrefill 20000and save a note while it's running.Receive stays at “Preparing address” after the save completes, with no address or QR. Switching away and back recovers. The parent works, and the note-editor fix still reproduces this. We should resume the skipped preparation once the pending operation finishes.
Reproduced a Legacy request turning into a Taproot request when using “Request again.” With the default Taproot preference:
getnewaddress "" legacy.The repeat uses Taproot on this branch; the parent preserves Legacy. We're dropping
pendingTypehere. We should preserve it through the retry so repeating a request keeps the address format the user chose.Related: #1042 tracks the request still saying “Payment received” after its only payment is replaced away. This reproduces on
qt6independently of this PR;0d9d14ce7061also still uses the permanent observed-payment flag for the status label.🟠 Minor · Wallet snapshots re-run synchronous send-balance queries
Snapshot notifications repeat synchronous balance queries from the always-instantiated Send page, leaving GUI-thread wallet locking and coin enumeration despite the worker cache.
Location:
qml/models/walletqmlmodel.cpp:663(head).🟠 Minor · Unchanged payment polls reset editable address rows
While a saved request has an unconfirmed mempool payment, unchanged snapshots repeatedly reset the address and coin models, recreating editable address delegates and potentially interrupting label editing.
Location:
qml/models/addresslistmodel.cpp:65(head).🔵 Suggestion · Pending request payments trigger full-wallet polling
An unchanged unconfirmed payment causes each eligible one-second poll to enumerate the whole wallet on the shared serial worker, instead of checking only pending transaction IDs as base did.
Location:
qml/models/walletstatesnapshot.cpp:215(head).Review coverage was incomplete.
Reviewed:
18e374fcb804· Full review report · Previous reportspermalink
Verified at
8af78885e. Saving retires the receiving address even if the draft or selected wallet changes before completion.receiveSaveRetiresAddressAfterDraftChangescovers delayed-save cases.Verified at
8af78885e. The worker applies the requested lock/unlock operation, and the GUI keeps it pending until the resulting snapshot arrives.staleCachedStateDoesNotSuppressRequestscovers stale cached lock and unlock states.Verified at
8af78885e. Wallet polling compares the processed block, retries a busy wallet, and refreshes cached balances after maturity.processedBlockRefreshesBalanceWithoutTransactionNotificationcovers existing and newly entered amounts; the wallet-state GUI test also passes.Verified at
8af78885e. The unload handler is connected before background subscriptions start.unloadIsConnectedBeforeBackgroundSubscriptionsblocks setup and checks that unload reaches the model.Verified at
8af78885e. The save result retains its saved ID independently of the follow-up refresh.receiveSaveSurvivesRefreshFailureverifies that retrying does not create another request.Verified at
8af78885e. Both note editors become read-only while saving, show Saving…, and reject duplicate submissions.test_addressList_blocks_edits_while_savingcovers this behavior.Verified at
8af78885e. Request-again retains the selected address type through its pending retry.test_request_again_prefills_without_savingchecks Legacy and Taproot against a different default.Verified at
8af78885e. Receive retries address preparation when the pending operation finishes.test_address_preparation_resumes_after_pending_operationcovers recovery without switching pages.Restacked onto the latest #985/#981 fixes at
14ef21e14a. All eight original inline threads remain addressed and resolved, with regression tests named in their replies. Descriptor import and restored receiving preferences remain covered. The #1042 badge fix still follows current received amount through payment, cancellation and renewed payment while retaining historical restrictions.Validation at
14ef21e14a5c: full build, seven relevant non-QML CTest groups and startup/shutdown/onboarding functional checks pass. Matching LLVM 22/Bitcoin-plugin checks pass on all four inherited changed C++ files. QML sources and fixtures match3b574e1b, where all eight CTest groups, 704 QML cases and six wallet/address/Receive functional suites passed. The wallet feature and review-fix patches are unchanged.Unchanged RequestPayment sources have 61 ASan/LSan/UBSan/integer and 61 TSan passes from the preceding
8af78885validation. The new inherited options/preparation tests pass 32 strict ASan/LSan/UBSan/integer and 32 TSan cases at #981. Full sanitizer validation of this combined application is not established; #981 records an intermittent supplemental ASAN SIGINT deadline failure.The standalone checkout lacks the requested top-level CI drivers. Configured rootless Docker is available; Core-only fallback attempts are partial and do not validate parent GUI-QML. The IPC-enabled standalone GUI uses a local node factory; actual Core multiprocess IPC lifecycle remains untested and interface_gui.py is absent. Current CI.
CI follow-up in
e410bffc11: the proxy-draft test called an external wallet shortcut that clears cached settings pages, then used stale page/button references. It now uses the normal Settings navigation, real key/mouse input, and retained-page identity/depth checks before Save. All draft and persisted-address assertions remain. Restacked onto the test-only fix. Fresh Qt 6.2 and Qt 6.8 builds each pass all 704 QML cases. Own wallet patches and production sources remain unchanged. Both fork-push and upstream-PR workflows are tracked. Fork CI.Hosted CI confirmation (2026-11-02 19:49 UTC): the current fork head passes Qt 6.2, Qt 6.4, Qt 6.10 and GUI functional tests. All twelve Linux matrix/GUI jobs across #981, #985 and #990 are green. Upstream PR-triggered runs remain queued. macOS runner-capacity failures were retried; macOS validation remains pending. The earlier validation qualifications above are unchanged.
Additional CI follow-up in
5280e52567: the inherited custom-fee test required exact equality with the final signed transaction size. Pinned Core reproduced a 141-sat fee with a 140-vB transaction after a shorter ECDSA signature, so this was a test defect. The test now uses Core's bounded fee assertion and retains the wallet-minimum override and relay-minimum rejection checks. Shared-path validation passes eleven fee-boundary controls and both instrumented GUI fee scenarios. Only the Python test changed in this follow-up; earlier sanitizer/driver/IPC qualifications remain unchanged. New hosted checks are queued or running on this revision; no result is claimed yet.The delayed-deletion case requested in #972 still reproduces with this PR's current QML at
1cc00c240d94.I rechecked this using the current payment-request card and modal in a focused QML test with controlled backend completion. The modal closes while displaying B; reopening B preserves its amount and message. The earlier native reproduction used a busy disposable wallet to create the overlap. This is a dialog-lifetime bug, not deletion of the wrong request.
pendingOperationandpendingRequestIdsurvive closing the modal. Both openings reuse the same detail object, so changing its request ID does not triggeronRequestChanged. A's completion then emitsdeleted, and the modal closes whichever request it is showing.Please tie the UI completion to the opening that started the operation, while allowing A's deletion to finish in its original wallet. Closing and reopening the same request should also count as a new opening. The regression case should keep B open after A finishes, as #972 already requires.
I sent a fix for the delayed-deletion case to the branch: johnny9/gui-qml#5. Each opening of the request modal is numbered, so a delete only closes the opening that started it; closing and reopening the same request counts as a new opening. A regression test covers both a different request and the same one reopened.
I re-tested
1cc00c240d94on an optimised build against its base6e54a48ab571. One problem remains, and three things are better.Remaining: the wallet state is re-read and re-applied every second while a payment to a saved request is unconfirmed
To reproduce:
Until the payment confirms, the Addresses list resets once a second:
The label editor is destroyed 0.3 to 0.8 s after typing starts. The partial text is saved as the label, and the next Space opens Address details. The reset count is the same on a 30-transaction wallet, so this does not depend on wallet size.
On this PR the other states are quiet: no resets when idle, two at the arrival of an ordinary unconfirmed payment and none after, and none once the request payment confirms. Label typing loses no keys in those states.
WalletStateBackend::pollskips its processed-block comparison whilem_unconfirmed_paymentsis set (walletstatesnapshot.cpp#L209-L220), so the 1 s timer (walletqmlmodel.cpp#L605-L607) runs a fullread()every cycle.applyWalletStatethen applies every snapshot and emitswalletStateChangedwithout comparing it with the previous one (walletqmlmodel.cpp#L658-L690). Applying a snapshot only when it differs, or polling only the status of the unconfirmed payments, would keep the lists stable.Better than base
A smoke run of nine flows passed on this PR, offscreen and native: start with two wallets, send, receive, a new block, request create, edit and delete, an inline label, wallet switching during traffic, closing a wallet with Activity open, and quit. Quitting with a refresh in flight on the large wallet exited cleanly 9 of 9 times.
Tested on macOS / Qt 6.9, isolated regtest, RelWithDebInfo builds of both commits, offscreen and native. Each configuration ran once. Stalls were measured as the round trip of a bridge read sent every 50 ms, so stalls under about 0.1 s are not resolved. Typing and clicks went through the test bridge. The preference fault was applied to the INI store selected by the test switch, not the macOS preference store, and the kill route ran offscreen only.
🟠 Minor · Applied snapshots still trigger GUI-thread Send balance scans
Applied snapshots now re-evaluate the pre-existing synchronous Send balance getters, including while Send is hidden; the available-balance query and valid-draft exhaustion check still scan wallet data and can wait on
cs_wallet.Location: qml/models/walletqmlmodel.cpp:666 (head).
🟠 Minor · Temporary worker unlocks race with GUI transaction signing
Overlapping worker signing or passphrase receive work with GUI transaction signing can let one operation relock the wallet after another skips its password prompt; this narrow race has not been reproduced deterministically.
Location: qml/models/signverifymessagemodel.cpp:89 (head).
🟠 Minor · A rejected Addresses action still replaces the Receive draft
Creating a payment request from Addresses while a label save is pending reports the address unavailable, but first clears and replaces the Receive draft, leaving state changed despite the rejected action.
Location: qml/models/walletqmlmodel.cpp:1252 (head).
🔵 Suggestion · Receive commands repeat full scans and retain a broad wallet lock
Successful Save/EnsureAddress commands perform three full wallet reads; EnsureAddress also holds
cs_walletthrough settings I/O, extending contention with GUI wallet calls, although stall durations have not been measured.Location: qml/models/walletstatesnapshot.cpp:286 (head).
Review coverage was incomplete.
Reviewed:
389e2f1dac5c· Review reportFor information, since this touches the same models: I ran
389e2f1dac5cagainst its base for the two macOS crashes, #1116 and #1119. I don't expect this PR to fix either, and it doesn't claim to.#1119 still occurs on both pages. Both lists now refresh on one coalesced signal, but a notification arriving during a read starts a second read and every read ends in a full reset, so two resets one read apart remain. In alternating launches it crashed at least as often as the base (Addresses 36 of 40 against 8 of 28, View coins 8 of 20 against 3 of 20; the base ran below its usual rate, so I can't say it is worse).
#1116 is unaffected, as expected: the teardown code isn't touched. One side benefit: the freeze after a payment on a 5,000-transaction wallet drops from about 4.4 s to about 0.5 s, which removes the large-wallet variant of that crash (0 of 5 against 3 of 3, offscreen).
Details are on the two issues.