diff options
author | Andrew Chow <github@achow101.com> | 2022-12-21 17:51:03 -0500 |
---|---|---|
committer | Andrew Chow <github@achow101.com> | 2023-06-12 15:13:50 -0400 |
commit | bdbe3fd76b4b9186503dc1926a2fa3f8178d00a5 (patch) | |
tree | 0d46185accc7fe64524dfd44d0d814d6c30367f2 /src/wallet | |
parent | cb40639bdf04bab31bcdceb3bf941e9bade8317a (diff) | |
download | bitcoin-bdbe3fd76b4b9186503dc1926a2fa3f8178d00a5.tar.xz |
wallet: Generated migrated wallet's path from walletdir and name
Co-Authored-By: Ryan Ofsky <ryan@ofsky.org>
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index e5c03849af..7dc50586b0 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3843,16 +3843,19 @@ bool CWallet::MigrateToSQLite(bilingual_str& error) // Close this database and delete the file fs::path db_path = fs::PathFromString(m_database->Filename()); - fs::path db_dir = db_path.parent_path(); m_database->Close(); fs::remove(db_path); + // Generate the path for the location of the migrated wallet + // Wallets that are plain files rather than wallet directories will be migrated to be wallet directories. + const fs::path wallet_path = fsbridge::AbsPathJoin(GetWalletDir(), fs::PathFromString(m_name)); + // Make new DB DatabaseOptions opts; opts.require_create = true; opts.require_format = DatabaseFormat::SQLITE; DatabaseStatus db_status; - std::unique_ptr<WalletDatabase> new_db = MakeDatabase(db_dir, opts, db_status, error); + std::unique_ptr<WalletDatabase> new_db = MakeDatabase(wallet_path, opts, db_status, error); assert(new_db); // This is to prevent doing anything further with this wallet. The original file was deleted, but a backup exists. m_database.reset(); m_database = std::move(new_db); |