Industry observers note that the key reason behind the setup is error handling in a way where there's no break in wallet usage that needs manual intervention in the process, to a significant degree. Indeed, a Bitcoin wallet migration change was, broadly speaking, merged on November 25 by Bitcoin Core.

It has been revealed that the pull request follows two earlier fixes, one for unnamed legacy wallets and another for crashes when Bitcoin Core couldn't write to the wallet directory, on the whole. In fact, the thinking is to handle failures in a controlled way so the process can (to some degree) automatically restore the original wallet without needing manual intervention.

This isn't the first fix for wallet migration either, in the actual application. (Related: Show, Don't Certify: How to Prepare for Your First Data...)

Sources indicate that some mismatches during wallet creation could crash the graphical app or cause it to return a generic error. Those differences are now caught by Bitcoin Core and reported, which lets the migration process restore the original wallet from its backup, There are a couple of cases where the process could abruptly stop. (Related: Scientists find โ€œfieldโ€ of washing machines in ocean du...)

Trying to migrate a wallet in a read-only directory could also throw an error and skip cleanup, in real-world scenarios. In fact, now the process crashes with a clear error message. The test for this case is checking that the wallet is still in the old database format after the failure.

Industry observers note that the biggest change is in how Bitcoin Core moves the wallet to SQLite. Earlier, it deleted the original database before writing the upcoming one. If something went wrong while making the new database or writing the wallet records, the user could end up restoring the backup by hand.

According to recent reports, now Bitcoin Core builds the SQLite database next to the original. So, the old database stays in place. These days, the latest one is being built. Once the wallet records have been written successfully, Bitcoin Core can move the new database into place. The pull request also tests this with a wallet stored on a separate filesystem.

Sources indicate that A leftover SQLite journal in the wallet directory can corrupt the newly introduced database if SQLite uses it for the migrated wallet. In fact, Bitcoin Core now stops the migration when it finds a file, and the test checks that the journal stays in place. Moreover, the wallet keeps its legacy format.

It's significant to keep in mind that automatic recovery still hinges on the backup being copied back successfully. As Ryan Ofsky mentioned in his review, if that copy crashes, the user still has to restore the backup by hand, on the whole.

โ†’ Read original article