Review report

bitcoin-core/gui-qml: PR #990

3 minor findings · 3 suggestions

Findings

Link

[minor] · Wallet snapshots repeat live send-balance queries on the GUI thread

Every applied snapshot re-evaluates synchronous send-balance getters, even with Send hidden, retaining wallet-lock and coin-enumeration work on the GUI thread.

Location: qml/models/walletqmlmodel.cpp:663 (head).

Details and suggested fix

SendCreate remains instantiated in the desktop StackLayout. Its available-balance binding depends on coinCount, which CoinsListModel::update() re-notifies on every walletStateChanged. Each applied snapshot therefore calls availableSendBalanceSatoshi() again. Snapshot application also unconditionally re-notifies sendAmountExhaustsBalance(), whose live query runs when the draft is valid. In the pinned backend, both queries take cs_wallet and compute selected or available inputs. These calls existed at base, but this PR adds recurring snapshot-driven invocations, including eligible one-second polls for unconfirmed request payments and processed-tip refreshes. Return m_wallet_state.available_balance from the default-balance getter. Compute the coin-control-specific predicate on the worker from the captured draft and selected-input policy, and publish it only for the matching draft revision. Do not substitute the unselected cached balance for that predicate. Latency was not measured; the cost depends on wallet size and lock contention.


Link

[minor] · Creating a payment request can overwrite the draft before reporting failure

Clicking Create payment request while a note save is pending can replace the Receive draft and then report that the address is unavailable.

Location: qml/models/walletqmlmodel.cpp:1243 (head).

Details and suggested fix

For an address without a saved request, setCurrentPaymentRequestAddress() clears and repopulates both m_current_payment_request and m_receiving_address before submitting RememberAddress. submitReceiveCommand() then returns false if another receive command is pending. AddressDetails can already have submitted a label save from editingFinished; it makes the note field read-only but leaves Create payment request enabled. Clicking during that pending interval closes the popup and displays “This address is no longer available,” although the draft has already been replaced using the cached, pre-save label. At base, the synchronous persistence path returned true after this mutation. Check the pending state before changing either request, and disable the create action while the label save is pending. Retrying after completion can succeed. The failure requires that overlap; direct-click focus-event ordering was not exercised in a rendered UI.


Link

[minor] · Unchanged wallet snapshots repeatedly reset address and coin editors

Eligible one-second polls for unconfirmed request payments reset unchanged address and coin lists, rebuilding delegates instead of preserving editor focus and cursor state.

Location: qml/models/addresslistmodel.cpp:65 (head).

Details and suggested fix

applyWalletState() always emits walletStateChanged, which now directly refreshes both lists. AddressListModel::rebuild() always resets the model, and the coin update resets it twice. While a saved request has an active unconfirmed payment, each eligible one-second poll publishes a full snapshot even if nothing changed; processed-tip changes also trigger snapshots. At base, these list refreshes followed address, balance or transaction notifications instead. The Receive-category ListView disables delegate reuse, so resets recreate its inline note editors. pendingNotesByAddress preserves their text, not their focus or cursor. Coin selections survive because they reside in WalletQmlModel. Compare each list's derived entries and skip the reset when they are unchanged, while retaining walletStateChanged for other consumers. Add a QML check that an editor remains focused across an unchanged snapshot. Polls skip overlapping work, and destruction-time focus and editingFinished behavior were not exercised.


Optional improvements

Link

[suggestion] · A pending request payment makes each eligible poll rescan the whole wallet

An unchanged unconfirmed request payment repeatedly reloads unrelated wallet history on the shared executor; targeted status checks would avoid that work.

Location: qml/models/walletstatesnapshot.cpp:215 (head).

Details and suggested fix

poll() bypasses the processed-tip check whenever m_unconfirmed_payments is true and calls the full snapshot reader. Each eligible one-second tick reloads balances, addresses, coins, locked coins, receive requests and every wallet transaction. Base instead queried details only for the captured unconfirmed payment txids. Poll guards prevent overlapping polls, but a scan already running still delays receive commands and fee previews on the same serial executor. Record the unconfirmed request txids and poll their status, falling back to a full read when it changes. Retain full reads for initial load, notifications and processed-tip changes, including maturity reconciliation. The targeted path must still detect a payment leaving the mempool without a receiver notification, update current totals and retain historical address-use restrictions. A call-count test could establish that unchanged pending payments no longer enumerate the wallet. Latency depends on wallet size and was not measured.


Link

[suggestion] · Unrelated wallet notifications suppress payment-request sharing

A label or lock-state notification hides an otherwise-shareable saved request's QR and disables sharing until the full wallet snapshot completes.

Location: qml/models/walletqmlmodel.h:180 (head).

Details and suggested fix

receiveRequestReconciliationPending() now includes every scheduled or running wallet-state refresh. Status, address-book, transaction and capability notifications all schedule the same refresh and notify this property immediately. PaymentRequestCard.sharing depends on it, so even an unrelated label or lock-state change clears the QR and disables Copy/Save for the full read. This is conservative, but broader than payment reconciliation requires. Track refresh causes and keep the sharing gate for initial load and transaction/payment reconciliation rather than non-payment status, label and capability refreshes. Preserve that distinction when requests coalesce. Do not simply keep sharing enabled during transaction-driven scans: the saved unpaid flag may be stale, and the transaction notification supplies only a txid. The current behavior protects against sharing an observed address; the recommendation reduces unnecessary suppression without removing that protection. Its duration was not measured.


Link

[suggestion] · Save and EnsureAddress repeat full scans and keep settings I/O under cs_wallet

In-process Save and EnsureAddress paths discard a full pre-read and retain cs_wallet during preference writes, adding avoidable scans and lock hold time.

Location: qml/models/walletstatesnapshot.cpp:271 (head).

Details and suggested fix

When these commands reach locked validation with an in-process wallet, execute() first reads the whole snapshot, then takes cs_wallet and replaces it with another full read. finish() performs a third read after releasing the lock. EnsureAddress also calls settings.sync() and persists the address type through PersistSettings before unlocking; Save synchronizes QSettings there when reserving the receiving address. Keep the lock around observed-address validation and wallet request persistence, since that atomicity prevents reuse races. Skip the redundant pre-read for these raw-wallet paths and perform preference-file writes after releasing the lock, preserving their failure reporting and relock handling. This removes one full scan and avoids making wallet processing or RPCs wait for preference I/O. Other command kinds do not take this second-read path, and Save does not always write preferences or generate an address. Lock-hold time was not measured.


Coverage details