Skip to content

Instantly share code, notes, and snippets.

@bitschmidty
Last active January 9, 2026 20:38
Show Gist options
  • Select an option

  • Save bitschmidty/5144c098c522c0144adfc24d9e1bb9ec to your computer and use it in GitHub Desktop.

Select an option

Save bitschmidty/5144c098c522c0144adfc24d9e1bb9ec to your computer and use it in GitHub Desktop.

Bitcoin Core wallet migration bug

Context

On 2026-01-05 bitcoincore.org put out a notice of a bug in the wallet migration feature in Bitcoin Core versions 30.0 and 30.1 noting: "Under rare circumstances, when the migration of a wallet.dat file fails, all files in the wallet directory may be deleted in the process, potentially resulting in a loss of funds."

FAQ

Can I use Bitcoin Core version 30.0 or 30.1 as normal if I don't need to migrate a wallet?

Yes. Only the feature to migrate a legacy wallet to a descriptor wallet is affected by this bug.

What are the conditions for this bug?

Bitcoin Core Users

  • of a Bitcoin Core legacy wallet
  • that use an unnamed wallet.dat file
  • that had not previously migrated their wallet to a descriptor wallet
  • who attempt a migration using either of these versions
  • and if the migration process failed

have their wallet directory deleted, potentially resulting in a loss of funds.

Is there a fix for this?

Yes. The fix is in a release candidate, being tested for a 30.2 release.

Is this bad? How did this happen?

Any bug that allows for loss of funds is terrible. More information on this incident will be forthcoming.

How and when was this bug discovered?

GitHub user jestory opened an issue on 2025-12-20 outlining the bug. This user was impacted by the bug, but had backups of their wallet files. Bitcoin Core contributors worked to be able to recreate the conditions to reproduce the bug and a PR to fix it was drafted and since merged.

Does this happen if any legacy wallet migration fails?

No. One of the conditions for the bug is that the legacy wallet is unnamed.

Does the wallet migration process run automatically?

No.

What sequence of events led to unrelated files being deleted?

The goal of migration is replacing the old wallet file with one in the new file format, but holding the same information (keys, addresses, transactions, ...), and with the same file name. The first step is making a backup of the old file, which is normally left in place after migration, such that if anything were to go wrong with the migration process (disk space exhaustion, filesystem errors, unexpected shutdown, or inability to load the file afterwards), the process can be reverted by deleting the faulty migrated wallet file, and restoring the backup. Typically, wallet files reside in their own directory, and this restoration operation would delete the faulty migrated wallet's directory. However, old "unnamed" wallet.dat files can reside in the root of the wallets directory, rather than in their own wallet-specific directory. In this case, when migration failure occurs, the restoration operation would delete the directory containing it - which happens to be the directory that contains all wallets, including the created backup.

This was an error-prone approach, and the upcoming 30.2 release changes it such that only individual files which were created during the failed migration process are deleted - not whole directories without regard for their contents.

What if I migrated previously?

Then you are fine. Just do not attempt additional migrations with these versions.

Were the Bitcoin Core binaries for these releases removed from the bitcoincore.org website?

No, but out of caution they were moved to a new url (https://bitcoincore.org/bin/insecure-wallet-deletion/) so existing links to them would be broken.

What is an "unnamed" wallet?

Unnamed wallets refer to the plain wallet.dat file usually located in the top-level /wallets/ directory. These are different from named wallets, which are wallet.dat files residing in their own directory.

When were such unnamed wallets no longer created by default in Bitcoin Core?

Bitcoin Core 0.21 which was released January 2021 included #15454 which stopped creating these by default.

Was Bitcoin Core aware of this bug before the version 30 was released? Was this bug reported before version 30 was released?

No. There is no evidence for this claim.

@Conza88
Copy link

Conza88 commented Jan 8, 2026

@bitschmidty
Copy link
Author

Pointing out that migration code could theoretically have a bug is not the same as reporting a specific wallet migration bug.

@Conza88
Copy link

Conza88 commented Jan 8, 2026

The risks were pointed out, and they were laughed about and joked about...
https://x.com/i/status/2009380081852969399 .

You should add a "Am I, a Bitcoiner, negatively impacted?"

The answer is: yes. Absolutely. Everyone is negatively impacted by bCore reducing Bitcoin's quality as money.
Even if no-one lost funds; the point is Bitcoin's quality as money is reduced. The 🚩reduces economic reserve demand, which reduces purchasing power (all else being equal), so we're all negatively impacted.

@luke-jr
Copy link

luke-jr commented Jan 8, 2026

What if I migrated previously?

It wasn't possible to migrate affected wallets previously...?

Was this bug reported before version 30 was released?

Reported Dec 20th here, 2 weeks prior to the 30.1 release. I don't think anyone is seriously claiming it was prior to 30.0?

@bitschmidty
Copy link
Author

I don't think anyone is seriously claiming it was prior to 30.0?

Ive seen several posts about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment