Repository navigation
Closed
Labels
bugSomething isn't working
Description
Summary
Application shutdown does not cancel an in-flight PSBT signing worker; shutdown waits for the whole signing, consumes PQC counters, then drops the signed PSBT.
Severity: medium. Found in the 2026-11-04 review of the v1.0.1 change set (all 1.x.x merges since v1.0.0 plus the open PRs that target it), against 1.x.x 21fee6ee8e; area: #145.
Observed
Confidence: confirmed (proven from code).
- Location:
src/qt/walletframe.cpp:60-65(WalletFrame::prepareForShutdowniterates onlymapWalletViews),src/qt/walletview.cpp:116-120(cancels only the bump and send workers),src/qt/walletframe.cpp:237(the PSBT dialog is a child ofWalletFrame, not of aWalletView),src/qt/psbtoperationsdialog.cpp:93-104(the only cancel is in the destructor),src/qt/psbtoperationsdialog.cpp:206(return !dialog.isNull()is always true while the worker runs),src/qt/bitcoin.cpp:353,371-381,src/wallet/load.cpp:183at 21fee6e. - Scenario:
- In an encrypted P2MR wallet, open File → Load PSBT with a many-input P2MR PSBT, click Sign, enter the passphrase. The worker starts.
- Shutdown is requested by
qbit-cli stop, SIGTERM, or OS logoff (the pollShutdownTimer →requestShutdown). requestShutdownhides all windows.prepareWalletsForShutdown()cancels the send and fee-bump workers only.removeAllWallets()anddelete m_wallet_controllerthen destroy everyWalletViewandWalletModel.- The PSBT dialog survives, hidden, until
delete windowin~BitcoinApplicationafterexec()returns. So does its worker, andm_sign_cancel_requestedis never set. Even during the cancellable preparation phase the worker goes on to reserve counters for every input and sign them all. Sign multi-input P2MR PSBTs outside the qbit-qt GUI thread #140's figure of 149 ms per signature makes 100 inputs about 15 s, before counter writes. - Meanwhile
appShutdown()→UnloadWallets→WaitForDeleteWalletblocks until the worker drops itsinterfaces::Walletclone. - When the worker finishes,
signTransactionFinishedtakes the!m_wallet_modelbranch (psbtoperationsdialog.cpp:300). The signed PSBT is discarded and the status "Failed to sign transaction: Wallet is no longer loaded." plus the consumed-usage block is written to a hidden dialog that is never seen. Nothing is logged unless a usage warning fires.
- Evidence: Traced from code:
requestShutdown→BitcoinGUI::prepareWalletsForShutdown→WalletFrame::prepareForShutdown→WalletView::prepareForShutdown. No other code path reachesPSBTOperationsDialog(grepfinds a single construction site, and nofindChildren). The node side isWalletLoaderImpl::stop→UnloadWallets→WaitForDeleteWallet(interfaces.cpp:713,load.cpp:175-184). Not reproduced.
Impact
- Shutdown is delayed by the full signing time. That risks an OS-forced kill at logoff.
- Stateful PQC capacity is consumed after shutdown began, for a result that is thrown away and never shown to the user. cancellation is not propagated. the consumption is invisible.
- Sign multi-input P2MR PSBTs outside the qbit-qt GUI thread #140's contract asked that "cancellation and shutdown follow explicit stateful-PQC safety rules" and listed an "application shutdown during signing" test. Only dialog destruction and direct model deletion are tested (
psbtoperationsdialogtests.cpp:377-414). AppTests covers the send worker only.
Suggested fix
- Add
PSBTOperationsDialog::prepareForShutdown(). It should setm_sign_cancel_requestedwhen!m_sign_counters_reservedand clear the progress dialog. Call it fromWalletFrame::prepareForShutdown()for everyfindChildren<PSBTOperationsDialog*>(), or track PSBT dialogs per wallet model. - Replace the dead
!dialog.isNull()condition with the cancel flag. - Add the AppTests case Sign multi-input P2MR PSBTs outside the qbit-qt GUI thread #140 asked for: quit during PSBT signing before and after counter reservation, asserting a bounded shutdown and no reservation in the first case.
- Optionally log the consumed usage when a completed result is discarded.
Related: new. It is not covered by the #181 Known limitations or #174, and it is related to but distinct from #286, which covers the background P2MR refill and walletlock.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
qt: keep PSBT signing results across shutdown, close and unload
qt: keep PSBT signing results across shutdown, close and unload (#344)
kiwidream commentedon Nov 6, 2026
Fixed on
1.x.xby #344 (merged as b5486bf).WalletFrame::prepareForShutdown()now reaches every PSBT dialog. Shutdown cancels a signing worker that has not reserved counters yet. A result produced after shutdown began is written todebug.logand, if signed, saved to the data directory asunshown-psbt-<txid>-<time>.psbt. AppTests and new PSBT dialog tests cover both cases and fail without the fix.maingets the fix when1.x.xis integrated.qt: keep PSBT signing results across shutdown, close and unload (#344)