Repository navigation
qt: answer address labels from the table model during wallet encryption - #182
Merged
Merged
Conversation
A repaint of the transaction list or the overview page resolves address labels through AddressTableModel::labelForAddress, which asks the wallet under cs_wallet. While the encryption worker from #178 holds the wallet locks, an expose or repaint event stalled the GUI thread until the encryption finished. No user input is needed: an uncomposited desktop delivers one behind the application-modal passphrase dialog. Every wallet read reachable from a paint path during an encryption goes through that lookup: the ToAddress column's display, edit, tooltip and foreground roles and the LabelRole and TxPlainTextRole answers in TransactionTableModel, TxViewDelegate on the overview page and the label search in TransactionFilterProxy. The other wallet reads in data(), LongDescriptionRole and TxHexRole, need a user action the modal dialog blocks; transaction status and balance polling already give up with TRY_LOCK; the address book and recent-requests views answer from their own rows, and the coin control view is rebuilt only by the user. The address book cannot change while the worker holds the wallet, so AddressTableModel::getAddressData answers from the rows it already holds while WalletModel::isEncryptingWallet(), found by the encoded address the rows are sorted on. One guard covers every caller of labelForAddress and purposeForAddress, and outside an encryption the wallet is asked as before. The synthetic test wallet gains an address book and a status for the transaction it holds, behind the encryption latch like the locks they stand in for. The new WalletTests case repaints an OverviewPage and requests every label-bearing role while the encryption is held open, checks that the GUI thread keeps servicing events and that the labels match before, during and after the encryption. Against the previous implementation it fails at the watchdog assertion. Fixes #180 Co-Authored-By: Claude <[email protected]>
The #180 test built its address book from one legacy receiving row, but every release chain sets fRestrictedOutputMode, so the rows a production wallet holds are P2MR bech32m addresses, and sending and hidden refund rows go through the same lookup. A single row also left the search the model answers from during an encryption with nothing to order. The synthetic wallet now also pays a labelled P2MR receiving address and files a P2MR sending and refund address, so the address book mixes both encodings. The test checks the transaction list roles for the P2MR payment and the label and purpose of every row before, during and after the held encryption, which also covers mapping a row's type back to its purpose. Against a32081e's address table model it still fails at the watchdog assertion. Fixes #180 Co-Authored-By: Claude <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Sep 25, 2026
This was referenced Oct 22, 2026
Merged
This was referenced Nov 4, 2026
kiwidream
added a commit
that referenced
this pull request
Nov 5, 2026
The Encrypt Wallet dialog runs the encryption on a worker thread and puts WalletModel into a mode in which status, PQC validation and label reads answer from cached values, and status, keypool and transaction-table updates are held back (#178, #182). That mode engaged only when the GUI started the encryption. The encryptwallet RPC holds the wallet locks for the whole call while it generates the new keys, so it stalled the GUI thread on those locks. On 2026-11-04, `qbit-cli encryptwallet` with -keypool=3000 froze qbit-qt for about 200 seconds. CWallet::EncryptWallet now counts itself in progress from its first line until it returns or throws, whoever called it, and it raises NotifyEncryptionInProgressChanged when it starts and when it ends. The counter is an atomic that reads no wallet state, so the GUI can query it without waiting for the locks. interfaces::Wallet exposes it as isEncryptionInProgress() and handleEncryptionInProgressChanged(). The announcement does not change the encryption itself: the #183 checks and the #277 lock order are untouched, and an overlapping encryptwallet call still returns -15 (RPC_WALLET_WRONG_ENC_STATE). WalletModel::isEncryptingWallet() now also reports an encryption that the wallet announces, so every guard from #178 and #182 covers it: the encryption status, the PQC validation status, label lookups, status and keypool notifications, transaction-table updates, the HD status in the status bar, payment URIs, unlock requests and fee bumps. The model enters this state the first time it sees the encryption and leaves it only when it handles the wallet's notification that the encryption ended. Updates held back in the meantime are therefore delivered before newer ones. The notification is queued, and the model reads the in-progress state instead of relying on the order in which notifications arrive, so a start that is announced after the end cannot leave the model stuck. When the encryption ends, the model refreshes the status from the wallet whatever the outcome, including a failure, or an exception that skipped the wallet's status notification. It then delivers what it held back and emits the new walletEncryptionEnded() signal, which payment URIs now wait for. The dialog's own result waits until every encryption in progress has ended. If another encryption holds the wallet when the dialog's request is refused, the dialog reports "already encrypted by another request" once that encryption has finished, instead of reading the status from before it. The listener only posts a queued call and never waits for the GUI thread. The notification can therefore be raised while the encryptwallet RPC holds cs_wallet without deadlocking against a GUI-thread call that waits for that lock. GUI actions that the user starts and that need the wallet, such as creating a receiving address, still wait for an encryption started outside the GUI, as in v1.0.0. The release notes list them. The synthetic test wallet now announces its encryption. New WalletTests start an encryption from another thread, as the RPC does, and hold it open: - The GUI thread keeps servicing events while the reads answer from the model, and the held-back updates are delivered once the encryption ends. - A failure, an exception and a late start announcement each end the mode and refresh the status. - A dialog request refused during another encryption reports the right result. - Deleting the model, as unloading the wallet does, does not wait for the encryption. A further test encrypts a real descriptor wallet with the wallet locks held, as the RPC does, and parks it inside its database transaction. The GUI stays responsive, a GUI-thread call that waits for cs_wallet completes once the encryption has finished, and the model then reports the wallet as encrypted and locked. Without the WalletModel changes, each new test fails at its watchdog assertion. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]>
kiwidream
added a commit
that referenced
this pull request
Nov 6, 2026
The Encrypt Wallet dialog runs the encryption on a worker thread and puts WalletModel into a mode in which status, PQC validation and label reads answer from cached values, and status, keypool and transaction-table updates are held back (#178, #182). That mode engaged only when the GUI started the encryption. The encryptwallet RPC holds the wallet locks for the whole call while it generates the new keys, so it stalled the GUI thread on those locks. On 2026-11-04, `qbit-cli encryptwallet` with -keypool=3000 froze qbit-qt for about 200 seconds. CWallet::EncryptWallet now counts itself in progress from its first line until it returns or throws, whoever called it, and it raises NotifyEncryptionInProgressChanged when it starts and when it ends. The counter is an atomic that reads no wallet state, so the GUI can query it without waiting for the locks. interfaces::Wallet exposes it as isEncryptionInProgress() and handleEncryptionInProgressChanged(). The announcement does not change the encryption itself: the #183 checks and the #277 lock order are untouched, and an overlapping encryptwallet call still returns -15 (RPC_WALLET_WRONG_ENC_STATE). WalletModel::isEncryptingWallet() now also reports an encryption that the wallet announces, so every guard from #178 and #182 covers it: the encryption status, the PQC validation status, label lookups, status and keypool notifications, transaction-table updates, the HD status in the status bar, payment URIs, unlock requests and fee bumps. The model enters this state the first time it sees the encryption and leaves it only when it handles the wallet's notification that the encryption ended. Updates held back in the meantime are therefore delivered before newer ones. The notification is queued, and the model reads the in-progress state instead of relying on the order in which notifications arrive, so a start that is announced after the end cannot leave the model stuck. When the encryption ends, the model refreshes the status from the wallet whatever the outcome, including a failure, or an exception that skipped the wallet's status notification. It then delivers what it held back and emits the new walletEncryptionEnded() signal, which payment URIs now wait for. The dialog's own result waits until every encryption in progress has ended. If another encryption holds the wallet when the dialog's request is refused, the dialog reports "already encrypted by another request" once that encryption has finished, instead of reading the status from before it. The listener only posts a queued call and never waits for the GUI thread. The notification can therefore be raised while the encryptwallet RPC holds cs_wallet without deadlocking against a GUI-thread call that waits for that lock. GUI actions that the user starts and that need the wallet, such as creating a receiving address, still wait for an encryption started outside the GUI, as in v1.0.0. The release notes list them. The synthetic test wallet now announces its encryption. New WalletTests start an encryption from another thread, as the RPC does, and hold it open: - The GUI thread keeps servicing events while the reads answer from the model, and the held-back updates are delivered once the encryption ends. - A failure, an exception and a late start announcement each end the mode and refresh the status. - A dialog request refused during another encryption reports the right result. - Deleting the model, as unloading the wallet does, does not wait for the encryption. A further test encrypts a real descriptor wallet with the wallet locks held, as the RPC does, and parks it inside its database transaction. The GUI stays responsive, a GUI-thread call that waits for cs_wallet completes once the encryption has finished, and the model then reports the wallet as encrypted and locked. Without the WalletModel changes, each new test fails at its watchdog assertion. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]>
kiwidream
added a commit
that referenced
this pull request
Nov 9, 2026
The Encrypt Wallet dialog runs the encryption on a worker thread and puts WalletModel into a mode in which status, PQC validation and label reads answer from cached values, and status, keypool and transaction-table updates are held back (#178, #182). That mode engaged only when the GUI started the encryption. The encryptwallet RPC holds the wallet locks for the whole call while it generates the new keys, so it stalled the GUI thread on those locks. On 2026-11-04, `qbit-cli encryptwallet` with -keypool=3000 froze qbit-qt for about 200 seconds. CWallet::EncryptWallet now counts itself in progress from its first line until it returns or throws, whoever called it, and it raises NotifyEncryptionInProgressChanged when it starts and when it ends. The counter is an atomic that reads no wallet state, so the GUI can query it without waiting for the locks. interfaces::Wallet exposes it as isEncryptionInProgress() and handleEncryptionInProgressChanged(). The announcement does not change the encryption itself: the #183 checks and the #277 lock order are untouched, and an overlapping encryptwallet call still returns -15 (RPC_WALLET_WRONG_ENC_STATE). WalletModel::isEncryptingWallet() now also reports an encryption that the wallet announces, so every guard from #178 and #182 covers it: the encryption status, the PQC validation status, label lookups, status and keypool notifications, transaction-table updates, the HD status in the status bar, payment URIs, unlock requests and fee bumps. The model enters this state the first time it sees the encryption and leaves it only when it handles the wallet's notification that the encryption ended. Updates held back in the meantime are therefore delivered before newer ones. The notification is queued, and the model reads the in-progress state instead of relying on the order in which notifications arrive, so a start that is announced after the end cannot leave the model stuck. When the encryption ends, the model refreshes the status from the wallet whatever the outcome, including a failure, or an exception that skipped the wallet's status notification. It then delivers what it held back and emits the new walletEncryptionEnded() signal, which payment URIs now wait for. The dialog's own result waits until every encryption in progress has ended. If another encryption holds the wallet when the dialog's request is refused, the dialog reports "already encrypted by another request" once that encryption has finished, instead of reading the status from before it. The listener only posts a queued call and never waits for the GUI thread. The notification can therefore be raised while the encryptwallet RPC holds cs_wallet without deadlocking against a GUI-thread call that waits for that lock. GUI actions that the user starts and that need the wallet, such as creating a receiving address, still wait for an encryption started outside the GUI, as in v1.0.0. The release notes list them. The synthetic test wallet now announces its encryption. New WalletTests start an encryption from another thread, as the RPC does, and hold it open: - The GUI thread keeps servicing events while the reads answer from the model, and the held-back updates are delivered once the encryption ends. - A failure, an exception and a late start announcement each end the mode and refresh the status. - A dialog request refused during another encryption reports the right result. - Deleting the model, as unloading the wallet does, does not wait for the encryption. A further test encrypts a real descriptor wallet with the wallet locks held, as the RPC does, and parks it inside its database transaction. The GUI stays responsive, a GUI-thread call that waits for cs_wallet completes once the encryption has finished, and the model then reports the wallet as encrypted and locked. Without the WalletModel changes, each new test fails at its watchdog assertion. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]>
kiwidream
added a commit
that referenced
this pull request
Nov 10, 2026
…it (#352) * qt: keep the GUI responsive during wallet encryption started outside it The Encrypt Wallet dialog runs the encryption on a worker thread and puts WalletModel into a mode in which status, PQC validation and label reads answer from cached values, and status, keypool and transaction-table updates are held back (#178, #182). That mode engaged only when the GUI started the encryption. The encryptwallet RPC holds the wallet locks for the whole call while it generates the new keys, so it stalled the GUI thread on those locks. On 2026-11-04, `qbit-cli encryptwallet` with -keypool=3000 froze qbit-qt for about 200 seconds. CWallet::EncryptWallet now counts itself in progress from its first line until it returns or throws, whoever called it, and it raises NotifyEncryptionInProgressChanged when it starts and when it ends. The counter is an atomic that reads no wallet state, so the GUI can query it without waiting for the locks. interfaces::Wallet exposes it as isEncryptionInProgress() and handleEncryptionInProgressChanged(). The announcement does not change the encryption itself: the #183 checks and the #277 lock order are untouched, and an overlapping encryptwallet call still returns -15 (RPC_WALLET_WRONG_ENC_STATE). WalletModel::isEncryptingWallet() now also reports an encryption that the wallet announces, so every guard from #178 and #182 covers it: the encryption status, the PQC validation status, label lookups, status and keypool notifications, transaction-table updates, the HD status in the status bar, payment URIs, unlock requests and fee bumps. The model enters this state the first time it sees the encryption and leaves it only when it handles the wallet's notification that the encryption ended. Updates held back in the meantime are therefore delivered before newer ones. The notification is queued, and the model reads the in-progress state instead of relying on the order in which notifications arrive, so a start that is announced after the end cannot leave the model stuck. When the encryption ends, the model refreshes the status from the wallet whatever the outcome, including a failure, or an exception that skipped the wallet's status notification. It then delivers what it held back and emits the new walletEncryptionEnded() signal, which payment URIs now wait for. The dialog's own result waits until every encryption in progress has ended. If another encryption holds the wallet when the dialog's request is refused, the dialog reports "already encrypted by another request" once that encryption has finished, instead of reading the status from before it. The listener only posts a queued call and never waits for the GUI thread. The notification can therefore be raised while the encryptwallet RPC holds cs_wallet without deadlocking against a GUI-thread call that waits for that lock. GUI actions that the user starts and that need the wallet, such as creating a receiving address, still wait for an encryption started outside the GUI, as in v1.0.0. The release notes list them. The synthetic test wallet now announces its encryption. New WalletTests start an encryption from another thread, as the RPC does, and hold it open: - The GUI thread keeps servicing events while the reads answer from the model, and the held-back updates are delivered once the encryption ends. - A failure, an exception and a late start announcement each end the mode and refresh the status. - A dialog request refused during another encryption reports the right result. - Deleting the model, as unloading the wallet does, does not wait for the encryption. A further test encrypts a real descriptor wallet with the wallet locks held, as the RPC does, and parks it inside its database transaction. The GUI stays responsive, a GUI-thread call that waits for cs_wallet completes once the encryption has finished, and the model then reports the wallet as encrypted and locked. Without the WalletModel changes, each new test fails at its watchdog assertion. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * wallet: announce RPC encryption before taking the wallet locks The encryptwallet RPC takes m_relock_mutex and cs_wallet before its checks, and GetPQCKeyValidationInfo then waits for every descriptor manager's cs_desc_man. A background P2MR refill or create-time top-up step holds cs_desc_man without cs_wallet while it derives and writes keys, so the RPC can sit with cs_wallet held before EncryptWallet raises the in-progress counter. A GUI read in that window, such as a label lookup during a repaint, waited for cs_wallet and so for the whole encryption: the stall the previous commit fixes. The counter and its notifications move into an RAII CWallet::EncryptionInProgressScope. EncryptWallet holds one as before, and the encryptwallet RPC now takes another before LOCK2. The counter nests. The RPC's scope ends after the locks are released, so a call that fails, or that finds the wallet encrypted and returns -15, also ends with the GUI reading the wallet again. The scope does not touch the RPC's checks or the lock order from #183 and #277. A new WalletTests case runs the encryptwallet RPC against a real descriptor wallet while a thread holds a descriptor manager's lock, the way a keypool step does. The GUI keeps servicing events while the RPC holds cs_wallet and waits for that lock, and the model answers from what it last read. The encryption then completes, and a second call returns -15 and still ends with walletEncryptionEnded(). Without the RPC's scope, the test fails at its watchdog assertion. The same test also covers an encryption that throws from m_before_encrypt_wallet_locks: the announcement ends, and the model reads the wallet again. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: refuse Encrypt Wallet while another encryption runs While another caller, such as the encryptwallet RPC, was encrypting the wallet, the GUI still showed it as unencrypted and accepted a request from the Encrypt Wallet dialog. The worker then derived a key and waited for the other encryption's locks. The dialog showed its progress bar for the rest of that encryption, and only then reported that the wallet had been encrypted by another request. Meanwhile ~WalletModel would have waited for the worker. WalletModel::encryptWallet() now refuses while isEncryptingWallet(), with the "Wallet encryption in progress" message that unlock requests and fee bumps get, and starts nothing. The dialog then closes without claiming a result. The dialog's own result still waits for every encryption in progress. The encryptwallet RPC announces its encryption before it waits for the locks, which can happen while the dialog's encryption holds them. The test that covered this now exercises that order: the synthetic wallet can announce an encryption without holding its latch, as the RPC does while it waits. A new test covers the refusal and fails without it. The release notes add opening a wallet in the GUI while it is being encrypted to the known limitations: the model reads the wallet when it is created. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: tighten the wallet-announced encryption mode Follow-ups from a local review of this branch: - The Encrypt Wallet dialog decided whether another encryption had refused its request by checking isEncryptingWallet() after the call. The model's "Wallet encryption in progress" message runs a nested event loop, which can see that other encryption end. The dialog then reported a result for an attempt the model never made. It now checks before asking, and WalletView refuses to open the dialog while another encryption runs, before the user has chosen a passphrase. - WalletModel now reads the encryption and PQC validation status once it has subscribed to the wallet. A model that had not been asked for them before another caller started encrypting reported the defaults: an encrypted wallet showed as unencrypted while a refused encryptwallet call waited for the locks. - encryptWallet() no longer resets the status the model last reported. Doing so could swallow an encryptionStatusChanged() whose notification was still queued. The getters now record the values that the GUI is answered from. - Each encryption raises several notifications, and they can all be queued while the GUI thread is busy. The model now coalesces the refresh at the end of an encryption into one. - If a listener threw from EncryptionInProgressScope's constructor, the announcement was rolled back without telling the listeners that had already heard it. A listener that threw when the scope ended called std::terminate. The rollback now notifies, and the destructor logs a listener's exception. Each new test fails without its change. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: read the wallet's status directly when the model is created Follow-ups from a second local review: - The model now reads the wallet directly for the status it reports while another caller is encrypting, as the table models built just before it do. Before, it went through the getters, which already answer from the defaults if the encryptwallet RPC has announced an encryption but not yet taken the wallet locks. - encryptWallet() refuses with "Wallet encryption in progress" while this model's own worker is running too, so the dialog no longer closes silently in that case. - A single refuseWhileEncrypting() helper now posts the message in place of four copies. - The refresh queued by a notification is dropped once another refresh has run. Before, a GUI-started encryption refreshed twice. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: read the wallet's status before building the table models The previous commit read the status for the encrypting state after the table models had been built. An encryptwallet RPC that took the wallet locks between those reads and the table models' own reads stalled creating the model for the whole encryption. Read the status first: building the model now waits for an encryption only where the table models would anyway, the documented limitation. Also guard the Encrypt Wallet dialog against deletion during the refusal message's event loop, and fix two comments. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: rename the RPC-encryption GUI release notes after the PR Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
kiwidream
added a commit
that referenced
this pull request
Nov 12, 2026
…on (#182) * qt: answer address labels from the table model during wallet encryption A repaint of the transaction list or the overview page resolves address labels through AddressTableModel::labelForAddress, which asks the wallet under cs_wallet. While the encryption worker from #178 holds the wallet locks, an expose or repaint event stalled the GUI thread until the encryption finished. No user input is needed: an uncomposited desktop delivers one behind the application-modal passphrase dialog. Every wallet read reachable from a paint path during an encryption goes through that lookup: the ToAddress column's display, edit, tooltip and foreground roles and the LabelRole and TxPlainTextRole answers in TransactionTableModel, TxViewDelegate on the overview page and the label search in TransactionFilterProxy. The other wallet reads in data(), LongDescriptionRole and TxHexRole, need a user action the modal dialog blocks; transaction status and balance polling already give up with TRY_LOCK; the address book and recent-requests views answer from their own rows, and the coin control view is rebuilt only by the user. The address book cannot change while the worker holds the wallet, so AddressTableModel::getAddressData answers from the rows it already holds while WalletModel::isEncryptingWallet(), found by the encoded address the rows are sorted on. One guard covers every caller of labelForAddress and purposeForAddress, and outside an encryption the wallet is asked as before. The synthetic test wallet gains an address book and a status for the transaction it holds, behind the encryption latch like the locks they stand in for. The new WalletTests case repaints an OverviewPage and requests every label-bearing role while the encryption is held open, checks that the GUI thread keeps servicing events and that the labels match before, during and after the encryption. Against the previous implementation it fails at the watchdog assertion. Fixes #180 Co-Authored-By: Claude <[email protected]> * qt: cover P2MR, sending and refund rows in the encryption label test The #180 test built its address book from one legacy receiving row, but every release chain sets fRestrictedOutputMode, so the rows a production wallet holds are P2MR bech32m addresses, and sending and hidden refund rows go through the same lookup. A single row also left the search the model answers from during an encryption with nothing to order. The synthetic wallet now also pays a labelled P2MR receiving address and files a P2MR sending and refund address, so the address book mixes both encodings. The test checks the transaction list roles for the P2MR payment and the label and purpose of every row before, during and after the held encryption, which also covers mapping a row's type back to its purpose. Against a32081e's address table model it still fails at the watchdog assertion. Fixes #180 Co-Authored-By: Claude <[email protected]> --------- Co-authored-by: Claude <[email protected]>
kiwidream
added a commit
that referenced
this pull request
Nov 12, 2026
…it (#352) * qt: keep the GUI responsive during wallet encryption started outside it The Encrypt Wallet dialog runs the encryption on a worker thread and puts WalletModel into a mode in which status, PQC validation and label reads answer from cached values, and status, keypool and transaction-table updates are held back (#178, #182). That mode engaged only when the GUI started the encryption. The encryptwallet RPC holds the wallet locks for the whole call while it generates the new keys, so it stalled the GUI thread on those locks. On 2026-11-04, `qbit-cli encryptwallet` with -keypool=3000 froze qbit-qt for about 200 seconds. CWallet::EncryptWallet now counts itself in progress from its first line until it returns or throws, whoever called it, and it raises NotifyEncryptionInProgressChanged when it starts and when it ends. The counter is an atomic that reads no wallet state, so the GUI can query it without waiting for the locks. interfaces::Wallet exposes it as isEncryptionInProgress() and handleEncryptionInProgressChanged(). The announcement does not change the encryption itself: the #183 checks and the #277 lock order are untouched, and an overlapping encryptwallet call still returns -15 (RPC_WALLET_WRONG_ENC_STATE). WalletModel::isEncryptingWallet() now also reports an encryption that the wallet announces, so every guard from #178 and #182 covers it: the encryption status, the PQC validation status, label lookups, status and keypool notifications, transaction-table updates, the HD status in the status bar, payment URIs, unlock requests and fee bumps. The model enters this state the first time it sees the encryption and leaves it only when it handles the wallet's notification that the encryption ended. Updates held back in the meantime are therefore delivered before newer ones. The notification is queued, and the model reads the in-progress state instead of relying on the order in which notifications arrive, so a start that is announced after the end cannot leave the model stuck. When the encryption ends, the model refreshes the status from the wallet whatever the outcome, including a failure, or an exception that skipped the wallet's status notification. It then delivers what it held back and emits the new walletEncryptionEnded() signal, which payment URIs now wait for. The dialog's own result waits until every encryption in progress has ended. If another encryption holds the wallet when the dialog's request is refused, the dialog reports "already encrypted by another request" once that encryption has finished, instead of reading the status from before it. The listener only posts a queued call and never waits for the GUI thread. The notification can therefore be raised while the encryptwallet RPC holds cs_wallet without deadlocking against a GUI-thread call that waits for that lock. GUI actions that the user starts and that need the wallet, such as creating a receiving address, still wait for an encryption started outside the GUI, as in v1.0.0. The release notes list them. The synthetic test wallet now announces its encryption. New WalletTests start an encryption from another thread, as the RPC does, and hold it open: - The GUI thread keeps servicing events while the reads answer from the model, and the held-back updates are delivered once the encryption ends. - A failure, an exception and a late start announcement each end the mode and refresh the status. - A dialog request refused during another encryption reports the right result. - Deleting the model, as unloading the wallet does, does not wait for the encryption. A further test encrypts a real descriptor wallet with the wallet locks held, as the RPC does, and parks it inside its database transaction. The GUI stays responsive, a GUI-thread call that waits for cs_wallet completes once the encryption has finished, and the model then reports the wallet as encrypted and locked. Without the WalletModel changes, each new test fails at its watchdog assertion. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * wallet: announce RPC encryption before taking the wallet locks The encryptwallet RPC takes m_relock_mutex and cs_wallet before its checks, and GetPQCKeyValidationInfo then waits for every descriptor manager's cs_desc_man. A background P2MR refill or create-time top-up step holds cs_desc_man without cs_wallet while it derives and writes keys, so the RPC can sit with cs_wallet held before EncryptWallet raises the in-progress counter. A GUI read in that window, such as a label lookup during a repaint, waited for cs_wallet and so for the whole encryption: the stall the previous commit fixes. The counter and its notifications move into an RAII CWallet::EncryptionInProgressScope. EncryptWallet holds one as before, and the encryptwallet RPC now takes another before LOCK2. The counter nests. The RPC's scope ends after the locks are released, so a call that fails, or that finds the wallet encrypted and returns -15, also ends with the GUI reading the wallet again. The scope does not touch the RPC's checks or the lock order from #183 and #277. A new WalletTests case runs the encryptwallet RPC against a real descriptor wallet while a thread holds a descriptor manager's lock, the way a keypool step does. The GUI keeps servicing events while the RPC holds cs_wallet and waits for that lock, and the model answers from what it last read. The encryption then completes, and a second call returns -15 and still ends with walletEncryptionEnded(). Without the RPC's scope, the test fails at its watchdog assertion. The same test also covers an encryption that throws from m_before_encrypt_wallet_locks: the announcement ends, and the model reads the wallet again. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: refuse Encrypt Wallet while another encryption runs While another caller, such as the encryptwallet RPC, was encrypting the wallet, the GUI still showed it as unencrypted and accepted a request from the Encrypt Wallet dialog. The worker then derived a key and waited for the other encryption's locks. The dialog showed its progress bar for the rest of that encryption, and only then reported that the wallet had been encrypted by another request. Meanwhile ~WalletModel would have waited for the worker. WalletModel::encryptWallet() now refuses while isEncryptingWallet(), with the "Wallet encryption in progress" message that unlock requests and fee bumps get, and starts nothing. The dialog then closes without claiming a result. The dialog's own result still waits for every encryption in progress. The encryptwallet RPC announces its encryption before it waits for the locks, which can happen while the dialog's encryption holds them. The test that covered this now exercises that order: the synthetic wallet can announce an encryption without holding its latch, as the RPC does while it waits. A new test covers the refusal and fails without it. The release notes add opening a wallet in the GUI while it is being encrypted to the known limitations: the model reads the wallet when it is created. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: tighten the wallet-announced encryption mode Follow-ups from a local review of this branch: - The Encrypt Wallet dialog decided whether another encryption had refused its request by checking isEncryptingWallet() after the call. The model's "Wallet encryption in progress" message runs a nested event loop, which can see that other encryption end. The dialog then reported a result for an attempt the model never made. It now checks before asking, and WalletView refuses to open the dialog while another encryption runs, before the user has chosen a passphrase. - WalletModel now reads the encryption and PQC validation status once it has subscribed to the wallet. A model that had not been asked for them before another caller started encrypting reported the defaults: an encrypted wallet showed as unencrypted while a refused encryptwallet call waited for the locks. - encryptWallet() no longer resets the status the model last reported. Doing so could swallow an encryptionStatusChanged() whose notification was still queued. The getters now record the values that the GUI is answered from. - Each encryption raises several notifications, and they can all be queued while the GUI thread is busy. The model now coalesces the refresh at the end of an encryption into one. - If a listener threw from EncryptionInProgressScope's constructor, the announcement was rolled back without telling the listeners that had already heard it. A listener that threw when the scope ended called std::terminate. The rollback now notifies, and the destructor logs a listener's exception. Each new test fails without its change. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: read the wallet's status directly when the model is created Follow-ups from a second local review: - The model now reads the wallet directly for the status it reports while another caller is encrypting, as the table models built just before it do. Before, it went through the getters, which already answer from the defaults if the encryptwallet RPC has announced an encryption but not yet taken the wallet locks. - encryptWallet() refuses with "Wallet encryption in progress" while this model's own worker is running too, so the dialog no longer closes silently in that case. - A single refuseWhileEncrypting() helper now posts the message in place of four copies. - The refresh queued by a notification is dropped once another refresh has run. Before, a GUI-started encryption refreshed twice. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * qt: read the wallet's status before building the table models The previous commit read the status for the encrypting state after the table models had been built. An encryptwallet RPC that took the wallet locks between those reads and the table models' own reads stalled creating the model for the whole encryption. Read the status first: building the model now waits for an encryption only where the table models would anyway, the documented limitation. Also guard the Encrypt Wallet dialog against deletion during the refusal message's event loop, and fix two comments. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: rename the RPC-encryption GUI release notes after the PR Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
kiwidream
added a commit
that referenced
this pull request
Nov 12, 2026
## Summary This lands the v1.0.1 release branch on `main` as one commit, the same way `main` received v1.0.0 in #135. The `v1.0.1` tag will then be created on the resulting `main` commit. - **Source:** release branch `1.x.x` at `a7a70660ad6ecadbf77b89bc2fe85ba068a86a71`, this PR's head before the signed squash. `main` (`70fea84f5b`) is an ancestor of that commit, so the squash has exactly its tree: `35a01d570ceef5984ae84e15d4dc74adecb587be`. - **Signing:** the release coordinator squashes the head into one commit and signs it with `squash-sign`. The tree does not change. - **Rebuilt head:** this branch replays the 75 commits of `1.x.x` since `main` (`70fea84f5b..a7a7066`) with their trees, messages and authors unchanged, so their SHAs differ from `1.x.x`'s. The one change: #268 (`e374ba24cf`) is split into its pure libbitcoinpqc v0.3.2 import, which carries the subtree's directory and split (`1965d0da1e`) trailers, and the rest of #268. That way the squash keeps the subtree trailer that `test/lint/libbitcoinpqc-subtree-check.sh` needs on `main`. Without it, the check would find v0.1.1's split `ac72d1ffa0` and fail. The final tree is still `35a01d570ceef5984ae84e15d4dc74adecb587be`. ## Validation of this tree (on `a7a70660ad`) - Full Validation [43271045040](https://github.com/Qbit-Org/qbit/actions/runs/43271045040): passed. - Required Merge Gate [43271044819](https://github.com/Qbit-Org/qbit/actions/runs/43271044819): passed. - Core Checks [43271044808](https://github.com/Qbit-Org/qbit/actions/runs/43271044808), including the `mainnet publication posture` job: passed. - Nightly CI [43273463067](https://github.com/Qbit-Org/qbit/actions/runs/43273463067): dispatched on this commit. Its scanner results are triaged, and one job is being re-run after a runner infrastructure failure. - The release notes are `doc/release-notes-1.0.1.md`, from #181. The freeze and the changes since v1.0.0 are tracked in #174. ## Review Please review the release as a whole against `v1.0.0` (`git diff v1.0.0 a7a7066`), or through the individual `1.x.x` PRs listed in #174 and the release notes. This PR adds nothing beyond `1.x.x` at `a7a70660ad`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Squashed commits: 5aa60b3 fix: resolve finalized mainnet CI failures (#137) b83f87d wallet: avoid deferred keypool unlock deadlock (#143) 0716a7c qt: move PSBT signing off GUI thread (#145) 141a9de Build versioned RPC docs pages (#148) 73c064a test: stabilize REST chaininfo comparison (#149) 508c6ea wallet: default -fallbackfee to the minimum relay fee (#151) 6f703b6 wallet: publish descriptor top-ups after commit (#144) f9172e8 wallet: show fee-only change-only self-transfers (#150) 6de89ab qt: show consumed PQC usage when a generated proof fails verification (#129) (#161) 9084d83 fuzz: seed qbit targets and verify replay and mutation (#164) df533c5 qt: preserve and display consumed PQC usage in transaction signing flows (#167) fc835f4 ci: run classifier tests in Required Merge Gate (#160) 2053d83 release: fail closed when the release asset list cannot be read (#170) 7f11260 ci: harden the Required Merge Gate check-run poller (#171) 5b80d5f ci: validate maintained source in scheduled heavy workflows (#165) 4873900 wallet: batch P2MR counters across mixed descriptors (#163) 19043e0 script: cache successful P2MR PQC signature checks (#162) b262cd0 ci: forward IBD workflow timeout inputs to the harness flags (#159) 4b89e4a doc: correct the v1.0.0 release trust record (#175) 0d2de1e fuzz: repair stale pqc_sign_refused coverage anchor (#176) 0954b74 qt: keep fee-bump PQC usage visible without a notification backend (#177) 3ccf788 qt: keep Encrypt Wallet responsive during existing-wallet encryption (#178) 6d6cc7d wallet: close races around CWallet::EncryptWallet (#183) 54f6737 qt: answer address labels from the table model during wallet encryption (#182) 1339e6b doc: fix pipe rendering and tighten P2MR v1 consensus profile (#252) 422ba0e doc: document bounded30 usage-dependent security margin and raw-key counter limits (#264) 981605a script: cache verified P2MR data-signature checks (v1.0.1) (#265) a5292af policy: bound P2MR runtime stack bytes (#263) d3b02f4 net: bound the size of headers messages we send (#266) 0c60e64 Squashed 'src/libbitcoinpqc/' changes from ac72d1ffa0..1965d0da1e 2f6992b subtree: import libbitcoinpqc v0.3.2 signer stack scrub (#268) cbb1961 crypto: clear stack released by PQC secret-key operations (#270) 260ac73 wallet: take descriptor locks before EncryptWallet's transaction (#277) 243065c mining: reset cached block checks in IPC submitSolution (backport bitcoin/bitcoin#33745) (#289) bc9f1bd wallet: keep the SQLite lock when probing loaded wallet files (#297) 95b8b9f wallet: fail a send whose inputs a concurrent call spent (#298) ad3d708 depends: Update Qt to 6.8.4 and fix macOS accessibility use-after-free (#347) 660034c fuzz: re-anchor PQC coverage checks after #270 and run them in CI (#342) b178391 wallet: deferred P2MR keypool refill at startup and unlock; Lock() waits for key copies (#299) 6700285 test: fix race in p2p_auxpow_headers_size (#358) f6c2013 qt: fix send confirmation re-entrancy and dialog deletion during confirmation (#348) 1fe12ea wallet: fallback-fee follow-ups for #151 (discard rate, GUI warning, default test, help texts) (#346) d21acc4 ci: bind the Required Merge Gate to its own event's runs, fail drafts, keep both sides of renames (#345) a4e1f26 qt: keep PSBT signing results across shutdown, close and unload (#344) e783923 test: keep wallet_p2mr_deferred_keypool_tests within time limits under sanitizers (#361) 1538eed ci: run runner selection on GitHub-hosted Ubuntu (#362) 1b8d10f qt: ignore PSBT Sign while a signing attempt is in progress (#353) 01a9ab3 contrib: import libbitcoinpqc releases as one verified main-line commit (#360) 5b42181 guix: ship macOS debug symbols as dSYM bundles (#343) 6f080f0 wallet: remove deleted plaintext keys from the wallet file after encryption (#300) 98dbe5b wallet: re-encrypt plaintext PQC keys in encrypted wallets on unlock (#301) dff82fb ci: allowlist fuzz-seed format tags in the gitleaks scan (#367) c7c9fbd ci: retry the cargo-audit database fetch and fix the clang analyzer scan (#368) 8ee5231 contrib: add the rulesets for qbit-guix.sigs main (#371) f8ababf contrib: add public tools to stage, sign and combine release checksums (#374) c4d88af contrib: keep the release key policy in one place and tighten key-policy continuity checks (#375) 78405ad wallet: keep the lock state when changing the passphrase (#379) ea99d08 ci: keep the 32-bit ARM nightly unit-test shards within their time limit (#377) cb1f507 ci: run the mainnet publication posture check on every mainnet line (#385) 6582427 qt: wait for open dialogs before shutdown and wallet unload (#354) 7953475 qt: keep the GUI responsive during wallet encryption started outside it (#352) 0d87213 doc: replace the release docs with a runbook, a publisher reference and a release issue form (#376) 3de5e93 net: only use service bits learned from a direct connection when deciding which addresses to avoid (#380) 565eb46 photon: bound inbound relay state per peer and check blocks before submission (#381) 7b7066f ci: parse gpg status output on newline only and reject other line separators (#387) b1b0860 net: budget per-peer time spent validating rejected transactions (#386) 3ae934c photon: announce blocks under the low-order bits of their hash (#410) faaaaa8 wallet: refill P2MR keypools before walletpassphrase returns (#411) 9e74401 wallet: fail descriptor key encryption when the plaintext record is not erased (#418) e8a796d ipc: return false from submitSolution for a missing or undecodable coinbase (#419) 396940d net: request transactions held back by the validation budget later, and limit each connection's share of the pool (#422) 6ca0132 net, validation: attribute received blocks to their sender and check recovered blocks (#414) c65bea2 qt: add a play-money poker lobby based on Satoshi's 2009 design (#378) b3b5096 script: limit standard hashing of large P2MR stack elements (#415) ca5d4b5 release: prepare v1.0.1 (#181) b1c6d4e net: pass held-back transaction announcements on at most once per retry delay (#425) Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Alexander Miller <[email protected]> Co-authored-by: Sjors Provoost <[email protected]> Co-authored-by: Fabian Jahr <[email protected]> Co-authored-by: Dan Hepworth <[email protected]> git-subtree-dir: src/libbitcoinpqc git-subtree-split: 1965d0da1eb4d9e196613b8f3a5d0d866a221c53
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After #178, encrypting an existing wallet no longer blocks the GUI thread, with one exception. If the transaction list or overview page is repainted during encryption, it resolves address labels through
AddressTableModel::labelForAddress, which callsinterfaces::Wallet::getAddressand takesLOCK(cs_wallet). The encryption worker holds that lock, so the repaint stalls until encryption finishes. This happens on an expose event with no user input, for example on an uncomposited X11 desktop.While
WalletModel::isEncryptingWallet()is true,AddressTableModel::getAddressDatanow answers from the rows the model already holds. It uses its address-sorted cache: decode and re-encode the address, binary search, and recover the purpose from the row type. The address book can't change while the worker holdscs_wallet, and any write queued before the lock was taken still reaches the model throughNotifyAddressBookChanged, so the cache is current. Outside encryption, behaviour is unchanged.This covers every repaint-reachable lookup: the
TransactionTableModelTo-address display, edit, tooltip and foreground roles,LabelRole,TxPlainTextRole, the overviewTxViewDelegate, and theTransactionFilterProxylabel search.Audit of the other GUI-thread paths:
LongDescriptionRole,TxHexRoleand coin control need user input, which the application-modal encryption dialog blocks.tryGetTxStatusandtryGetBalancesalready useTRY_LOCK.Known cosmetic gap: after the Sign/Verify dialog refreshes with
pk_hash_only, the cache holds only PKHash rows. Non-PKHash labels then show as bare addresses until encryption finishes. Only regtest with restricted output mode off can reach this.Fixes #180.
Testing
Built locally.
Ran focused unit or functional tests for the changed area.
Ran lint or formatting checks relevant to this change.
Not run. Reason:
New test:
WalletTestsgainsTestEncryptWalletRepaintUsesCachedLabels. While a latched synthetic encryption is held open, it grabs the overview page and requests every label-bearing role of the transaction rows, with a watchdog asserting the event loop keeps ticking. Before, during and after encryption, it checks labels andpurposeForAddressfor PKHash and P2MR rows with RECEIVE, SEND and REFUND/Hidden purposes.Revert check: with the base
addresstablemodel.cpp, the test fails at the watchdog: "GUI thread blocked on the encrypting wallet while resolving transaction labels". A mutation that maps Hidden to SEND fails the new REFUND assertion.Qt suite:
test_qbit-qt(offscreen) passes, 76/76, on GCC and on clang 20 built with-Wthread-safety -Wthread-safety-precise -Werror=thread-safety.Review: an independent adversarial review found no blocker or should-fix defects. It checked sort invariants, the purpose inverse, P2MR encode/decode round trips, cache staleness and threading. Its main nit, P2MR and SEND/REFUND coverage, is addressed in ef20c21.
Not run: unit and functional tests, since only
src/qtchanged; and a real X11 repaint.Target Branch
mainor a maintainer-requested release branch such as0.1.x.Targets
1.x.xfor v1.0.1 (#174).Risk / Review Notes
Notes: this changes wallet GUI presentation only (
src/qt), with no wallet-layer changes.Docs / Process Impact
Choose exactly one:
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.