qml: Handle payment URIs passed on the command line

bitcoin-core/gui-qml: PR #934

4 minor findings · 2 suggestions

Findings

Link

[minor] · An interrupted payment request is not retried when Send returns

With animated closing, leaving Send during a command-line request review can leave it queued even after returning to Send; the native macOS menu route was not exercised.

Location: qml/pages/wallet/SendCreate.qml:790 (head).

Details and suggested fix

Hiding Send calls interruptPaymentRequest(), which clears m_incomingPaymentRequest and schedules redelivery without removing the queue head. WalletView.pageHidden() also closes the review. While its exit transition runs, canAcceptPaymentRequest() rejects the retry because the popup remains visible. When onClosed eventually runs, finishIncomingPaymentRequest("resolved") returns immediately because interruption already cleared the flag. Unlike the overwrite popup, this handler emits no paymentRequestAcceptable, and showing Send again only checks the clipboard. An unrelated wallet or availability event can later retry the request and unexpectedly select Send. Emit availability when the review closes and when Send becomes visible, and gate retries of interrupted deliveries on Send being shown. Add an animated integration test that leaves the review, returns to Send, and checks that the retained request reopens exactly once; the existing standalone hiding test only checks the interruption outcome.


Link

[minor] · An accepted request can be applied after being reported interrupted

Hiding Send or deselecting its wallet after Apply but before closed can both update the draft and retain the request for redelivery; no reliable production sequence for this animation-window timing was identified.

Location: qml/pages/wallet/SendCreate.qml:787 (head).

Details and suggested fix

Apply sets accepted = true and starts closing, but the form changes only in onClosed. If Send becomes hidden or its retained WalletView becomes inactive during the exit animation, interruption reports the request as "interrupted". Neither path clears acceptance or the pending parsed request, so onClosed still applies it to the old wallet's draft. Its later completion call does nothing because the incoming flag is already false, while the queue keeps the request for review again, potentially in another selected wallet. Make application conditional on the delivery still being active, so an already-interrupted delivery cannot update the draft. Add an animated-mode test that interrupts between Apply and closed. Native-menu navigation and asynchronous wallet loading are plausible triggers for this short window; another application still requires another explicit Apply, and sending still requires transaction review.


Link

[minor] · The availability check ignores an open coin-selection session

A delivery during coin selection would open the request review over its provisional session because canAcceptPaymentRequest() ignores coinSelectionPopup; no ordinary current production sequence triggering that delivery was identified.

Location: qml/pages/wallet/SendCreate.qml:149 (head).

Details and suggested fix

root.depth === 1 does not detect coin selection: the Select coins button opens SendCoinSelection directly, and that component is a DialogPopup, not a pushed page. Its onAboutToShow starts provisional selection and captures wallet.sendTotalSatoshi as the fallback target. Both delivery checks consequently accept a request while that session owns the form, allowing Apply to change the recipient or amount underneath it. Include !coinSelectionPopup.visible in the predicate and emit paymentRequestAcceptable when coin selection closes. Requests currently enter only at startup, so this is a conditional form-ownership defect rather than an established routine startup collision.


Link

[minor] · The new -h recovery advice does not display help

The new loose-token error recommends bitcoin-core-app -h, but the app's pre-existing lack of help handling means the suggested recovery starts GUI initialization instead of listing options.

Location: qml/bitcoin.cpp:507 (head).

Details and suggested fix

SetupServerArgs() calls SetupHelpOptions(), which registers -h as an accepted hidden alias. Registration does not display help: the caller must handle HelpRequested() or generate a help message. The QML application does neither and continues from parsing into settings, model creation, and onboarding. Drop the -h reference from this diagnostic unless help handling is added.


Optional improvements

Link

[suggestion] · Abandoning wallet opening leaves the queued request without a notice

Abandoning Open wallet or Create wallet leaves the request queued but removes its only pending-request notice, so users cannot tell it is still waiting.

Location: qml/pages/MainWindow.qml:109 (head).

Details and suggested fix

Both actions close the notice without advancing the queue, leaving paymentUriAnnounced set. Closing wallet creation retries delivery, but announcePendingPaymentUri() then returns early; cancelling wallet selection does not reset the flag either. A later wallet load still delivers the request, but until then it has no visible reminder, and the in-memory queue disappears on quit. Keep suppression for ordinary retries, but reset the announcement after an explicit Open/Create attempt ends without a loaded wallet and reannounce once that flow closes. Add an abandonment case to verify this behavior without reopening the notice over an active wallet-opening flow.


Link

[suggestion] · The request review omits the wallet whose draft it changes

A retained request can be reoffered for a different selected wallet, but the review shows only its request source, not the wallet whose draft Apply will modify.

Location: qml/components/PaymentRequestReviewPopup.qml:80 (head).

Details and suggested fix

Deselecting a wallet interrupts its request, and redelivery targets the current activeView; loading another wallet can change that target. The review lists From, Address, Amount, Label, and Message, but From contains provenance such as “command line,” not the paying wallet. Add a Wallet row using the owning SendCreate wallet's display name, and label the provenance row Source to distinguish the two. This makes the draft target explicit inside the review, consistent with design.md's wallet-identity guidance, while leaving delivery and transaction authorization unchanged.


Coverage details

Background

Ralph's summary of historical context for the behaviour affected by this change. The historical record reviewed here is incomplete.

Documented decisions

Command-line URI handling is a security boundary because a desktop handler can pass attacker-influenced arguments to Qt before Bitcoin Core validates them. Preventing Qt from interpreting the real process arguments and subsequently validating those arguments are distinct protections.

Earlier PR #897 introduced synthetic QApplication arguments and explicitly deferred command-line sanitation to URI-capture work. This explains why 338fba2 precedes delivery: it extends rejection coverage to options behind a URI and unexpected loose tokens, with matching argument-injection tests, rather than treating successful URI capture as sufficient protection.

Source 1

Counterparty-controlled payment text must not implicitly become markup: automatic rich-text detection creates both a financial-UI spoofing primitive and image-fetch attempts.

Issue #906 documents this rationale independently of the current PR. It explains the separate c15109a plain-text stage after the incoming-request review introduces another display surface for URI labels and messages. The supplied patch places literal-text assertions and an HTTP request recorder alongside that behavior change.

Source 1

Ralph's inferences

At the source-organization level, the series introduces the requested contracts in distinguishable steps and places relevant tests alongside them. This is an inference from the patch and selected intermediate diffs, not a historical endorsement or proof that every intermediate revision passes.

338fba2 adds ingress rejection and its functional probes. ed446f5 adds queued delivery, completion versus interruption, queue unit tests, startup functional coverage, routing tests, and Send tests ensuring wallet loss interrupts delivery while clipboard activity reports no queue outcome. Thus interruption handling accompanies initial delivery rather than arriving only as a later repair. 2e4e695 changes delivery into review-before-application and adds tests for unchanged form state, discard, focus, form ownership, long messages, and interruption during review; it also updates startup expectations. 1ab1bb3 adds no-wallet and wallet-disabled handling with tests for queue advancement and delivery after a covering wizard closes. c15109a separates literal rendering and network-fetch protection into their own tested step. Finally, 6a64ee1 extends replacement detection to earlier request labels and messages, with a QML case matrix and an updated clipboard functional expectation. The historical sources support the ingress and display threat models motivating these boundaries; the staging assessment itself comes from source inspection.

Source 1 · Source 2