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
This commit is contained in:
Luke Dashjr
2026-01-20 18:20:14 +00:00
parent cef01d0be5
commit 69a6b9b115

View File

@@ -4581,6 +4581,12 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(std::shared_ptr<CWallet>
// 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) {