Repository navigation
wallet: take descriptor locks before EncryptWallet's transaction - #277
Conversation
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. |
CWallet::EncryptWallet held cs_wallet and the SQLite writer, then waited for each descriptor manager's cs_desc_man in DescriptorScriptPubKeyMan::Encrypt. The background P2MR top-ups (RunP2MRKeyPoolRefillStep, RunPendingInitialKeyPoolTopUpStep) take cs_desc_man without cs_wallet and then wait for the writer, so the two could deadlock. A top-up whose key snapshot predated the encryption also committed plaintext walletdescriptorpqckey records into the encrypted, locked wallet, which the next load accepted. Both bugs date from v1.0.0. EncryptWallet now takes every manager's cs_desc_man before it begins its transaction and holds them until the commit. That matches the cs_desc_man -> writer order the top-ups and address reservation already use. Because the first master key is now added under those locks, a top-up that reads the encryption state under its own cs_desc_man gets an answer that cannot change while it holds the lock. TopUpWithDBPreparedResult refuses a plaintext snapshot taken before the encryption, and the self-committing top-up makes the same check before it opens a transaction. A stale top-up therefore never waits for the writer and never has a transaction open during EncryptWallet's VACUUM rewrite. It fails like a locked-wallet attempt, and the next attempt takes a new snapshot. PrepareTopUp and GetKeys read the encryption state under cs_desc_man for the same reason. DescriptorScriptPubKeyMan::Encrypt now requires cs_desc_man, PrepareTopUp excludes it, and the snapshot check requires it, so Clang's thread-safety analysis checks those callers. A small ASSERT_EXCLUSIVE_LOCK helper tells the analysis about the locks EncryptWallet holds in a list, and checks them at runtime under DEBUG_LOCKORDER. No wallet record or format changes. Two wallet_encryption_tests cases force each interleaving through new test hooks on real SQLite. On the base, one deadlocks and the other leaves 4 plaintext PQC key records in the encrypted wallet. Both pass with this change. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
304dba5 to
68606aa
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
GetKeys read the encryption state under cs_desc_man, then took the encryption key, then copied the key maps under a second cs_desc_man hold, and PrepareTopUp read the state and the key again. An encryption or an unlock between those steps could leave a top-up with an encryption key but no keys to derive from, or with plaintext keys under a state that says encrypted, while CheckTopUpPreparation only checked the last read. GetKeys now reads the state and copies both maps under one hold, then takes the key once, and PrepareTopUp keeps that state and key. The new wallet_encryption_tests returned util::Result<void> through std::future, which MSVC rejects because Result's assignment operators are deleted. The test threads now return whether the top-up succeeded. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@codex review |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
…e v1.0.1 notes The notes predated #270, #277 and #289, and the 2026-11-04 review of the v1.0.1 change set found that they left out the deferred wallet and IPC findings. - #270: a normal entry replaces the DerivePQCKey known limitation and the qualifiers in the summary and #268's entry. The 17 KiB figure is scoped to the library, and qbit's calls need at least 32 KiB for the new wipe. - #277: fold in release-notes-277.md. How to Upgrade gains the guidance for wallets encrypted by v1.0.0 that may still hold unencrypted PQC keys, and a downgrade statement. - #289: fold in release-notes-278.md as a new Mining interface section, and add the IPC client requirement under Behavior changes. - Known limitations add the deferred findings #279-#296 and #304, each with what users should do. The #143 entry now says which paths resume a pending keypool refill. - The fuzz-anchor entry and the fuzz-evidence caveat cover #270 and #342. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A v1.0.0 top-up that raced encryptwallet could commit plaintext walletdescriptorpqckey records into the encrypted wallet (#277). On load, validation adopted those keys into m_map_pqc_keys. getwalletinfo then reported status complete and encryption_recommended false. Every counter reservation for such a key rewrote its plaintext record, and nothing ever erased the record, so backupwallet copied it. An encrypted wallet now keeps validated plaintext records out of the signing maps and refuses their keys in every provider and counter reservation. A key that also has a crypted record is refused too, and so is a failed record. getwalletinfo reports the state in the new pqc_key_validation.reencryption_required field, and the GUI shows a warning. It is also set while records are still being validated. Unencrypted wallets keep adopting validated keys as before. While the field is set, signing_blocked is true, and the signing RPCs and GUI calls fail with an error that names the cause and the remedy. walletpassphrase and the GUI unlock call the new ReencryptPlaintextPQCKeys after the unlock has released cs_wallet. Like Lock(), it waits for active signers under m_relock_mutex before it takes cs_wallet, every descriptor lock and the writer. In one transaction it writes a crypted record with an auth tag for each validated plaintext record, which erases the plaintext one. A key that already has a crypted record keeps that key at the higher of the two counters. The transaction also erases the POST_ENCRYPTION_REWRITE record. The in-memory maps change only after the commit, and then RewriteAfterEncryption rewrites the file, still under the descriptor locks. If the process stops or the rewrite fails, the wallet is rewritten at its next load or backup. A failed re-encryption changes nothing and the next unlock retries it. Holding m_relock_mutex makes walletlock and the timed relock wait until the work is done. When there is nothing to do, it only reads the state. ChangeWalletPassphrase and EncryptWallet do not call it. Validation that finishes while the wallet is unlocked calls it as well; otherwise the next unlock does. CheckDecryptionKey no longer upgrades a legacy crypted record while a plaintext record for the same key remains, because that write would erase the plaintext record at the lower counter. WalletBatch::WriteCryptedDescriptorPQCKey ignored the result of erasing the plaintext record, so a failed erase inside a transaction that still committed looked like a clean re-encryption. It now returns that result. Erasing a missing record succeeds, so its other callers only see a new failure if the erase really fails. DescriptorScriptPubKeyMan::Encrypt now checks it and fails, which aborts EncryptWallet as before. A top-up, a counter reservation and the legacy tag upgrade at unlock already fail on false. walletpassphrase catches an exception from the re-encryption, so the relock is always scheduled. The GUI tooltip for validation in progress no longer calls an encrypted wallet unencrypted. Two wallet_p2mr_crypted_provider_tests cases asserted that a validated plaintext key in an encrypted, unlocked wallet signs. They now check that it is refused until re-encrypted, and signs afterwards. The new wallet_p2mr_plaintext_reencryption_tests and wallet_p2mr_plaintext_reencryption.py build the v1.0.0 state from real records. With the fix disabled they fail, and on that build spending rewrote the key's plaintext record from counter 52 to 53. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Until the first unlock re-encrypts them, an affected wallet keeps its plaintext walletdescriptorpqckey records, and backupwallet and the GUI's backup copied them with no warning. A backup taken right after upgrading was one more copy of the keys, which re-encryption can never reach (#321). BackupWallet now refuses while pqc_key_validation.reencryption_required is true. It checks under the cs_wallet it holds through the copy, which re-encryption also needs. backupwallet fails with -13 (RPC_WALLET_UNLOCK_NEEDED), so scripts can tell this case apart, and names the remedy: an unlock, and, for records that failed validation, which no unlock re-encrypts, the override after it. That new optional argument, allow_unencrypted_pqc_keys, backs up anyway; qbit-cli converts it as a bool. The GUI cannot pass it, so its message also names #300's qbit-wallet dump route. The GUI has no unlock action either, so its tooltips for such a wallet now say how to unlock it, and that backups are refused. The #283 release note now covers backups, including scheduled backupwallet jobs, which fail after the upgrade until the wallet has been unlocked once. It also takes over the correction of #277's note, which says this release does not re-encrypt such keys; #277's note is back to its 1.x.x text, because #181 folds and deletes it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A v1.0.0 top-up that raced encryptwallet could commit plaintext walletdescriptorpqckey records into the encrypted wallet (#277). On load, validation adopted those keys into m_map_pqc_keys. getwalletinfo then reported status complete and encryption_recommended false. Every counter reservation for such a key rewrote its plaintext record, and nothing ever erased the record, so backupwallet copied it. An encrypted wallet now keeps validated plaintext records out of the signing maps and refuses their keys in every provider and counter reservation. A key that also has a crypted record is refused too, and so is a failed record. getwalletinfo reports the state in the new pqc_key_validation.reencryption_required field, and the GUI shows a warning. It is also set while records are still being validated. Unencrypted wallets keep adopting validated keys as before. While the field is set, signing_blocked is true, and the signing RPCs and GUI calls fail with an error that names the cause and the remedy. walletpassphrase and the GUI unlock call the new ReencryptPlaintextPQCKeys after the unlock has released cs_wallet. Like Lock(), it waits for active signers under m_relock_mutex before it takes cs_wallet, every descriptor lock and the writer. In one transaction it writes a crypted record with an auth tag for each validated plaintext record, which erases the plaintext one. A key that already has a crypted record keeps that key at the higher of the two counters. The transaction also erases the POST_ENCRYPTION_REWRITE record. The in-memory maps change only after the commit, and then RewriteAfterEncryption rewrites the file, still under the descriptor locks. If the process stops or the rewrite fails, the wallet is rewritten at its next load or backup. A failed re-encryption changes nothing and the next unlock retries it. Holding m_relock_mutex makes walletlock and the timed relock wait until the work is done. When there is nothing to do, it only reads the state. ChangeWalletPassphrase and EncryptWallet do not call it. Validation that finishes while the wallet is unlocked calls it as well; otherwise the next unlock does. CheckDecryptionKey no longer upgrades a legacy crypted record while a plaintext record for the same key remains, because that write would erase the plaintext record at the lower counter. WalletBatch::WriteCryptedDescriptorPQCKey ignored the result of erasing the plaintext record, so a failed erase inside a transaction that still committed looked like a clean re-encryption. It now returns that result. Erasing a missing record succeeds, so its other callers only see a new failure if the erase really fails. DescriptorScriptPubKeyMan::Encrypt now checks it and fails, which aborts EncryptWallet as before. A top-up, a counter reservation and the legacy tag upgrade at unlock already fail on false. walletpassphrase catches an exception from the re-encryption, so the relock is always scheduled. The GUI tooltip for validation in progress no longer calls an encrypted wallet unencrypted. Two wallet_p2mr_crypted_provider_tests cases asserted that a validated plaintext key in an encrypted, unlocked wallet signs. They now check that it is refused until re-encrypted, and signs afterwards. The new wallet_p2mr_plaintext_reencryption_tests and wallet_p2mr_plaintext_reencryption.py build the v1.0.0 state from real records. With the fix disabled they fail, and on that build spending rewrote the key's plaintext record from counter 52 to 53. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Until the first unlock re-encrypts them, an affected wallet keeps its plaintext walletdescriptorpqckey records, and backupwallet and the GUI's backup copied them with no warning. A backup taken right after upgrading was one more copy of the keys, which re-encryption can never reach (#321). BackupWallet now refuses while pqc_key_validation.reencryption_required is true. It checks under the cs_wallet it holds through the copy, which re-encryption also needs. backupwallet fails with -13 (RPC_WALLET_UNLOCK_NEEDED), so scripts can tell this case apart, and names the remedy: an unlock, and, for records that failed validation, which no unlock re-encrypts, the override after it. That new optional argument, allow_unencrypted_pqc_keys, backs up anyway; qbit-cli converts it as a bool. The GUI cannot pass it, so its message also names #300's qbit-wallet dump route. The GUI has no unlock action either, so its tooltips for such a wallet now say how to unlock it, and that backups are refused. The #283 release note now covers backups, including scheduled backupwallet jobs, which fail after the upgrade until the wallet has been unlocked once. It also takes over the correction of #277's note, which says this release does not re-encrypt such keys; #277's note is back to its 1.x.x text, because #181 folds and deletes it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
…e v1.0.1 notes The notes predated #270, #277 and #289, and the 2026-11-04 review of the v1.0.1 change set found that they left out the deferred wallet and IPC findings. - #270: a normal entry replaces the DerivePQCKey known limitation and the qualifiers in the summary and #268's entry. The 17 KiB figure is scoped to the library, and qbit's calls need at least 32 KiB for the new wipe. - #277: fold in release-notes-277.md. How to Upgrade gains the guidance for wallets encrypted by v1.0.0 that may still hold unencrypted PQC keys, and a downgrade statement. - #289: fold in release-notes-278.md as a new Mining interface section, and add the IPC client requirement under Behavior changes. - Known limitations add the deferred findings #279-#296 and #304, each with what users should do. The #143 entry now says which paths resume a pending keypool refill. - The fuzz-anchor entry and the fuzz-evidence caveat cover #270 and #342. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
A v1.0.0 top-up that raced encryptwallet could commit plaintext walletdescriptorpqckey records into the encrypted wallet (#277). On load, validation adopted those keys into m_map_pqc_keys. getwalletinfo then reported status complete and encryption_recommended false. Every counter reservation for such a key rewrote its plaintext record, and nothing ever erased the record, so backupwallet copied it. An encrypted wallet now keeps validated plaintext records out of the signing maps and refuses their keys in every provider and counter reservation. A key that also has a crypted record is refused too, and so is a failed record. getwalletinfo reports the state in the new pqc_key_validation.reencryption_required field, and the GUI shows a warning. It is also set while records are still being validated. Unencrypted wallets keep adopting validated keys as before. While the field is set, signing_blocked is true, and the signing RPCs and GUI calls fail with an error that names the cause and the remedy. walletpassphrase and the GUI unlock call the new ReencryptPlaintextPQCKeys after the unlock has released cs_wallet. Like Lock(), it waits for active signers under m_relock_mutex before it takes cs_wallet, every descriptor lock and the writer. In one transaction it writes a crypted record with an auth tag for each validated plaintext record, which erases the plaintext one. A key that already has a crypted record keeps that key at the higher of the two counters. The transaction also erases the POST_ENCRYPTION_REWRITE record. The in-memory maps change only after the commit, and then RewriteAfterEncryption rewrites the file, still under the descriptor locks. If the process stops or the rewrite fails, the wallet is rewritten at its next load or backup. A failed re-encryption changes nothing and the next unlock retries it. Holding m_relock_mutex makes walletlock and the timed relock wait until the work is done. When there is nothing to do, it only reads the state. ChangeWalletPassphrase and EncryptWallet do not call it. Validation that finishes while the wallet is unlocked calls it as well; otherwise the next unlock does. CheckDecryptionKey no longer upgrades a legacy crypted record while a plaintext record for the same key remains, because that write would erase the plaintext record at the lower counter. WalletBatch::WriteCryptedDescriptorPQCKey ignored the result of erasing the plaintext record, so a failed erase inside a transaction that still committed looked like a clean re-encryption. It now returns that result. Erasing a missing record succeeds, so its other callers only see a new failure if the erase really fails. DescriptorScriptPubKeyMan::Encrypt now checks it and fails, which aborts EncryptWallet as before. A top-up, a counter reservation and the legacy tag upgrade at unlock already fail on false. walletpassphrase catches an exception from the re-encryption, so the relock is always scheduled. The GUI tooltip for validation in progress no longer calls an encrypted wallet unencrypted. Two wallet_p2mr_crypted_provider_tests cases asserted that a validated plaintext key in an encrypted, unlocked wallet signs. They now check that it is refused until re-encrypted, and signs afterwards. The new wallet_p2mr_plaintext_reencryption_tests and wallet_p2mr_plaintext_reencryption.py build the v1.0.0 state from real records. With the fix disabled they fail, and on that build spending rewrote the key's plaintext record from counter 52 to 53. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Until the first unlock re-encrypts them, an affected wallet keeps its plaintext walletdescriptorpqckey records, and backupwallet and the GUI's backup copied them with no warning. A backup taken right after upgrading was one more copy of the keys, which re-encryption can never reach (#321). BackupWallet now refuses while pqc_key_validation.reencryption_required is true. It checks under the cs_wallet it holds through the copy, which re-encryption also needs. backupwallet fails with -13 (RPC_WALLET_UNLOCK_NEEDED), so scripts can tell this case apart, and names the remedy: an unlock, and, for records that failed validation, which no unlock re-encrypts, the override after it. That new optional argument, allow_unencrypted_pqc_keys, backs up anyway; qbit-cli converts it as a bool. The GUI cannot pass it, so its message also names #300's qbit-wallet dump route. The GUI has no unlock action either, so its tooltips for such a wallet now say how to unlock it, and that backups are refused. The #283 release note now covers backups, including scheduled backupwallet jobs, which fail after the upgrade until the wallet has been unlocked once. It also takes over the correction of #277's note, which says this release does not re-encrypt such keys; #277's note is back to its 1.x.x text, because #181 folds and deletes it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A v1.0.0 top-up that raced encryptwallet could commit plaintext walletdescriptorpqckey records into the encrypted wallet (#277). On load, validation adopted those keys into m_map_pqc_keys. getwalletinfo then reported status complete and encryption_recommended false. Every counter reservation for such a key rewrote its plaintext record, and nothing ever erased the record, so backupwallet copied it. An encrypted wallet now keeps validated plaintext records out of the signing maps and refuses their keys in every provider and counter reservation. A key that also has a crypted record is refused too, and so is a failed record. getwalletinfo reports the state in the new pqc_key_validation.reencryption_required field, and the GUI shows a warning. It is also set while records are still being validated. Unencrypted wallets keep adopting validated keys as before. While the field is set, signing_blocked is true, and the signing RPCs and GUI calls fail with an error that names the cause and the remedy. walletpassphrase and the GUI unlock call the new ReencryptPlaintextPQCKeys after the unlock has released cs_wallet. Like Lock(), it waits for active signers under m_relock_mutex before it takes cs_wallet, every descriptor lock and the writer. In one transaction it writes a crypted record with an auth tag for each validated plaintext record, which erases the plaintext one. A key that already has a crypted record keeps that key at the higher of the two counters. The transaction also erases the POST_ENCRYPTION_REWRITE record. The in-memory maps change only after the commit, and then RewriteAfterEncryption rewrites the file, still under the descriptor locks. If the process stops or the rewrite fails, the wallet is rewritten at its next load or backup. A failed re-encryption changes nothing and the next unlock retries it. Holding m_relock_mutex makes walletlock and the timed relock wait until the work is done. When there is nothing to do, it only reads the state. ChangeWalletPassphrase and EncryptWallet do not call it. Validation that finishes while the wallet is unlocked calls it as well; otherwise the next unlock does. CheckDecryptionKey no longer upgrades a legacy crypted record while a plaintext record for the same key remains, because that write would erase the plaintext record at the lower counter. WalletBatch::WriteCryptedDescriptorPQCKey ignored the result of erasing the plaintext record, so a failed erase inside a transaction that still committed looked like a clean re-encryption. It now returns that result. Erasing a missing record succeeds, so its other callers only see a new failure if the erase really fails. DescriptorScriptPubKeyMan::Encrypt now checks it and fails, which aborts EncryptWallet as before. A top-up, a counter reservation and the legacy tag upgrade at unlock already fail on false. walletpassphrase catches an exception from the re-encryption, so the relock is always scheduled. The GUI tooltip for validation in progress no longer calls an encrypted wallet unencrypted. Two wallet_p2mr_crypted_provider_tests cases asserted that a validated plaintext key in an encrypted, unlocked wallet signs. They now check that it is refused until re-encrypted, and signs afterwards. The new wallet_p2mr_plaintext_reencryption_tests and wallet_p2mr_plaintext_reencryption.py build the v1.0.0 state from real records. With the fix disabled they fail, and on that build spending rewrote the key's plaintext record from counter 52 to 53. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Until the first unlock re-encrypts them, an affected wallet keeps its plaintext walletdescriptorpqckey records, and backupwallet and the GUI's backup copied them with no warning. A backup taken right after upgrading was one more copy of the keys, which re-encryption can never reach (#321). BackupWallet now refuses while pqc_key_validation.reencryption_required is true. It checks under the cs_wallet it holds through the copy, which re-encryption also needs. backupwallet fails with -13 (RPC_WALLET_UNLOCK_NEEDED), so scripts can tell this case apart, and names the remedy: an unlock, and, for records that failed validation, which no unlock re-encrypts, the override after it. That new optional argument, allow_unencrypted_pqc_keys, backs up anyway; qbit-cli converts it as a bool. The GUI cannot pass it, so its message also names #300's qbit-wallet dump route. The GUI has no unlock action either, so its tooltips for such a wallet now say how to unlock it, and that backups are refused. The #283 release note now covers backups, including scheduled backupwallet jobs, which fail after the upgrade until the wallet has been unlocked once. It also takes over the correction of #277's note, which says this release does not re-encrypt such keys; #277's note is back to its 1.x.x text, because #181 folds and deletes it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…301) * wallet: re-encrypt plaintext PQC keys in encrypted wallets on unlock A v1.0.0 top-up that raced encryptwallet could commit plaintext walletdescriptorpqckey records into the encrypted wallet (#277). On load, validation adopted those keys into m_map_pqc_keys. getwalletinfo then reported status complete and encryption_recommended false. Every counter reservation for such a key rewrote its plaintext record, and nothing ever erased the record, so backupwallet copied it. An encrypted wallet now keeps validated plaintext records out of the signing maps and refuses their keys in every provider and counter reservation. A key that also has a crypted record is refused too, and so is a failed record. getwalletinfo reports the state in the new pqc_key_validation.reencryption_required field, and the GUI shows a warning. It is also set while records are still being validated. Unencrypted wallets keep adopting validated keys as before. While the field is set, signing_blocked is true, and the signing RPCs and GUI calls fail with an error that names the cause and the remedy. walletpassphrase and the GUI unlock call the new ReencryptPlaintextPQCKeys after the unlock has released cs_wallet. Like Lock(), it waits for active signers under m_relock_mutex before it takes cs_wallet, every descriptor lock and the writer. In one transaction it writes a crypted record with an auth tag for each validated plaintext record, which erases the plaintext one. A key that already has a crypted record keeps that key at the higher of the two counters. The transaction also erases the POST_ENCRYPTION_REWRITE record. The in-memory maps change only after the commit, and then RewriteAfterEncryption rewrites the file, still under the descriptor locks. If the process stops or the rewrite fails, the wallet is rewritten at its next load or backup. A failed re-encryption changes nothing and the next unlock retries it. Holding m_relock_mutex makes walletlock and the timed relock wait until the work is done. When there is nothing to do, it only reads the state. ChangeWalletPassphrase and EncryptWallet do not call it. Validation that finishes while the wallet is unlocked calls it as well; otherwise the next unlock does. CheckDecryptionKey no longer upgrades a legacy crypted record while a plaintext record for the same key remains, because that write would erase the plaintext record at the lower counter. WalletBatch::WriteCryptedDescriptorPQCKey ignored the result of erasing the plaintext record, so a failed erase inside a transaction that still committed looked like a clean re-encryption. It now returns that result. Erasing a missing record succeeds, so its other callers only see a new failure if the erase really fails. DescriptorScriptPubKeyMan::Encrypt now checks it and fails, which aborts EncryptWallet as before. A top-up, a counter reservation and the legacy tag upgrade at unlock already fail on false. walletpassphrase catches an exception from the re-encryption, so the relock is always scheduled. The GUI tooltip for validation in progress no longer calls an encrypted wallet unencrypted. Two wallet_p2mr_crypted_provider_tests cases asserted that a validated plaintext key in an encrypted, unlocked wallet signs. They now check that it is refused until re-encrypted, and signs afterwards. The new wallet_p2mr_plaintext_reencryption_tests and wallet_p2mr_plaintext_reencryption.py build the v1.0.0 state from real records. With the fix disabled they fail, and on that build spending rewrote the key's plaintext record from counter 52 to 53. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: add release notes for #283 Co-Authored-By: Claude Opus 5.5 <[email protected]> * wallet: verify the master key before re-encrypting, and contain errors A local review of the re-encryption found five gaps. ReencryptPlaintextPQCKeys trusted any key that unlocked the wallet. If no manager holds a crypted key, CheckDecryptionKey passes for every master key, so a wrong passphrase whose decryption happens to pass the padding check unlocks the wallet. Re-encrypting under that key and erasing the plaintext records would lose the keys. It now re-encrypts only if some crypted key exists, which the unlock decrypted. ReencryptPlaintextPQCKeys can throw, for example on a database error. Its callers run on the GUI thread, on the scheduler thread, which rethrows and stops the node, and in walletpassphrase before the relock is scheduled. It now logs the exception and returns false itself, which leaves the records reported and refused, as a failed re-encryption does. walletpassphrase computed nRelockTime before the re-encryption and its database rewrite, but scheduled the relock nSleepTime after them, so a long rewrite kept the wallet unlocked past unlocked_until. It now moves the deadline to after the re-encryption has returned. A top-up that reached the index of a key whose plaintext record failed validation wrote a fresh record for it at counter 0, which erased the failed record. In an encrypted wallet the new crypted record's auth tag also disagreed with the counter in memory. HavePQCKeyRecord now counts failed records, so the top-up leaves the record and the key stays blocked until the wallet is restored or repaired. GetPQCSignatureCounter took the higher counter of a key's plaintext and crypted records only once the plaintext record was validated, and reported the crypted record's lower counter while it was pending. WriteReencryptedPQCKeys could also write a key in both plaintext maps twice, the second time without the higher counter. No current caller puts a key in both, but it now skips the duplicate. Co-Authored-By: Claude Opus 5.5 <[email protected]> * wallet: refuse backups that would copy plaintext PQC keys Until the first unlock re-encrypts them, an affected wallet keeps its plaintext walletdescriptorpqckey records, and backupwallet and the GUI's backup copied them with no warning. A backup taken right after upgrading was one more copy of the keys, which re-encryption can never reach (#321). BackupWallet now refuses while pqc_key_validation.reencryption_required is true. It checks under the cs_wallet it holds through the copy, which re-encryption also needs. backupwallet fails with -13 (RPC_WALLET_UNLOCK_NEEDED), so scripts can tell this case apart, and names the remedy: an unlock, and, for records that failed validation, which no unlock re-encrypts, the override after it. That new optional argument, allow_unencrypted_pqc_keys, backs up anyway; qbit-cli converts it as a bool. The GUI cannot pass it, so its message also names #300's qbit-wallet dump route. The GUI has no unlock action either, so its tooltips for such a wallet now say how to unlock it, and that backups are refused. The #283 release note now covers backups, including scheduled backupwallet jobs, which fail after the upgrade until the wallet has been unlocked once. It also takes over the correction of #277's note, which says this release does not re-encrypt such keys; #277's note is back to its 1.x.x text, because #181 folds and deletes it. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…6-11-05 Fold in #297, #298, #299, #319, #344, #346, #347 and #348 from the reviewed draft, and #300, #301, #343 and #353 from their fragments: the post-encryption rewrite and its disk space and first-load cost, the re-encryption of PQC keys v1.0.0 left unencrypted and how to unlock for it in qbit-qt, the new backupwallet and getwalletinfo fields, PSBT Sign re-entrancy, and the macOS debug symbol archives. Update the How to Upgrade, downgrade, #277 and Known limitations text these change, remove the limitations fixed since, and extend the fuzz-evidence list. Delete the per-PR fragments the notes now cover. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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]>
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]>
…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]>
…e v1.0.1 notes The notes predated #270, #277 and #289, and the 2026-11-04 review of the v1.0.1 change set found that they left out the deferred wallet and IPC findings. - #270: a normal entry replaces the DerivePQCKey known limitation and the qualifiers in the summary and #268's entry. The 17 KiB figure is scoped to the library, and qbit's calls need at least 32 KiB for the new wipe. - #277: fold in release-notes-277.md. How to Upgrade gains the guidance for wallets encrypted by v1.0.0 that may still hold unencrypted PQC keys, and a downgrade statement. - #289: fold in release-notes-278.md as a new Mining interface section, and add the IPC client requirement under Behavior changes. - Known limitations add the deferred findings #279-#296 and #304, each with what users should do. The #143 entry now says which paths resume a pending keypool refill. - The fuzz-anchor entry and the fuzz-evidence caveat cover #270 and #342. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…6-11-05 Fold in #297, #298, #299, #319, #344, #346, #347 and #348 from the reviewed draft, and #300, #301, #343 and #353 from their fragments: the post-encryption rewrite and its disk space and first-load cost, the re-encryption of PQC keys v1.0.0 left unencrypted and how to unlock for it in qbit-qt, the new backupwallet and getwalletinfo fields, PSBT Sign re-entrancy, and the macOS debug symbol archives. Update the How to Upgrade, downgrade, #277 and Known limitations text these change, remove the limitations fixed since, and extend the fuzz-evidence list. Delete the per-PR fragments the notes now cover. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e v1.0.1 notes The notes predated #270, #277 and #289, and the 2026-11-04 review of the v1.0.1 change set found that they left out the deferred wallet and IPC findings. - #270: a normal entry replaces the DerivePQCKey known limitation and the qualifiers in the summary and #268's entry. The 17 KiB figure is scoped to the library, and qbit's calls need at least 32 KiB for the new wipe. - #277: fold in release-notes-277.md. How to Upgrade gains the guidance for wallets encrypted by v1.0.0 that may still hold unencrypted PQC keys, and a downgrade statement. - #289: fold in release-notes-278.md as a new Mining interface section, and add the IPC client requirement under Behavior changes. - Known limitations add the deferred findings #279-#296 and #304, each with what users should do. The #143 entry now says which paths resume a pending keypool refill. - The fuzz-anchor entry and the fuzz-evidence caveat cover #270 and #342. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…6-11-05 Fold in #297, #298, #299, #319, #344, #346, #347 and #348 from the reviewed draft, and #300, #301, #343 and #353 from their fragments: the post-encryption rewrite and its disk space and first-load cost, the re-encryption of PQC keys v1.0.0 left unencrypted and how to unlock for it in qbit-qt, the new backupwallet and getwalletinfo fields, PSBT Sign re-entrancy, and the macOS debug symbol archives. Update the How to Upgrade, downgrade, #277 and Known limitations text these change, remove the limitations fixed since, and extend the fuzz-evidence list. Delete the per-PR fragments the notes now cover. Co-Authored-By: Claude Opus 5.5 <[email protected]>
* doc: add v1.0.1 release notes Cover every pull request merged to 1.x.x since the signed v1.0.0 tag, through #252. List the behavior changes first: the -fallbackfee default (#151), fee-only send entries (#150), and the encryptwallet overlap error code moving from -16 to -15 (#183). Record the release's known limitations: the unsigned-platform waiver (#70), the depth of the fuzz evidence (#173), and scheduled-workflow deployment (#152, #158). The required P2MR v1 conformance statement names the signed tag target and the oracle report digest, so the in-tree notes point to the release page, and the publish-time notes file carries the exact statement. Fold the #150 and #151 fragments into these notes and remove them. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * build: bump version to v1.0.1 Set CLIENT_VERSION_BUILD to 1 so the source identifies as v1.0.1, the maintenance release proposed in #174. It ships without a release candidate, so CLIENT_VERSION_RC stays 0. CLIENT_VERSION_IS_RELEASE stays true: 1.x.x is the release line, so its binaries carry no commit suffix, as for v1.0.0. CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR and CLIENT_VERSION_PHASE are unchanged. CLIENT_VERSION_STRING becomes 1.0.1, so every binary reports v1.0.1, the user agent is /qbit:1.0.1/, the Windows installer metadata and the RPC docs manifest derive from the same string, and Guix and the release validators derive 1.0.1 from a v1.0.1 tag. Regenerate the manual pages from the built binaries with contrib/devtools/gen-manpages.py (help2man 1.49.3). Only the version and date lines change. util_tests/test_FormatSubVersion expected the "Test" client name to format as CLIENT_VERSION_STRING. FormatSubVersion uses that string only for the qbit user agent and formats any other name numerically, so the check holds only while the version has no phase or release-candidate suffix. Expect the numeric form built from the version components, which holds for every version. The qbit user-agent checks on the next lines still cover CLIENT_VERSION_STRING. No other tracked file carries the release version. The README and doc mentions of v1.0.0 describe the launch source, and the 1.0.0 entries in the workflows are branch names, so they are left alone. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: add the release-gate fixes to the v1.0.1 release notes Fold the release-notes fragments of #264, #265, #266 and #268 into doc/release-notes-1.0.1.md and delete them, and write the #263 entry from its pull request. #263's new P2MR stack-byte standardness rule is also listed under the behavior changes. Correct claims these merges made stale: - the fuzz-evidence limitation said later changes touch no fuzzed code; #263 and #265 change the interpreter that p2mr_script runs, and #268 replaces the library that pqc and p2mr_script call, so fresh evidence on the release source is now required before tagging; - the #162 entry said data signatures are unchanged (#265 caches them); - the no-measurement line now points to #268's library cost figures; - the #252 entry now notes the later #264 and #263 profile edits. Also correct the #183 entry, which said every other encryptwallet failure returns -16; some return -4 or -8. Record the deferred items under Known limitations: the consensus stack-byte cap (#257), uncached failed PQC signature checks (#259), and the remaining AuxPoW limits and open review notes from #266 (#258). Refs #174. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: record the remaining v1.0.1 limitations in the release notes Address the independent review of the v1.0.1 notes: - record that DerivePQCKey still leaves HD seed material and HKDF state in its own stack frame, which #268's library wipe does not reach and #270 would clear, and qualify the summary and the #268 entry; - qualify #163's retry claim and record its pre-existing serial-fallback re-signing as a known limitation; - say how v1.0.0 receivers handle headers messages cut short for size, matching the Known limitations entry; - list every installed Linux binary in the upgrade steps; - say that docs.qbit.org is already served by the earlier Pages workflow and only the versioned site from #148 is undeployed; - give the nightly fuzz mutation phase the Known limitations entry its pointer refers to, and credit #164 for the Qt shutdown-test fix. Refs #174. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: add the area-review findings to the v1.0.1 release notes Release notes: - add an Updated RPCs section: bumpfee rejects a replacement whose signer changed anything but input signatures, and revalidates the replacement at commit time (#167, which shipped the unmerged #146); send entries can omit vout, address and label (#150); list the new bumpfee failures under the behavior changes as well; - restate #268's cost from the release review's measurements, with the SHA backends they cover; - add Known limitations for per-descriptor PQC signature counters, the qbit-qt Send dialog signing while it prepares, and the platforms on which the libbitcoinpqc stack-wipe depth is verified. doc/consensus/p2mr-v1.md: correct the non-normative section 9 sentence from #264, which implied wallet-wide per-key counting. Wallet counters enforce the 2^30 contract per descriptor and per wallet copy. No normative text changes, but the specification bytes do, so the P2MR v1 consensus review must cite a commit that contains this change. share/examples/qbit.conf: show the -fallbackfee default from #151, as contrib/devtools/gen-qbit-conf.sh generates it. The generator's other difference, the lock debug category, appears only in Debug builds and is left out. Refs #174. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: cover #270, #277 and #289 and the deferred review findings in the v1.0.1 notes The notes predated #270, #277 and #289, and the 2026-11-04 review of the v1.0.1 change set found that they left out the deferred wallet and IPC findings. - #270: a normal entry replaces the DerivePQCKey known limitation and the qualifiers in the summary and #268's entry. The 17 KiB figure is scoped to the library, and qbit's calls need at least 32 KiB for the new wipe. - #277: fold in release-notes-277.md. How to Upgrade gains the guidance for wallets encrypted by v1.0.0 that may still hold unencrypted PQC keys, and a downgrade statement. - #289: fold in release-notes-278.md as a new Mining interface section, and add the IPC client requirement under Behavior changes. - Known limitations add the deferred findings #279-#296 and #304, each with what users should do. The #143 entry now says which paths resume a pending keypool refill. - The fuzz-anchor entry and the fuzz-evidence caveat cover #270 and #342. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: correct v1.0.1 notes and docs from the release review Release notes: - fallback fee (#307): the floor is only this node's minimum relay fee, -mintxfee and mempool minimum. Peers with a higher minimum, or a congested network, may not relay or mine a fallback-rate send until its fee is bumped. Note the bump cost for P2MR, -fallbackfee=0 for services that prefer failure, and the 60-hour estimate staleness; - #268 cost (#311): production mode pins the library's SHA-2 to its portable code on every platform, so SHA-NI, ARMv8 SHA and CommonCrypto are never used; AVX2 still speeds up keygen and signing. Restate the measured figures for that backend, drop the SHA-NI and test-knob-only scalar figures, list what was not measured, and remove the CommonCrypto clause from the stack-wipe limitation; - low-work headers sync (#309) cannot complete from any peer through a dense AuxPoW range and retries at each announcement; - the -15 encryptwallet wording, the libexec binaries in the upgrade steps (#339), the #163 planner wording (#330), the #337 docs deploy, and drop "reviewed" from the summary (#315). doc/user/bitcoin-core-differences.md (#330): add the 1 MiB P2MR stack-byte policy limit and its reject reason, and correct the data-signature charge to 3,683 with the testnet4 and regtest legacy cases. doc/subtrees/libbitcoinpqc.md (#333): direct library calls need about 17 KiB of stack; qbit's CPQCKey and DerivePQCKey calls need at least 32 KiB plus frames for the #270 wipe. Remove the v1.0.0 fragments release-notes-95, -102, -128 and -132 (#340), which shipped at v1.0.0 and are referenced nowhere. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: update the v1.0.1 release notes for the changes merged since 2026-11-05 Fold in #297, #298, #299, #319, #344, #346, #347 and #348 from the reviewed draft, and #300, #301, #343 and #353 from their fragments: the post-encryption rewrite and its disk space and first-load cost, the re-encryption of PQC keys v1.0.0 left unencrypted and how to unlock for it in qbit-qt, the new backupwallet and getwalletinfo fields, PSBT Sign re-entrancy, and the macOS debug symbol archives. Update the How to Upgrade, downgrade, #277 and Known limitations text these change, remove the limitations fixed since, and extend the fuzz-evidence list. Delete the per-PR fragments the notes now cover. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: regenerate the v1.0.1 manual pages Regenerate doc/man with contrib/devtools/gen-manpages.py from binaries built at the merged tree. Apart from the date, only the -discardfee help in qbitd.1 and qbit-qt.1 changes, for the limit #346 added when there is no fee estimate. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: correct the v1.0.1 release notes from the launch review - #268: libbitcoinpqc v0.3.2 verification is about 7 to 8% slower in a production-mode x86-64 micro-benchmark, from the wipe of the SHA-256 and SHA-512 finalize buffers it added, and a mainnet -reindex-chainstate on the same machine took about 5 to 8% longer than with v1.0.0. The notes said verification showed no change, and that no throughput or IBD measurement accompanied the release. - #293 is fixed by #300 (DelAddressBook takes cs_wallet before its transaction): move it from Known limitations to Wallet fixes. - #166: the Sign/Verify dialog shows the lowercase state name, such as "normal". - #266: add the mainnet mixed-version sync result and the advice to upgrade nodes that accept inbound connections first. - Add known limitations for #364 (PSBT Save's file dialog leaves Sign and Close reachable through accessibility tools) and #365 (coin control's change preview). Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: regenerate the example config and drop an internal note from the v1.0.1 notes Regenerate share/examples/qbit.conf with contrib/devtools/gen-qbit-conf.sh from the v1.0.1 build, so the -discardfee description carries the sentence that #346 added to the help, as the regenerated manual pages do. The "lock" debug category is only compiled into builds with DEBUG_LOCKCONTENTION, so a release build does not list it. Drop the known-limitations item about the scope of the release readiness inspection: it describes release-process status, not a limitation users need to know about. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: cover the PRs merged since the last v1.0.1 notes update Add entries for the eleven PRs merged into 1.x.x after 0a936d6: #379 (walletpassphrasechange keeps the lock state) under Wallet fixes and Updated RPCs, #352 and #354 with the other qbit-qt fixes, folded from their fragments, #380 (NODE_WITNESS_PRUNED only from a peer's own version message) with the P2P changes, #381 in a new PHOTON section, and #371, #374, #375, #376, #377 and #385 under release engineering and CI. Mention the new fixes in the summary, update the encryptwallet and shutdown Known limitations for #352 and #354 (#349 is fixed), and add the new PRs to the fuzz-evidence list, with #380's addrman and net_processing change and the inherited targets that reach it. Delete the folded fragments release-notes-352.md and -354.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: cover the PRs merged for v1.0.1 since the last notes update Fold in #378, #386 with #422's edits, #411, #418 and #419 from their fragments, carry #411's edits to the deleted #304 fragment into the walletpassphrase text, and add entries for #387, #410, #414 and #415. Behavior changes add the P2MR hashing standardness rule (#415), the per-peer budget for validating rejected transactions with its debug-only -txvalidationbudget option (#386, #422), and walletpassphrase refilling the P2MR keypools before it returns, with the timeout counting from the end of the refill and a new -4 error on failure (#411). How to Upgrade adds the reconsiderblock line, and the qbit-photon interoperability sentence now matches #410. Known limitations drop #296, which #418 fixes, update the uncached failed PQC signature bullet for the validation budget, and extend the fuzz-evidence caveat with #386, #414, #415 and #422 and the inherited targets that reach them. Delete the per-PR fragments the notes now cover. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
* wallet: take descriptor locks before EncryptWallet's transaction CWallet::EncryptWallet held cs_wallet and the SQLite writer, then waited for each descriptor manager's cs_desc_man in DescriptorScriptPubKeyMan::Encrypt. The background P2MR top-ups (RunP2MRKeyPoolRefillStep, RunPendingInitialKeyPoolTopUpStep) take cs_desc_man without cs_wallet and then wait for the writer, so the two could deadlock. A top-up whose key snapshot predated the encryption also committed plaintext walletdescriptorpqckey records into the encrypted, locked wallet, which the next load accepted. Both bugs date from v1.0.0. EncryptWallet now takes every manager's cs_desc_man before it begins its transaction and holds them until the commit. That matches the cs_desc_man -> writer order the top-ups and address reservation already use. Because the first master key is now added under those locks, a top-up that reads the encryption state under its own cs_desc_man gets an answer that cannot change while it holds the lock. TopUpWithDBPreparedResult refuses a plaintext snapshot taken before the encryption, and the self-committing top-up makes the same check before it opens a transaction. A stale top-up therefore never waits for the writer and never has a transaction open during EncryptWallet's VACUUM rewrite. It fails like a locked-wallet attempt, and the next attempt takes a new snapshot. PrepareTopUp and GetKeys read the encryption state under cs_desc_man for the same reason. DescriptorScriptPubKeyMan::Encrypt now requires cs_desc_man, PrepareTopUp excludes it, and the snapshot check requires it, so Clang's thread-safety analysis checks those callers. A small ASSERT_EXCLUSIVE_LOCK helper tells the analysis about the locks EncryptWallet holds in a list, and checks them at runtime under DEBUG_LOCKORDER. No wallet record or format changes. Two wallet_encryption_tests cases force each interleaving through new test hooks on real SQLite. On the base, one deadlocks and the other leaves 4 plaintext PQC key records in the encrypted wallet. Both pass with this change. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: add release notes for #277 Co-Authored-By: Claude Opus 5.5 <[email protected]> * wallet: take a top-up's key snapshot under one lock GetKeys read the encryption state under cs_desc_man, then took the encryption key, then copied the key maps under a second cs_desc_man hold, and PrepareTopUp read the state and the key again. An encryption or an unlock between those steps could leave a top-up with an encryption key but no keys to derive from, or with plaintext keys under a state that says encrypted, while CheckTopUpPreparation only checked the last read. GetKeys now reads the state and copies both maps under one hold, then takes the key once, and PrepareTopUp keeps that state and key. The new wallet_encryption_tests returned util::Result<void> through std::future, which MSVC rejects because Result's assignment operators are deleted. The test threads now return whether the top-up succeeded. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…301) * wallet: re-encrypt plaintext PQC keys in encrypted wallets on unlock A v1.0.0 top-up that raced encryptwallet could commit plaintext walletdescriptorpqckey records into the encrypted wallet (#277). On load, validation adopted those keys into m_map_pqc_keys. getwalletinfo then reported status complete and encryption_recommended false. Every counter reservation for such a key rewrote its plaintext record, and nothing ever erased the record, so backupwallet copied it. An encrypted wallet now keeps validated plaintext records out of the signing maps and refuses their keys in every provider and counter reservation. A key that also has a crypted record is refused too, and so is a failed record. getwalletinfo reports the state in the new pqc_key_validation.reencryption_required field, and the GUI shows a warning. It is also set while records are still being validated. Unencrypted wallets keep adopting validated keys as before. While the field is set, signing_blocked is true, and the signing RPCs and GUI calls fail with an error that names the cause and the remedy. walletpassphrase and the GUI unlock call the new ReencryptPlaintextPQCKeys after the unlock has released cs_wallet. Like Lock(), it waits for active signers under m_relock_mutex before it takes cs_wallet, every descriptor lock and the writer. In one transaction it writes a crypted record with an auth tag for each validated plaintext record, which erases the plaintext one. A key that already has a crypted record keeps that key at the higher of the two counters. The transaction also erases the POST_ENCRYPTION_REWRITE record. The in-memory maps change only after the commit, and then RewriteAfterEncryption rewrites the file, still under the descriptor locks. If the process stops or the rewrite fails, the wallet is rewritten at its next load or backup. A failed re-encryption changes nothing and the next unlock retries it. Holding m_relock_mutex makes walletlock and the timed relock wait until the work is done. When there is nothing to do, it only reads the state. ChangeWalletPassphrase and EncryptWallet do not call it. Validation that finishes while the wallet is unlocked calls it as well; otherwise the next unlock does. CheckDecryptionKey no longer upgrades a legacy crypted record while a plaintext record for the same key remains, because that write would erase the plaintext record at the lower counter. WalletBatch::WriteCryptedDescriptorPQCKey ignored the result of erasing the plaintext record, so a failed erase inside a transaction that still committed looked like a clean re-encryption. It now returns that result. Erasing a missing record succeeds, so its other callers only see a new failure if the erase really fails. DescriptorScriptPubKeyMan::Encrypt now checks it and fails, which aborts EncryptWallet as before. A top-up, a counter reservation and the legacy tag upgrade at unlock already fail on false. walletpassphrase catches an exception from the re-encryption, so the relock is always scheduled. The GUI tooltip for validation in progress no longer calls an encrypted wallet unencrypted. Two wallet_p2mr_crypted_provider_tests cases asserted that a validated plaintext key in an encrypted, unlocked wallet signs. They now check that it is refused until re-encrypted, and signs afterwards. The new wallet_p2mr_plaintext_reencryption_tests and wallet_p2mr_plaintext_reencryption.py build the v1.0.0 state from real records. With the fix disabled they fail, and on that build spending rewrote the key's plaintext record from counter 52 to 53. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: add release notes for #283 Co-Authored-By: Claude Opus 5.5 <[email protected]> * wallet: verify the master key before re-encrypting, and contain errors A local review of the re-encryption found five gaps. ReencryptPlaintextPQCKeys trusted any key that unlocked the wallet. If no manager holds a crypted key, CheckDecryptionKey passes for every master key, so a wrong passphrase whose decryption happens to pass the padding check unlocks the wallet. Re-encrypting under that key and erasing the plaintext records would lose the keys. It now re-encrypts only if some crypted key exists, which the unlock decrypted. ReencryptPlaintextPQCKeys can throw, for example on a database error. Its callers run on the GUI thread, on the scheduler thread, which rethrows and stops the node, and in walletpassphrase before the relock is scheduled. It now logs the exception and returns false itself, which leaves the records reported and refused, as a failed re-encryption does. walletpassphrase computed nRelockTime before the re-encryption and its database rewrite, but scheduled the relock nSleepTime after them, so a long rewrite kept the wallet unlocked past unlocked_until. It now moves the deadline to after the re-encryption has returned. A top-up that reached the index of a key whose plaintext record failed validation wrote a fresh record for it at counter 0, which erased the failed record. In an encrypted wallet the new crypted record's auth tag also disagreed with the counter in memory. HavePQCKeyRecord now counts failed records, so the top-up leaves the record and the key stays blocked until the wallet is restored or repaired. GetPQCSignatureCounter took the higher counter of a key's plaintext and crypted records only once the plaintext record was validated, and reported the crypted record's lower counter while it was pending. WriteReencryptedPQCKeys could also write a key in both plaintext maps twice, the second time without the higher counter. No current caller puts a key in both, but it now skips the duplicate. Co-Authored-By: Claude Opus 5.5 <[email protected]> * wallet: refuse backups that would copy plaintext PQC keys Until the first unlock re-encrypts them, an affected wallet keeps its plaintext walletdescriptorpqckey records, and backupwallet and the GUI's backup copied them with no warning. A backup taken right after upgrading was one more copy of the keys, which re-encryption can never reach (#321). BackupWallet now refuses while pqc_key_validation.reencryption_required is true. It checks under the cs_wallet it holds through the copy, which re-encryption also needs. backupwallet fails with -13 (RPC_WALLET_UNLOCK_NEEDED), so scripts can tell this case apart, and names the remedy: an unlock, and, for records that failed validation, which no unlock re-encrypts, the override after it. That new optional argument, allow_unencrypted_pqc_keys, backs up anyway; qbit-cli converts it as a bool. The GUI cannot pass it, so its message also names #300's qbit-wallet dump route. The GUI has no unlock action either, so its tooltips for such a wallet now say how to unlock it, and that backups are refused. The #283 release note now covers backups, including scheduled backupwallet jobs, which fail after the upgrade until the wallet has been unlocked once. It also takes over the correction of #277's note, which says this release does not re-encrypt such keys; #277's note is back to its 1.x.x text, because #181 folds and deletes it. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
…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]>
## 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
* doc: add v1.0.1 release notes Cover every pull request merged to 1.x.x since the signed v1.0.0 tag, through #252. List the behavior changes first: the -fallbackfee default (#151), fee-only send entries (#150), and the encryptwallet overlap error code moving from -16 to -15 (#183). Record the release's known limitations: the unsigned-platform waiver (#70), the depth of the fuzz evidence (#173), and scheduled-workflow deployment (#152, #158). The required P2MR v1 conformance statement names the signed tag target and the oracle report digest, so the in-tree notes point to the release page, and the publish-time notes file carries the exact statement. Fold the #150 and #151 fragments into these notes and remove them. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * build: bump version to v1.0.1 Set CLIENT_VERSION_BUILD to 1 so the source identifies as v1.0.1, the maintenance release proposed in #174. It ships without a release candidate, so CLIENT_VERSION_RC stays 0. CLIENT_VERSION_IS_RELEASE stays true: 1.x.x is the release line, so its binaries carry no commit suffix, as for v1.0.0. CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR and CLIENT_VERSION_PHASE are unchanged. CLIENT_VERSION_STRING becomes 1.0.1, so every binary reports v1.0.1, the user agent is /qbit:1.0.1/, the Windows installer metadata and the RPC docs manifest derive from the same string, and Guix and the release validators derive 1.0.1 from a v1.0.1 tag. Regenerate the manual pages from the built binaries with contrib/devtools/gen-manpages.py (help2man 1.49.3). Only the version and date lines change. util_tests/test_FormatSubVersion expected the "Test" client name to format as CLIENT_VERSION_STRING. FormatSubVersion uses that string only for the qbit user agent and formats any other name numerically, so the check holds only while the version has no phase or release-candidate suffix. Expect the numeric form built from the version components, which holds for every version. The qbit user-agent checks on the next lines still cover CLIENT_VERSION_STRING. No other tracked file carries the release version. The README and doc mentions of v1.0.0 describe the launch source, and the 1.0.0 entries in the workflows are branch names, so they are left alone. Refs #174 Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: add the release-gate fixes to the v1.0.1 release notes Fold the release-notes fragments of #264, #265, #266 and #268 into doc/release-notes-1.0.1.md and delete them, and write the #263 entry from its pull request. #263's new P2MR stack-byte standardness rule is also listed under the behavior changes. Correct claims these merges made stale: - the fuzz-evidence limitation said later changes touch no fuzzed code; #263 and #265 change the interpreter that p2mr_script runs, and #268 replaces the library that pqc and p2mr_script call, so fresh evidence on the release source is now required before tagging; - the #162 entry said data signatures are unchanged (#265 caches them); - the no-measurement line now points to #268's library cost figures; - the #252 entry now notes the later #264 and #263 profile edits. Also correct the #183 entry, which said every other encryptwallet failure returns -16; some return -4 or -8. Record the deferred items under Known limitations: the consensus stack-byte cap (#257), uncached failed PQC signature checks (#259), and the remaining AuxPoW limits and open review notes from #266 (#258). Refs #174. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: record the remaining v1.0.1 limitations in the release notes Address the independent review of the v1.0.1 notes: - record that DerivePQCKey still leaves HD seed material and HKDF state in its own stack frame, which #268's library wipe does not reach and #270 would clear, and qualify the summary and the #268 entry; - qualify #163's retry claim and record its pre-existing serial-fallback re-signing as a known limitation; - say how v1.0.0 receivers handle headers messages cut short for size, matching the Known limitations entry; - list every installed Linux binary in the upgrade steps; - say that docs.qbit.org is already served by the earlier Pages workflow and only the versioned site from #148 is undeployed; - give the nightly fuzz mutation phase the Known limitations entry its pointer refers to, and credit #164 for the Qt shutdown-test fix. Refs #174. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: add the area-review findings to the v1.0.1 release notes Release notes: - add an Updated RPCs section: bumpfee rejects a replacement whose signer changed anything but input signatures, and revalidates the replacement at commit time (#167, which shipped the unmerged #146); send entries can omit vout, address and label (#150); list the new bumpfee failures under the behavior changes as well; - restate #268's cost from the release review's measurements, with the SHA backends they cover; - add Known limitations for per-descriptor PQC signature counters, the qbit-qt Send dialog signing while it prepares, and the platforms on which the libbitcoinpqc stack-wipe depth is verified. doc/consensus/p2mr-v1.md: correct the non-normative section 9 sentence from #264, which implied wallet-wide per-key counting. Wallet counters enforce the 2^30 contract per descriptor and per wallet copy. No normative text changes, but the specification bytes do, so the P2MR v1 consensus review must cite a commit that contains this change. share/examples/qbit.conf: show the -fallbackfee default from #151, as contrib/devtools/gen-qbit-conf.sh generates it. The generator's other difference, the lock debug category, appears only in Debug builds and is left out. Refs #174. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: cover #270, #277 and #289 and the deferred review findings in the v1.0.1 notes The notes predated #270, #277 and #289, and the 2026-11-04 review of the v1.0.1 change set found that they left out the deferred wallet and IPC findings. - #270: a normal entry replaces the DerivePQCKey known limitation and the qualifiers in the summary and #268's entry. The 17 KiB figure is scoped to the library, and qbit's calls need at least 32 KiB for the new wipe. - #277: fold in release-notes-277.md. How to Upgrade gains the guidance for wallets encrypted by v1.0.0 that may still hold unencrypted PQC keys, and a downgrade statement. - #289: fold in release-notes-278.md as a new Mining interface section, and add the IPC client requirement under Behavior changes. - Known limitations add the deferred findings #279-#296 and #304, each with what users should do. The #143 entry now says which paths resume a pending keypool refill. - The fuzz-anchor entry and the fuzz-evidence caveat cover #270 and #342. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: correct v1.0.1 notes and docs from the release review Release notes: - fallback fee (#307): the floor is only this node's minimum relay fee, -mintxfee and mempool minimum. Peers with a higher minimum, or a congested network, may not relay or mine a fallback-rate send until its fee is bumped. Note the bump cost for P2MR, -fallbackfee=0 for services that prefer failure, and the 60-hour estimate staleness; - #268 cost (#311): production mode pins the library's SHA-2 to its portable code on every platform, so SHA-NI, ARMv8 SHA and CommonCrypto are never used; AVX2 still speeds up keygen and signing. Restate the measured figures for that backend, drop the SHA-NI and test-knob-only scalar figures, list what was not measured, and remove the CommonCrypto clause from the stack-wipe limitation; - low-work headers sync (#309) cannot complete from any peer through a dense AuxPoW range and retries at each announcement; - the -15 encryptwallet wording, the libexec binaries in the upgrade steps (#339), the #163 planner wording (#330), the #337 docs deploy, and drop "reviewed" from the summary (#315). doc/user/bitcoin-core-differences.md (#330): add the 1 MiB P2MR stack-byte policy limit and its reject reason, and correct the data-signature charge to 3,683 with the testnet4 and regtest legacy cases. doc/subtrees/libbitcoinpqc.md (#333): direct library calls need about 17 KiB of stack; qbit's CPQCKey and DerivePQCKey calls need at least 32 KiB plus frames for the #270 wipe. Remove the v1.0.0 fragments release-notes-95, -102, -128 and -132 (#340), which shipped at v1.0.0 and are referenced nowhere. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: update the v1.0.1 release notes for the changes merged since 2026-11-05 Fold in #297, #298, #299, #319, #344, #346, #347 and #348 from the reviewed draft, and #300, #301, #343 and #353 from their fragments: the post-encryption rewrite and its disk space and first-load cost, the re-encryption of PQC keys v1.0.0 left unencrypted and how to unlock for it in qbit-qt, the new backupwallet and getwalletinfo fields, PSBT Sign re-entrancy, and the macOS debug symbol archives. Update the How to Upgrade, downgrade, #277 and Known limitations text these change, remove the limitations fixed since, and extend the fuzz-evidence list. Delete the per-PR fragments the notes now cover. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: regenerate the v1.0.1 manual pages Regenerate doc/man with contrib/devtools/gen-manpages.py from binaries built at the merged tree. Apart from the date, only the -discardfee help in qbitd.1 and qbit-qt.1 changes, for the limit #346 added when there is no fee estimate. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: correct the v1.0.1 release notes from the launch review - #268: libbitcoinpqc v0.3.2 verification is about 7 to 8% slower in a production-mode x86-64 micro-benchmark, from the wipe of the SHA-256 and SHA-512 finalize buffers it added, and a mainnet -reindex-chainstate on the same machine took about 5 to 8% longer than with v1.0.0. The notes said verification showed no change, and that no throughput or IBD measurement accompanied the release. - #293 is fixed by #300 (DelAddressBook takes cs_wallet before its transaction): move it from Known limitations to Wallet fixes. - #166: the Sign/Verify dialog shows the lowercase state name, such as "normal". - #266: add the mainnet mixed-version sync result and the advice to upgrade nodes that accept inbound connections first. - Add known limitations for #364 (PSBT Save's file dialog leaves Sign and Close reachable through accessibility tools) and #365 (coin control's change preview). Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: regenerate the example config and drop an internal note from the v1.0.1 notes Regenerate share/examples/qbit.conf with contrib/devtools/gen-qbit-conf.sh from the v1.0.1 build, so the -discardfee description carries the sentence that #346 added to the help, as the regenerated manual pages do. The "lock" debug category is only compiled into builds with DEBUG_LOCKCONTENTION, so a release build does not list it. Drop the known-limitations item about the scope of the release readiness inspection: it describes release-process status, not a limitation users need to know about. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: cover the PRs merged since the last v1.0.1 notes update Add entries for the eleven PRs merged into 1.x.x after 0a936d6: #379 (walletpassphrasechange keeps the lock state) under Wallet fixes and Updated RPCs, #352 and #354 with the other qbit-qt fixes, folded from their fragments, #380 (NODE_WITNESS_PRUNED only from a peer's own version message) with the P2P changes, #381 in a new PHOTON section, and #371, #374, #375, #376, #377 and #385 under release engineering and CI. Mention the new fixes in the summary, update the encryptwallet and shutdown Known limitations for #352 and #354 (#349 is fixed), and add the new PRs to the fuzz-evidence list, with #380's addrman and net_processing change and the inherited targets that reach it. Delete the folded fragments release-notes-352.md and -354.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> * doc: cover the PRs merged for v1.0.1 since the last notes update Fold in #378, #386 with #422's edits, #411, #418 and #419 from their fragments, carry #411's edits to the deleted #304 fragment into the walletpassphrase text, and add entries for #387, #410, #414 and #415. Behavior changes add the P2MR hashing standardness rule (#415), the per-peer budget for validating rejected transactions with its debug-only -txvalidationbudget option (#386, #422), and walletpassphrase refilling the P2MR keypools before it returns, with the timeout counting from the end of the refill and a new -4 error on failure (#411). How to Upgrade adds the reconsiderblock line, and the qbit-photon interoperability sentence now matches #410. Known limitations drop #296, which #418 fixes, update the uncached failed PQC signature bullet for the validation budget, and extend the fuzz-evidence caveat with #386, #414, #415 and #422 and the inherited targets that reach them. Delete the per-PR fragments the notes now cover. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
## Summary Merges `1.x.x` (through #425, 51 commits, the v1.0.1 work) into `1.1.0`, which has not moved since the v1.1.0-rc1 prep (#256) on 2026-10-27. After this, `1.1.0` is `1.x.x` plus the PQ transport line (#233, #249, #255, #256). ## Sync point This commit is the squash of the merge of `1.x.x` at `a7a70660ad6ecadbf77b89bc2fe85ba068a86a71` into `1.1.0` at `1b6e6b677ddd7e965a374cf3419bde4dd09747e4` (reviewed merge commit `2f01f54d8dbc3984fbdc848b4d96eb220d75464e`, tree `d588767f7af07c937ea4d6525313897e9c9daf6e`). A squash does not record `1.x.x` as a parent, so the next sync must name that `1.x.x` commit as its merge base (`git merge-tree --merge-base=<that commit>`, or a local join commit with it as second parent) instead of using the base Git finds, which stays at `45e9e72c2d` and would raise every conflict below again. ## Conflict resolutions | Files | Resolution | | --- | --- | | `CMakeLists.txt`, `doc/man/*.1` | Keep v1.1.0-rc1. | | `src/init.cpp` | Keep both `-mlkemportable` and `-txvalidationbudget`. | | `required-merge-gate.yml`, `test_merge_gate_poller.py` | Both lines independently taught the gate to read only its own event's runs. Took the `1.x.x` implementation (#345) whole and re-added the `1.1.0` triggers, the PQ CI contract step and the `1.1.0` ruleset template. | | `ci.yml`, `core-checks.yml` | Took the `1.x.x` spelling of the identical `--no-renames` change and its mainnet-line rule (already covers `1.1.0`); kept the PQ jobs, the apt cache and the fuzz tooling step. | | `ci-nightly-heavy.yml` | Kept the job catalog; carried the 300 minute ARM shard limit (#377) into it. `test_scheduled_validation_contract.py` now reads the catalog. | | `classify_merge_profile.py` | Kept the `1.x.x` operator-key routing and the PQ unit and functional file sets. | | `release-process.md`, `test_verify_mainnet_ci_posture.py` | Took the `1.x.x` runbook and the removal (#376, #385). | | `.github/rulesets/1.1.0.json` | Not a conflict: matched to the `1.0.0` template, which the ruleset check from `1.x.x` requires. | ## Testing (local, x86_64 Linux, Release build) - Build: clean. - Unit tests: 187 of 188 pass, `script_assets_tests` skipped as usual. - Functional, in `--v2pqtransport` mode and again in default mode: every `p2p_v2_*`, `feature_pq_*`, `rpc_net`, `rpc_pqtransport`, and the 12 functional tests `1.x.x` added or changed (including `p2p_tx_validation_budget` and `p2p_auxpow_headers_size`). All pass. - `ci/checks/test_*.py`, `ci/release/test_*.py`, PQ canary, fuzz coverage anchors, seed check, PQ doc token lint: pass, except `test_verify_testnet_release_posture.py`, which fails identically on both parents on this host. Not run locally: the full functional suite, sanitizers, non-x86 and macOS jobs, fuzz replay. ## Follow-ups, not in this PR - Man pages keep the October date and are not regenerated; do that when the next release candidate is cut. - `test/rpc_docs/test_site_builder.py` fails on `1.1.0` before and after this merge (`getpqtransportinfo` is missing from the sample manifest). - `1.x.x` does not contain the v1.0.1 release commit on `main`; nothing here depends on it. Squashed commits: 4fb9dbe doc: fix pipe rendering and tighten P2MR v1 consensus profile (#252) d38cbd8 doc: document bounded30 usage-dependent security margin and raw-key counter limits (#264) 02a465d script: cache verified P2MR data-signature checks (v1.0.1) (#265) aa8ea86 policy: bound P2MR runtime stack bytes (#263) a1e8bd9 net: bound the size of headers messages we send (#266) e374ba2 subtree: import libbitcoinpqc v0.3.2 signer stack scrub (#268) 330b370 crypto: clear stack released by PQC secret-key operations (#270) b27130a wallet: take descriptor locks before EncryptWallet's transaction (#277) 21fee6e mining: reset cached block checks in IPC submitSolution (backport bitcoin/bitcoin#33745) (#289) 9c831be wallet: keep the SQLite lock when probing loaded wallet files (#297) 635919d wallet: fail a send whose inputs a concurrent call spent (#298) a5967f6 depends: Update Qt to 6.8.4 and fix macOS accessibility use-after-free (#347) baf158a fuzz: re-anchor PQC coverage checks after #270 and run them in CI (#342) dd86425 wallet: deferred P2MR keypool refill at startup and unlock; Lock() waits for key copies (#299) ee85afc test: fix race in p2p_auxpow_headers_size (#358) e112622 qt: fix send confirmation re-entrancy and dialog deletion during confirmation (#348) 863e6b1 wallet: fallback-fee follow-ups for #151 (discard rate, GUI warning, default test, help texts) (#346) 621b330 ci: bind the Required Merge Gate to its own event's runs, fail drafts, keep both sides of renames (#345) b5486bf qt: keep PSBT signing results across shutdown, close and unload (#344) 49b5013 test: keep wallet_p2mr_deferred_keypool_tests within time limits under sanitizers (#361) 993ab75 ci: run runner selection on GitHub-hosted Ubuntu (#362) 9574775 qt: ignore PSBT Sign while a signing attempt is in progress (#353) 594b934 contrib: import libbitcoinpqc releases as one verified main-line commit (#360) 535f69f guix: ship macOS debug symbols as dSYM bundles (#343) ea571b8 wallet: remove deleted plaintext keys from the wallet file after encryption (#300) 3a12925 wallet: re-encrypt plaintext PQC keys in encrypted wallets on unlock (#301) b10c761 ci: allowlist fuzz-seed format tags in the gitleaks scan (#367) 0a936d6 ci: retry the cargo-audit database fetch and fix the clang analyzer scan (#368) d647580 contrib: add the rulesets for qbit-guix.sigs main (#371) 26ebfc9 contrib: add public tools to stage, sign and combine release checksums (#374) d6a72d6 contrib: keep the release key policy in one place and tighten key-policy continuity checks (#375) bdc43f3 wallet: keep the lock state when changing the passphrase (#379) 33cb6e8 ci: keep the 32-bit ARM nightly unit-test shards within their time limit (#377) e26c22e ci: run the mainnet publication posture check on every mainnet line (#385) 73c704b qt: wait for open dialogs before shutdown and wallet unload (#354) dfbf4b8 qt: keep the GUI responsive during wallet encryption started outside it (#352) 843ba29 doc: replace the release docs with a runbook, a publisher reference and a release issue form (#376) c53393d net: only use service bits learned from a direct connection when deciding which addresses to avoid (#380) 9fc25e0 photon: bound inbound relay state per peer and check blocks before submission (#381) 3723aeb ci: parse gpg status output on newline only and reject other line separators (#387) 9935217 net: budget per-peer time spent validating rejected transactions (#386) a811585 photon: announce blocks under the low-order bits of their hash (#410) 1efb3ae wallet: refill P2MR keypools before walletpassphrase returns (#411) e9f4499 wallet: fail descriptor key encryption when the plaintext record is not erased (#418) 694c26d ipc: return false from submitSolution for a missing or undecodable coinbase (#419) 2f2ad3e net: request transactions held back by the validation budget later, and limit each connection's share of the pool (#422) 273353b net, validation: attribute received blocks to their sender and check recovered blocks (#414) 889d3e2 qt: add a play-money poker lobby based on Satoshi's 2009 design (#378) 6a3421d script: limit standard hashing of large P2MR stack elements (#415) 29c0ec9 release: prepare v1.0.1 (#181) a7a7066 net: pass held-back transaction announcements on at most once per retry delay (#425) 2f01f54 Merge 1.x.x into 1.1.0 Synced-From: 1.x.x@a7a70660ad6ecadbf77b89bc2fe85ba068a86a71 git-subtree-dir: src/libbitcoinpqc git-subtree-split: 1965d0da1eb4d9e196613b8f3a5d0d866a221c53 Co-authored-by: Claude Opus 5.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]>
Summary
Fixes two wallet bugs present since v1.0.0, both between
CWallet::EncryptWalletand the background P2MR keypool top-ups (RunP2MRKeyPoolRefillStep,RunPendingInitialKeyPoolTopUpStep).EncryptWalletheldcs_walletand the SQLite writer, then waited for each manager'scs_desc_maninsideDescriptorScriptPubKeyMan::Encrypt. A background top-up holdscs_desc_manwithoutcs_walletand then waits for the writer, so each could wait on the other forever.walletdescriptorpqckeyrecords after it. The wallet then said it was encrypted and locked while holding plaintext PQC private keys, and the next load accepted them.Fix. The lock order is now
cs_wallet→cs_desc_man→ database writer. The top-ups and address reservation already used this order.EncryptWallettakes every descriptor manager'scs_desc_manbeforeTxnBeginand holds them all until the commit.cs_desc_man. A top-up that readsHasEncryptionKeys()under its owncs_desc_mangets an answer that cannot change while it holds that lock, since encryption cannot be undone.PrepareTopUptakes its whole snapshot at once.GetKeysreads the encryption state and copies both key maps under a singlecs_desc_manhold, then takes the encryption key once, andPrepareTopUpkeeps that state and key. Before, an encryption or an unlock between the separate reads could leave a top-up with an encryption key but no keys to derive from.TopUpWithDBPreparedResultrefuses a plaintext snapshot taken before encryption.Rewrite()inEncryptWallet.Thread-safety annotations.
EncryptisEXCLUSIVE_LOCKS_REQUIRED(cs_desc_man),PrepareTopUpisLOCKS_EXCLUDED(cs_desc_man), and the new snapshot check isEXCLUSIVE_LOCKS_REQUIRED(cs_desc_man).EncryptWalletholds its locks in a list, which Clang's analysis cannot follow. A smallASSERT_EXCLUSIVE_LOCKhelper tells the analysis that the lock is held and checks it at runtime underDEBUG_LOCKORDER. No locks were added just to satisfy the analysis.This keeps the fixes from #143, #144 and #183, and the STAGED/COMMITTING/COMMITTED publication state from #144 is unchanged. There are no wallet record, format or consensus changes.
Testing
There are two new
wallet_encryption_testscases. Both use real SQLite and force each interleaving with new test hooks:EncryptWalletAndBackgroundTopUpBothFinish. On the base it deadlocks (Timed out waiting for EncryptWallet: the wallet threads are deadlocked, after the 5-minute watchdog). With the fix it passes.StaleTopUpSnapshotDoesNotWritePlaintextKeys. On the base it fails 7 checks: 4 plaintext PQC key records in the encrypted wallet, and they are still there after a reload. With the fix it passes. The test also unloads, reloads, unlocks and tops up, and checks that the new keys are written encrypted.The test threads return whether the top-up succeeded, not a
util::Result, because MSVC'sstd::futurerequires an assignable type. The base results above came from the earlier form of the tests, which checked the same thing, and were not re-run after this change. No dedicated test covers theGetKeyssingle-snapshot change: once the reads are combined there is no window left to park a thread in.Results at head
2509876ad1:test_qbit: 1309/1309 pass.script_assets_testwas skipped becauseDIR_UNIT_TEST_DATAis unset.wallet_encryption_tests,wallet_testsincluding all 18DescriptorTopUp*cases,wallet_p2mr_deferred_keypool_tests,wallet_p2mr_encryption_tests,wallet_p2mr_crypted_provider_tests,wallet_p2mr_descriptor_cache_tests,wallet_p2mr_change_keypool_tests,scriptpubkeyman_tests,walletload_tests,walletdb_tests): 70/70 pass.wallet_encryption.py,wallet_keypool.py,wallet_keypool_topup.py: pass.-fsyntax-only -Wthread-safety -Werrorand clang-tidy are clean on the changed files. Removing the assertion helper makes the analysis reportEncryptrequirescs_desc_man.lint-includes,lint-locale-dependenceandgit diff --checkare clean.DEBUG_LOCKORDERandABORT_ON_FAILED_ASSUME, with no reports:wallet_encryption_tests,wallet_p2mr_encryption_tests,wallet_p2mr_crypted_provider_tests,wallet_p2mr_descriptor_cache_tests,wallet_p2mr_deferred_keypool_tests,wallet_p2mr_change_keypool_tests,scriptpubkeyman_tests;wallet_tests,spend_tests,wallet_p2mr_descriptor_tests,wallet_p2mr_markunused_tests,wallet_p2mr_trusted_record_tests.wallet_p2mr_plaintext_validation_ready_tests. The latter takes about 570 s in Debug TSan and passed under TSan only before the first review. All of them pass in the full RelWithDebInfo run above.Target Branch
mainor a maintainer-requested release branch such as0.1.x. (Target:1.x.xfor v1.0.1.)Risk / Review Notes
Notes:
EncryptWallettakescs_wallet→ allcs_desc_man→ the writer. I audited the code and found no path that holds a writer transaction and then waits on an existing manager'scs_desc_man, and none that holds two managers'cs_desc_man. The comment oncs_desc_mannow records the order.cs_walletwhile holdingcs_desc_man:GetKeyandIsLocked()throughCWallet::GetKeyandMaybeTopUpInternalP2MRKeyPool,ReservePQCSignatureCountersBatch, andGetKeyscalled fromGetDescriptorString. Each of them takescs_walletthere only once the wallet is encrypted, so they cannot deadlock with this PR's new wait, which happens before the master key is added. After its commit,EncryptWalletstill takescs_desc_manundercs_walletinUnlock()andSetupDescriptorScriptPubKeyMans, as it did before this PR. The callers I checked already holdcs_wallet:CreateTransactionInternalandGetNewChangeDestinationforMaybeTopUpInternalP2MRKeyPool,rpc/wallet.cppforCWallet::GetKey, and the four RPCs that callGetDescriptorString. I did not audit every signing path intoReservePQCSignatureCountersBatch.Lock()can outlive it, including the plaintext PQC keyGetSigningProvider(const CPQCPubKey&)copies. AnIsLocked()re-check undercs_desc_manwould takecs_walletaftercs_desc_manand break the lock order.HasEncryptionKeys/IsCrypted/IsLockedreads in the schedulers remain a formal data race (already noted as a follow-up on wallet: close races around CWallet::EncryptWallet #183).LoadDescriptorWalletRecords).SQLiteDatabase::Rewritedoes not take the writer semaphore, andEncryptWalletignores its result.Docs / Process Impact
doc/release-notes-277.md.)🤖 Generated with Claude Code