mirror of
https://github.com/bitcoin-core/gui-qml.git
synced 2026-12-02 07:54:42 +00:00
Keep external signer discovery and approval responsive #977
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
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin-core/gui-qml#977
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Parent: #583.
Opening signer settings, creating a signer wallet or approving a transaction can wait for an external subprocess. A GUI timer only postpones that wait. Signing may hold wallet locks, so moving the subprocess call alone is insufficient if GUI getters still query the backend.
Cover
listExternalSigners(), discovery during creation and initialization, and device signing throughfillPSBT(), imported PSBTs and fee replacement.Run blocking work outside the GUI thread. Expose pending, available, unavailable and error states; coalesce repeated discovery; prevent duplicate approval; and reject results after settings, wallet or transaction changes. Keep the reviewed transaction bound to its approval and return complete results without GUI-side backend queries.
Define helper lifetime, timeout, cancellation and shutdown behavior explicitly. Discarding a result does not stop a running subprocess. Keep resources valid while it runs and avoid overlapping device commands after navigation or retry.
Acceptance should cover delayed or hung helpers, missing/multiple devices, malformed output, failure/retry, partial signatures, wallet changes and shutdown during discovery or approval.
Found two concrete cases for keeping signer approval tied to the transaction being reviewed. Both happen within the same wallet.
Tested on
qt6atd567e3eb2497, native macOS / Qt 6.9.0, using the repository’s mock signer and disposable regtest wallets. I didn’t test physical hardware.For the fixture, I used
bitcoin/test/functional/mocks/signer.pyand the signing-key setup fromtest/functional/qml_test_external_signer.py. Make two unsigned version-0 PSBTs spending the same confirmed coin, sending 0.02 BTC and 0.03 BTC. Save each as a binary.psbtfile. The mock readsmock_psbtandmock_resultfrom the GUI process’s working directory.mock_psbt, click Approve on external signer, and leave the review open without sending.1 {"error":"test signer failure"}tomock_result, then click Send.The GUI terminates with an uncaught
std::runtime_errorfromRunCommandParseJSONwhen the mock’senumeratecommand exits with status 1. The same helper failure through a fresh Approve action is caught and shows Retry external signer. The replacement does contact the signer again; it’s the error handling in this path that fails.There’s also a stuck-button case. Start with a fresh review of the first PSBT, remove
mock_result, and put that first unsigned PSBT inmock_psbtunchanged to exercise an incomplete signer result. Click Approve, then import the second unsigned PSBT without closing the review. The new transaction is signable, but its button stays disabled as “More signatures required.” This fixture returns an incomplete PSBT; it doesn’t add a partial signature.Closing and reimporting the second PSBT restores Approve. With the mock returning its signed PSBT, I could then approve and send it, and checked the exact transaction ID in the mempool.
ExternalSignerReviewActionskeeps its old state when the transaction changes, and the stale Send action reaches a signing path without the exception handling used by normal approval. We should reset that state for a new PSBT and handle helper failures in the Send path too. These are worth fixing before release, independently of moving the work off the GUI thread.Related to #763 and #1037; the latter covers the old password prompt surviving another PSBT import.
I can hit the helper-error crash through Activity → Speed up too, without replacing a PSBT.
Tested on
qt6atd567e3eb2497, native macOS / Qt 6.9.0, using the repository’s mock signer and disposable regtest wallets. I didn’t test physical hardware.To reproduce:
bitcoin/test/functional/mocks/signer.py. The signing-key fixture intest/functional/qml_test_external_signer.pyworks for this.mock_resultcontaining1 signer transport unavailable. This makes the mock’s nextenumeratecall exit with status 1.The whole GUI terminates with an uncaught
std::runtime_errorfromRunCommandParseJSON. The call tosignBumpTransaction()has no exception handling.Returning
0 []from the mock instead shows “Failed to sign transaction” and keeps the app running, so this is specifically the helper-error path. Also checked that mining the original while the dialog is open correctly prevents the bump.We need to catch the helper failure and show an error in the dialog. Moving this to a worker alone won’t fix the uncaught exception. Related to #976 and #642.
A concrete startup case for the initialization-discovery work here: a saved external-signer command can block interaction with an ordinary software wallet before the user starts any signer operation.
To reproduce:
enumerateresponse. I used a synthetic signer with a bounded delay.On two restarts, the picker click was still blocked after about 2.54 seconds. During each wait, five Core RPC calls completed in 33–34 ms and confirmed that the ordinary wallet was loaded, had private keys enabled and owned its fixture address. Releasing enumeration allowed the picker to open.
With the same saved signer command answering immediately, the healthy restart controls opened the picker in 28–29 ms.
QML’s wallet-controller initialization calls
listExternalSigners()synchronously on the GUI thread, and Core waits for the configured subprocess. Initialization discovery should run off that thread so an already-loaded software wallet remains usable while device discovery is pending. PR #1060 at733018ca9eabretains this synchronous initialization call.Reproduced on merged
qt6ateed1f426fcb6, macOS / Qt 6.9, using isolated offscreen regtest profiles. The delayed helper was released in both runs; this establishes the startup blocking behavior, not a permanent hang or a physical-device failure.