mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-28 13:02:38 +02:00
wallet: default wallet migration, modify inconvenient backup filename
On default legacy wallets, the backup filename starts with an "-" due
to the wallet name being empty. This is inconvenient for systems who
treat what follows the initial "-" character as flags.
Github-Pull: #29586
Rebased-From: a951dba3a9
This commit is contained in:
parent
96ec3b67a7
commit
8a16b8f6a4
@ -4218,7 +4218,7 @@ util::Result<MigrationResult> MigrateLegacyToDescriptor(const std::string& walle
|
||||
|
||||
// Make a backup of the DB
|
||||
fs::path this_wallet_dir = fs::absolute(fs::PathFromString(local_wallet->GetDatabase().Filename())).parent_path();
|
||||
fs::path backup_filename = fs::PathFromString(strprintf("%s-%d.legacy.bak", wallet_name, GetTime()));
|
||||
fs::path backup_filename = fs::PathFromString(strprintf("%s_%d.legacy.bak", (wallet_name.empty() ? "default_wallet" : wallet_name), GetTime()));
|
||||
fs::path backup_path = this_wallet_dir / backup_filename;
|
||||
if (!local_wallet->BackupWallet(fs::PathToString(backup_path))) {
|
||||
return util::Error{_("Error: Unable to make a backup of your wallet")};
|
||||
|
@ -514,11 +514,20 @@ class WalletMigrationTest(BitcoinTestFramework):
|
||||
self.log.info("Test migration of the wallet named as the empty string")
|
||||
wallet = self.create_legacy_wallet("")
|
||||
|
||||
wallet.migratewallet()
|
||||
# Set time to verify backup existence later
|
||||
curr_time = int(time.time())
|
||||
wallet.setmocktime(curr_time)
|
||||
|
||||
res = wallet.migratewallet()
|
||||
info = wallet.getwalletinfo()
|
||||
assert_equal(info["descriptors"], True)
|
||||
assert_equal(info["format"], "sqlite")
|
||||
|
||||
# Check backup existence and its non-empty wallet filename
|
||||
backup_path = self.nodes[0].wallets_path / f'default_wallet_{curr_time}.legacy.bak'
|
||||
assert backup_path.exists()
|
||||
assert_equal(str(backup_path), res['backup_path'])
|
||||
|
||||
def test_direct_file(self):
|
||||
self.log.info("Test migration of a wallet that is not in a wallet directory")
|
||||
wallet = self.create_legacy_wallet("plainfile")
|
||||
|
Loading…
Reference in New Issue
Block a user