← Socratic Seminar #52 ← → or space to navigate

Bitcoin Core #36387 · merged 2026-11-20

Deprecate encryptwallet for existing wallets

Encrypting a wallet after it was created rotates its keys, leaves old key material behind, and can silently retire descriptors you imported. Born-encrypted wallets are now the only recommended path.

Author: davidgumberg · Follows RFC #36027 (achow101) · github.com/bitcoin/bitcoin/pull/36387

Background

Why encrypting after the fact ever existed

  • When wallet encryption was introduced, only one wallet could be loaded, and it was created by default prefilled with keys. Encrypting afterward was the only option.
  • Today createwallet takes a passphrase, so a wallet can be encrypted from birth. That has worked for years.
  • encryptwallet rotates keys on purpose: the old keys sat on disk unencrypted, so they're treated as possibly compromised.
  • That rotation is the source of most of the footguns.

Footgun 1 & 2

Old backups miss new coins; old coins stay exposed

Timeline: a backup is taken while the wallet is unencrypted and 1 BTC is received on old keys. encryptwallet generates new descriptors, and 2 BTC is later received on new keys. Restoring the old backup misses the 2 BTC; anyone holding the old backup or plaintext disk remnants can still spend the 1 BTC, because existing funds are not moved. OLD keys plaintext on disk NEW keys encrypted time inactive, but coins stay here Backup A +1 BTC received +2 BTC received encryptwallet Restore Backup A sees 1 BTC, misses the 2 BTC Thief with Backup A or old disk data can still spend the 1 BTC

Encryption doesn't move existing coins, and Core makes no attempt to wipe old key material from disk: "difficult and dangerous, and for some SSD's infeasible."

Footgun 3 · issue #26607

Your imported descriptors get swapped out

Before encryptwallet, a blank wallet's active receive descriptor is one the user imported. After encryptwallet, the wallet generates its own descriptors and makes them active, so the imported descriptor becomes inactive and new addresses come from keys the user never chose. BEFORE Blank wallet Imported descriptor ACTIVE · e.g. your multisig getnewaddress → your keys ✓ encryptwallet AFTER Imported descriptor inactive Wallet-made descriptors ACTIVE getnewaddress → keys you never chose ✗

Funds can end up sent to descriptors the user didn't intend, changing the spending conditions out from under them.

The change

Off by default, behind -deprecatedrpc

// src/wallet/rpc/encrypt.cpp · encryptwallet()
+    if (!pwallet->chain().rpcEnableDeprecated("encryptwallet")) {
+        throw JSONRPCError(RPC_METHOD_DEPRECATED, "DEPRECATION WARNING: ...
+            Start bitcoind with the `-deprecatedrpc=encryptwallet` option ...");
+    }

Deprecated

encryptwallet on an existing unencrypted wallet. Errors (code -32) unless started with -deprecatedrpc=encryptwallet; removal planned for a future major release.

Unchanged

Born-encrypted wallets via createwallet … passphrase=, and walletpassphrasechange.

Also updated

doc/managing-wallets.md now recommends born-encrypted wallets; functional tests switched to them.

What to do instead

Start encrypted, then move the coins

$ bitcoin-cli -named createwallet wallet_name="vault" passphrase="…"
$ bitcoin-cli -rpcwallet="vault" backupwallet "/safe/place/vault.dat"
$ bitcoin-cli -rpcwallet="vault" getnewaddress
  # send everything from the old wallet to the new address
  • Create the new wallet with a passphrase so its keys never hit disk in plaintext.
  • Back it up right away, then send the old wallet's funds to it. Encrypting in place would have left them on the exposed keys.
  • Treat the old wallet and every backup of it as compromised once it's empty.

The docs recommend createwallet with a passphrase; the sweep and retire steps follow from #36027's point that encryption doesn't move existing funds.

Discussion

Questions for the room

  • Is wallet-file encryption worth much at all versus full-disk encryption or a hardware signer?
  • Rotate keys on encryption, or keep imported descriptors? Is there any right answer for encryptwallet?
  • Who still relies on encrypting after the fact: old scripts, node-in-a-box UIs, tutorials?
  • Should Core warn loudly when an unencrypted wallet holds funds?