Bugfix: Wallet/Migration: Move backup into wallet directory when migrating from non-directory

While 30.x+ keep backup files in walletdir, 29.x places them in the migrated wallet directory

Github-Pull: #34370
Rebased-From: 69a6b9b1152ba0bb3edab6d2a54509fd416b24c8
This commit is contained in:
Luke Dashjr 2026-01-20 18:20:14 +00:00 committed by Ava Chow
parent 6494072295
commit c5d9f75c4b

View File

@ -4523,6 +4523,12 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
// First change to using SQLite
if (!local_wallet->MigrateToSQLite(error)) return util::Error{error};
// In case we're migrating from file to directory, move the backup into it
this_wallet_dir = fs::absolute(fs::PathFromString(local_wallet->GetDatabase().Filename())).parent_path();
backup_path = this_wallet_dir / backup_filename;
fs::rename(res.backup_path, backup_path);
res.backup_path = backup_path;
// Do the migration of keys and scripts for non-blank wallets, and cleanup if it fails
success = local_wallet->IsWalletFlagSet(WALLET_FLAG_BLANK_WALLET);
if (!success) {