7 minor findings · 4 suggestions
Earlier concerns neither republished nor resolved: 4 suggestions. See the Run archive for their assessments.
Findings
[minor] · Signing reads the encryption state without cs_wallet
Worker signing can race GUI encryption when reading Core's master-key map without cs_wallet; this narrow source-established race has not produced an observed crash.
Location: qml/models/signverifymessagemodel.cpp:76 (head).
Details and suggested fix
Start signing on an unencrypted wallet, leave the page while the task waits, then set a wallet password. clear() only invalidates the completion, so the queued worker still calls wallet->isCrypted(). In the pinned Core, this calls HasEncryptionKeys(), which reads mapMasterKeys without locking, while GUI-thread EncryptWallet() inserts into that map under cs_wallet. The unlock session does not protect the read: signing checks encryption before acquiring it, and WalletQmlModel::encryptWallet() never acquires it. Before this migration both GUI actions ran on the GUI thread. Share the existing cs_wallet-protected ReadSecurityState() logic with signing and use it for both security-state checks, without holding cs_wallet while acquiring the session.
[minor] · A pending coin lock leaves the coin available to Send preparation
If Review runs before a selected coin's lock task completes, the prepared transaction can still include that coin; this timing-dependent overlap has not been observed in use.
Location: qml/models/walletqmlmodel.cpp:2515 (head).
Details and suggested fix
setCoinsLocked() sets m_coin_lock_pending but only unselects the outputs in its completion handler. A user can lock a selected coin in Coins, return to an already valid Send draft, and prepare it while the command waits on the serial executor. Neither the Review button nor prepareTransactionInternal() checks the pending lock, and Core's FetchSelectedInputs() does not reject locked preselected outpoints. Later unselection does not invalidate the prepared transaction or close its review. Base unselected the coin synchronously when locking succeeded. Disable Review and reject preparation while a coin-lock command is pending.
[minor] · The lock checkpoint can hide a stale available balance
An RPC coin-lock change between the balance and lock-set reads can leave Send's cached balance stale until another refresh trigger; this interleaving has not been reproduced.
Location: qml/models/walletstatesnapshot.cpp:173 (head).
Details and suggested fix
read() obtains available_balance before calling listLockedCoins() and assigning m_locked_coins, without an enclosing cs_wallet critical section on ordinary refreshes. If lockunspent changes the locks between those calls, the snapshot pairs the old balance with the new checkpoint. Subsequent polls see no lock-set difference and can return no snapshot indefinitely on an idle node. This can block an affordable draft after an unlock or leave an unaffordable draft enabled after a lock; transaction preparation still checks the backend balance again. Read the lock checkpoint before the balance so a later change remains detectable on the next poll.
[minor] · A delayed signing password prompt can open over Verify
Switching to Verify while signing is pending leaves the page visible, so a delayed needs-unlock result opens the signing password prompt over the verification form.
Location: qml/pages/wallet/SignVerifyMessage.qml:84 (head).
Details and suggested fix
On an encrypted, locked wallet, submit Sign and switch to Verify before the worker replies. The SegmentedPicker remains enabled because only the StackLayout is disabled during signing. onSigningFinished() checks root.visible but not selectedMode, so it opens signPassphrasePopup in Verify. Submitting that popup signs the hidden Sign form's address and message. Disable the mode picker while signing is pending so the completion remains associated with the displayed mode.
[minor] · Automatic Receive preparation can overwrite the type used by an unlock retry
An automatic refresh overlapping a typed address preparation can overwrite the type used by its password retry; this source-traced overlap has not been observed.
Location: qml/pages/wallet/ReceivePage.qml:36 (head).
Details and suggested fix
ensureReceivingAddress() assigns pendingNextAddress and pendingAddressType before checking receiveOperationPending. Although user controls are disabled during the operation, automatic callers such as onVisibleChanged can still replace the pending explicit type with "" or the draft's type. If the explicit preparation then needs unlocking, onSubmitted uses those overwritten properties. The failed derivation has not saved the chosen preference, so the retry can return an address of the previously saved type instead. Keep the submitted user intent separately from automatic deferred preparation, and use that intent for the password retry.
[minor] · A busy unlock session leaves Speed up in Failed
A transient busy-session error disables fee-bump confirmation until the user closes and reopens the Speed up overlay, even after the other operation finishes.
Location: qml/models/bumptransactionmodel.cpp:160 (head).
Details and suggested fix
When another encrypted-wallet operation holds the unlock session, confirmFeeBumpInternal() calls setError(), which changes the state to Failed. Subsequent confirmation calls reject every state except NeedsConfirmation, and the Update button requires that same state. Retrying through an already open password popup also hits the guard. Only reopening the overlay prepares the bump again. Keep NeedsConfirmation for this recoverable busy result and expose its error text in that state, allowing the user to retry after the session becomes available.
[minor] · A successful deletion remains cached when its follow-up read fails
If the snapshot read after deletion throws, completion reports success but leaves the deleted request listed and reopenable until a later refresh succeeds.
Location: qml/models/walletqmlmodel.cpp:802 (head).
Details and suggested fix
The Remove branch records only result.success. finish() preserves that success when the final read() throws, but submitReceiveCommand() handles the missing snapshot only by restoring saved_entry, setting the refresh error, and requesting another read. It never removes the deleted entry. loadSavedRequest() still looks up that cached row, so it can reopen a request whose later update or deletion fails in the backend. Return the removed request ID and apply removeByRequestId() in the successful no-snapshot path. Add a deletion counterpart to receiveSaveSurvivesRefreshFailure().
Optional improvements
[suggestion] · Successful snapshot balance reads are immediately repeated
When tryGetBalances() succeeds, read() discards its balance and computes it again, including while Save and EnsureAddress hold cs_wallet.
Location: qml/models/walletstatesnapshot.cpp:141 (head).
Details and suggested fix
In the pinned Core, tryGetBalances() records the block hash and calls GetBalance(), storing m_mine_trusted in balances.balance. The following getBalance() call repeats that computation for the same field. Save and EnsureAddress already hold the recursive cs_wallet, so both passes occur within their critical section. Assign state.balance from balances.balance on success and call getBalance() only when the try-lock fails. The cost was not measured, and cached per-transaction credits may make this pass small relative to the other snapshot scans.
[suggestion] · Small Receive commands perform an unnecessary full pre-scan
RememberAddress, Label, Remove, and AddressType perform a full wallet snapshot before acting, although they need none or only a small part of that data.
Location: qml/models/walletstatesnapshot.cpp:328 (head).
Details and suggested fix
execute() unconditionally calls read(node) before dispatching, then takes another snapshot in finish(). The pre-read lists addresses and coins and walks wallet transactions, but RememberAddress only writes settings, Label and Remove only need saved requests, and AddressType only needs capabilities. Every inline label edit therefore performs two full scans and keeps receiveOperationPending set throughout, disabling Receive controls. Skip the pre-read for RememberAddress and use narrow request/capability queries for these other branches, retaining the consistent pre-read for Save and EnsureAddress and the final snapshot. The latency saving has not been measured.
[suggestion] · Every applied snapshot clears Send fees and disables Review
For a valid Send draft, each snapshot disables Review until re-estimation finishes, potentially repeating during block catch-up; the duration and change in trigger frequency relative to base are unverified.
Location: qml/models/walletqmlmodel.cpp:734 (head).
Details and suggested fix
applyWalletState() always calls scheduleFeeEstimates(), which clears the previews, invalidates in-flight results, sets feeEstimatePending, and restarts the debounce. The Review button requires that pending flag to be false. Since polling takes a new snapshot when the wallet's processed block changes, catch-up can repeatedly interrupt an otherwise unchanged draft, with estimates queued behind wallet reads. Keep the last preview and Review availability during background re-estimation, separately from invalidation caused by user edits. Block-driven re-estimation can still run, and prepareTransactionInternal() computes the actual transaction and fee before opening review.
[suggestion] · Failed batch coin-lock operations lose the marked selection
As at base, a failed batch lock or unlock loses the user's marks, requiring every coin to be marked again before retrying.
Location: qml/components/CoinsList.qml:64 (head).
Details and suggested fix
lockMarked() clears markedIds as soon as setCoinsLocked() returns true, which now means only that the command was submitted. A later worker failure, including a database-write failure, exposes lockOperationError but does not restore the submitted batch. Head already preserves the marks on immediate rejection. Retain the submitted IDs until completion and restore them on failure, clearing them only after a successful outcome.
Earlier concerns
Earlier reports raised these, with the titles and severities shown there. This review neither republished nor resolved them.
- [suggestion]: Unused label aliases contradict their documented contracts (earlier report)
- [suggestion]: Receive holds
cs_walletand the unlock session across a full scan (earlier report) - [suggestion]: The wallet-refactor commit adds an unexplained QML package (earlier report)
- [suggestion]: The settings test wallet exposes a different completion contract (earlier report)
Background
Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.
Documented decisions
Moving execution off-thread does not by itself supply a complete request lifecycle. Issue #1054 identified silent rejection and discarded completions as causes of stuck pending states, and identified missing request identity, cancellation, lifetime rules, and replayable drain observation. The follow-up #1109 deliberately scoped itself to executor primitives rather than model migrations and generic helpers.
This is the rationale behind migrating wallet commands and queries to explicit outcomes. The head contract distinguishes skipping queued work from discarding a running result, never interrupts running work, and drains accepted work and worker cleanup. These distinctions separate obsolete queries from operations whose effects may already have occurred.
Temporary unlocking must preserve the original wallet lock state and prevent another operation from interfering before relocking. Earlier GUI requirements stated this explicitly. Separately, Core introduced its relock mutex to prevent timeout-driven relocking from deleting key material while a rescan still needed it, including for keypool replenishment.
Worker-based signing and Receive commands interact with the same wallet security state as synchronous GUI operations. The new WalletUnlockSession addresses coordination across those operations, while the pinned Qt UnlockContext demonstrates the pre-existing scoped-unlock/relock convention. Core's relock history explains the backend constraint, not the correctness of Qt callback lifetimes.
Completing a persistent operation and presenting its result are separate obligations. Earlier Receive requirements say successful saves and deletions must update the originating wallet even after switching away, but must not clear another wallet's draft, close a newer dialog opening, or present errors in an unrelated view. A reopened instance of the same request also counts as a new opening.
This explains the wallet/request/revision and dialog-opening identities around asynchronous completions. At head, command results retain their original backend and guarded request reference, while request revisions govern whether the draft still matches. The historical concern is not merely dangling pointers: a live, reused view can represent a different user action.
A request's current payment status and its historical address-use restriction deliberately answer different questions. Issue #1042 documented a payment replaced by a transaction paying elsewhere: the received amount became zero, but the permanent observed-payment flag kept the success badge green. The requested distinction was to update the displayed status while retaining sharing and reuse restrictions.
This directly explains why the badge now follows the current received amount while the backend preserves observed addresses and saved payment_received history. A disappearing or replaced payment does not make the address unused again. The change concerns wallet presentation and request policy, not a new transaction-finality rule.
Address labels and private payment-request notes are linked persistent data, so an old UI draft can overwrite a newer change made through another view. Issue #971 required stale results not to overwrite changed or cleared drafts and documented a no-op inline edit later restoring an obsolete label and request note.
This explains the distinction between an actual note edit and an untouched prefill. The head backend can obtain the current address label when saving a prefilled request, and the GUI follows updated labels only while the prefill remains untouched. The design constraint is preserving editing intent across linked representations.
Asynchronous exports must preserve artifact correctness as well as responsiveness. The CSV issue required one consistent filtered view, including display units, without mixing rows after view changes. The Receive issue retained Qt image capture on its required thread while moving file work away; a later report showed that an oversized QR payload could appear ready yet export a blank image without an error.
These requirements explain why CSV collection, formatting and writing have distinct responsibilities, and why QR encodeability is separate from image readiness and file-save success. The changed export and QR-action paths address different failure boundaries; successful file creation alone does not establish a usable payment artifact.
Source 1 · Source 2 · Source 3
Ralph's inferences
The snapshot boundary trades some freshness for cheap, repeatable GUI reads and an owned cross-thread handoff. Publishing a snapshot as one model update is distinct from making every QML getter perform a backend round trip.
The base balance getters directly queried the wallet. At head, WalletStateSnapshot contains owned values, getters read cached balances, and applyWalletState emits the relevant model notifications. This inference explains the presentation boundary without assuming the entire backend scan is one atomic wallet transaction.
The periodic poll serves as reconciliation for changes that notifications alone do not cover, rather than requiring a full wallet rebuild on every tick.
The head backend checks the wallet's processed block, externally changed coin locks, and outstanding unconfirmed-payment status before deciding to reread. Its comments identify maturity, lockunspent, and mempool eviction as notification gaps. This explains the implemented fallback; the historical reasons those notifications are absent were not independently established.
Unresolved disagreements
The inspected 2017 record did not resolve whether the CPU savings of notification-driven balance updates sufficiently addressed the risk of GUI hangs under lock contention. Jonas Schnelli reported substantial profiling improvements; Wladimir van der Laan raised worst-case blocking concerns; Russell Yanofsky explicitly questioned whether the measurements answered those concerns. The proposal was later closed 'for now' without an explanatory resolution in the retrieved comments.
This distinguishes average computational cost from responsiveness under contention. It supplies historical context for combining worker execution, caching, and coalescing, but is neither an objection to this PR nor evidence that its implementation satisfies either objective.