Skip to content

Commit bdbe3fd

Browse files
achow101ryanofsky
andcommitted
wallet: Generated migrated wallet's path from walletdir and name
Co-Authored-By: Ryan Ofsky <[email protected]>
1 parent cb40639 commit bdbe3fd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/wallet/wallet.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3843,16 +3843,19 @@ bool CWallet::MigrateToSQLite(bilingual_str& error)
38433843

38443844
// Close this database and delete the file
38453845
fs::path db_path = fs::PathFromString(m_database->Filename());
3846-
fs::path db_dir = db_path.parent_path();
38473846
m_database->Close();
38483847
fs::remove(db_path);
38493848

3849+
// Generate the path for the location of the migrated wallet
3850+
// Wallets that are plain files rather than wallet directories will be migrated to be wallet directories.
3851+
const fs::path wallet_path = fsbridge::AbsPathJoin(GetWalletDir(), fs::PathFromString(m_name));
3852+
38503853
// Make new DB
38513854
DatabaseOptions opts;
38523855
opts.require_create = true;
38533856
opts.require_format = DatabaseFormat::SQLITE;
38543857
DatabaseStatus db_status;
3855-
std::unique_ptr<WalletDatabase> new_db = MakeDatabase(db_dir, opts, db_status, error);
3858+
std::unique_ptr<WalletDatabase> new_db = MakeDatabase(wallet_path, opts, db_status, error);
38563859
assert(new_db); // This is to prevent doing anything further with this wallet. The original file was deleted, but a backup exists.
38573860
m_database.reset();
38583861
m_database = std::move(new_db);

0 commit comments

Comments
 (0)