Skip to content

wallet: warn when encryption cleanup fails - #36793

Closed
l0rinc wants to merge 2 commits into
bitcoin:masterfrom
l0rinc:l0rinc/wallet-encryption-rewrite-warning
Closed

l0rinc wants to merge 2 commits into
bitcoin:masterfrom
l0rinc:l0rinc/wallet-encryption-rewrite-warning

Conversation

@l0rinc

@l0rinc l0rinc commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Problem: Wallet encryption ignores a failed database rewrite after encrypted key records have been committed.
Old plaintext key material can remain in unused pages without a warning.

Fix: Log the cleanup failure while preserving the successful encryption result.
The warning advises moving funds to a newly created wallet before relying on at-rest encryption.

Show that `EncryptWallet()` still returns true and leaves usable encrypted keys when the final database rewrite fails.
A successful rewrite is the control, and a TODO marks the missing warning for the following fix.
Encrypted key records have already been committed when the final database rewrite runs.
A failed rewrite can leave old plaintext key bytes in unused pages, so log a warning while keeping the successful encryption result.
@DrahtBot DrahtBot added the Wallet label Nov 6, 2026
@DrahtBot

DrahtBot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.

@achow101

achow101 commented Nov 6, 2026

Copy link
Copy Markdown
Member

I prefer that we simply drop this code once encryptwallet is dropped altogether.

Or alternatively, we do a RAII thing that turns on/off secure_delete as needed, rather than requiring the caller to use VACUUM afterwards which can fail.

@achow101

achow101 commented Nov 7, 2026

Copy link
Copy Markdown
Member

Prefer #36796

@vicjuma

vicjuma commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Agree with @achow101. Resolving #36027 will remove most of these "post-commit" arms including #35966

@l0rinc

l0rinc commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the comments!

@l0rinc l0rinc closed this Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants