You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wallet: EncryptWallet derives the new keypool before VACUUM, leaving deleted plaintext keys unvacuumed for ~30 s #285
CWallet::EncryptWallet commits the encryption, which deletes the plaintext key records. It then derives a full P2MR keypool for the new seed, and only after that runs GetDatabase().Rewrite() (VACUUM).
With the default keypool this gap is about 30 s. A crash or kill during it leaves the deleted plaintext seed and PQC key records in the database's free pages permanently.
SetupDescriptorScriptPubKeyMans(use_create_keypool_warmup=false), which runs 1000 SLH-DSA key generations per new descriptor;
Rewrite().
Measured on regtest with -keypool=1000 -debug=walletdb, the encryption COMMIT came 31.7 s before the VACUUM. The encryptwallet RPC took 32 s.
Release builds use the SQLite from depends, built without SQLITE_SECURE_DELETE, so deleted cells remain until a VACUUM. The only other Rewrite() call is the legacy NEED_REWRITE load path, so nothing runs the VACUUM after a crash.
Bitcoin Core v30.2 uses the same order, but its EC keypool derivation takes about 1–2 s.
Expected behaviour
Plaintext key material should not stay in an encrypted wallet's file, and a crash should not be able to make that permanent.
Suggested fix
Run Rewrite() immediately after the encryption commit, before setting up the new descriptors. Alternatively, enable PRAGMA secure_delete for the encryption transaction, or persist a "needs vacuum" marker and act on it at the next load.
Fixed on 1.x.x by #300 (ea571b86f5), which ships in v1.0.1: EncryptWallet now rewrites the wallet file right after the encryption commit, before it derives the new keypool, and a postencryptionrewrite record makes the next load retry a rewrite that did not finish.
Closing by hand, because a merge into 1.x.x does not close issues automatically.
Activity
doc: add release notes for #285
doc: add release notes for #285
wallet: remove deleted plaintext keys from the wallet file after encr…
kiwidream commentedon Nov 11, 2026
Fixed on
1.x.xby #300 (ea571b86f5), which ships in v1.0.1:EncryptWalletnow rewrites the wallet file right after the encryption commit, before it derives the new keypool, and apostencryptionrewriterecord makes the next load retry a rewrite that did not finish.Closing by hand, because a merge into
1.x.xdoes not close issues automatically.wallet: remove deleted plaintext keys from the wallet file after encr…