2727#include < txmempool.h>
2828#include < utilmoneystr.h>
2929#include < wallet/fees.h>
30- #include < wallet/walletutil.h>
3130
3231#include < algorithm>
3332#include < assert.h>
@@ -3821,7 +3820,7 @@ void CWallet::MarkPreSplitKeys()
38213820 }
38223821}
38233822
3824- bool CWallet::Verify (std::string wallet_file , bool salvage_wallet, std::string& error_string, std::string& warning_string)
3823+ bool CWallet::Verify (const WalletLocation& location , bool salvage_wallet, std::string& error_string, std::string& warning_string)
38253824{
38263825 // Do some checking on wallet path. It should be either a:
38273826 //
@@ -3830,23 +3829,23 @@ bool CWallet::Verify(std::string wallet_file, bool salvage_wallet, std::string&
38303829 // 3. Path to a symlink to a directory.
38313830 // 4. For backwards compatibility, the name of a data file in -walletdir.
38323831 LOCK (cs_wallets);
3833- fs::path wallet_path = fs::absolute (wallet_file, GetWalletDir () );
3832+ const fs::path& wallet_path = location. GetPath ( );
38343833 fs::file_type path_type = fs::symlink_status (wallet_path).type ();
38353834 if (!(path_type == fs::file_not_found || path_type == fs::directory_file ||
38363835 (path_type == fs::symlink_file && fs::is_directory (wallet_path)) ||
3837- (path_type == fs::regular_file && fs::path (wallet_file) .filename () == wallet_file ))) {
3836+ (path_type == fs::regular_file && fs::path (location. GetName ()) .filename () == location. GetName () ))) {
38383837 error_string = strprintf (
38393838 " Invalid -wallet path '%s'. -wallet path should point to a directory where wallet.dat and "
38403839 " database/log.?????????? files can be stored, a location where such a directory could be created, "
38413840 " or (for backwards compatibility) the name of an existing data file in -walletdir (%s)" ,
3842- wallet_file , GetWalletDir ());
3841+ location. GetName () , GetWalletDir ());
38433842 return false ;
38443843 }
38453844
38463845 // Make sure that the wallet path doesn't clash with an existing wallet path
38473846 for (auto wallet : GetWallets ()) {
3848- if (fs::absolute ( wallet->GetName (), GetWalletDir () ) == wallet_path) {
3849- error_string = strprintf (" Error loading wallet %s. Duplicate -wallet filename specified." , wallet_file );
3847+ if (wallet->GetLocation (). GetPath ( ) == wallet_path) {
3848+ error_string = strprintf (" Error loading wallet %s. Duplicate -wallet filename specified." , location. GetName () );
38503849 return false ;
38513850 }
38523851 }
@@ -3856,13 +3855,13 @@ bool CWallet::Verify(std::string wallet_file, bool salvage_wallet, std::string&
38563855 return false ;
38573856 }
38583857 } catch (const fs::filesystem_error& e) {
3859- error_string = strprintf (" Error loading wallet %s. %s" , wallet_file , fsbridge::get_filesystem_error_message (e));
3858+ error_string = strprintf (" Error loading wallet %s. %s" , location. GetName () , fsbridge::get_filesystem_error_message (e));
38603859 return false ;
38613860 }
38623861
38633862 if (salvage_wallet) {
38643863 // Recover readable keypairs:
3865- CWallet dummyWallet (" dummy " , WalletDatabase::CreateDummy ());
3864+ CWallet dummyWallet (WalletLocation () , WalletDatabase::CreateDummy ());
38663865 std::string backup_filename;
38673866 if (!WalletBatch::Recover (wallet_path, (void *)&dummyWallet, WalletBatch::RecoverKeysOnlyFilter, backup_filename)) {
38683867 return false ;
@@ -3872,17 +3871,17 @@ bool CWallet::Verify(std::string wallet_file, bool salvage_wallet, std::string&
38723871 return WalletBatch::VerifyDatabaseFile (wallet_path, warning_string, error_string);
38733872}
38743873
3875- std::shared_ptr<CWallet> CWallet::CreateWalletFromFile (const std::string& name, const fs::path& path , uint64_t wallet_creation_flags)
3874+ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile (const WalletLocation& location , uint64_t wallet_creation_flags)
38763875{
3877- const std::string& walletFile = name ;
3876+ const std::string& walletFile = location. GetName () ;
38783877
38793878 // needed to restore wallet transaction meta data after -zapwallettxes
38803879 std::vector<CWalletTx> vWtx;
38813880
38823881 if (gArgs .GetBoolArg (" -zapwallettxes" , false )) {
38833882 uiInterface.InitMessage (_ (" Zapping all transactions from wallet..." ));
38843883
3885- std::unique_ptr<CWallet> tempWallet = MakeUnique<CWallet>(name , WalletDatabase::Create (path ));
3884+ std::unique_ptr<CWallet> tempWallet = MakeUnique<CWallet>(location , WalletDatabase::Create (location. GetPath () ));
38863885 DBErrors nZapWalletRet = tempWallet->ZapWalletTx (vWtx);
38873886 if (nZapWalletRet != DBErrors::LOAD_OK) {
38883887 InitError (strprintf (_ (" Error loading %s: Wallet corrupted" ), walletFile));
@@ -3896,7 +3895,7 @@ std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(const std::string& name,
38963895 bool fFirstRun = true ;
38973896 // TODO: Can't use std::make_shared because we need a custom deleter but
38983897 // should be possible to use std::allocate_shared.
3899- std::shared_ptr<CWallet> walletInstance (new CWallet (name , WalletDatabase::Create (path )), ReleaseWallet);
3898+ std::shared_ptr<CWallet> walletInstance (new CWallet (location , WalletDatabase::Create (location. GetPath () )), ReleaseWallet);
39003899 DBErrors nLoadWalletRet = walletInstance->LoadWallet (fFirstRun );
39013900 if (nLoadWalletRet != DBErrors::LOAD_OK)
39023901 {
0 commit comments