MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / Verify

Method Verify

src/wallet/wallet.cpp:3972–4021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3970}
3971
3972bool CWallet::Verify(std::string wallet_file, bool salvage_wallet, std::string& error_string, std::string& warning_string)
3973{
3974 // Do some checking on wallet path. It should be either a:
3975 //
3976 // 1. Path where a directory can be created.
3977 // 2. Path to an existing directory.
3978 // 3. Path to a symlink to a directory.
3979 // 4. For backwards compatibility, the name of a data file in -walletdir.
3980 LOCK(cs_wallets);
3981 fs::path wallet_path = fs::absolute(wallet_file, GetWalletDir());
3982 fs::file_type path_type = fs::symlink_status(wallet_path).type();
3983 if (!(path_type == fs::file_not_found || path_type == fs::directory_file ||
3984 (path_type == fs::symlink_file && fs::is_directory(wallet_path)) ||
3985 (path_type == fs::regular_file && fs::path(wallet_file).filename() == wallet_file))) {
3986 error_string = strprintf(
3987 "Invalid -wallet path '%s'. -wallet path should point to a directory where wallet.dat and "
3988 "database/log.?????????? files can be stored, a location where such a directory could be created, "
3989 "or (for backwards compatibility) the name of an existing data file in -walletdir (%s)",
3990 wallet_file, GetWalletDir());
3991 return false;
3992 }
3993
3994 // Make sure that the wallet path doesn't clash with an existing wallet path
3995 for (auto wallet : GetWallets()) {
3996 if (fs::absolute(wallet->GetName(), GetWalletDir()) == wallet_path) {
3997 error_string = strprintf("Error loading wallet %s. Duplicate -wallet filename specified.", wallet_file);
3998 return false;
3999 }
4000 }
4001
4002 try {
4003 if (!WalletBatch::VerifyEnvironment(wallet_path, error_string)) {
4004 return false;
4005 }
4006 } catch (const fs::filesystem_error& e) {
4007 error_string = strprintf("Error loading wallet %s. %s", wallet_file, e.what());
4008 return false;
4009 }
4010
4011 if (salvage_wallet) {
4012 // Recover readable keypairs:
4013 CWallet dummyWallet("dummy", WalletDatabase::CreateDummy());
4014 std::string backup_filename;
4015 if (!WalletBatch::Recover(wallet_path, (void *)&dummyWallet, WalletBatch::RecoverKeysOnlyFilter, backup_filename)) {
4016 return false;
4017 }
4018 }
4019
4020 return WalletBatch::VerifyDatabaseFile(wallet_path, warning_string, error_string);
4021}
4022
4023std::shared_ptr<CWallet> CWallet::CreateWalletFromFile(const std::string& name, const fs::path& path, uint64_t wallet_creation_flags)
4024{

Callers

nothing calls this directly

Calls 5

GetWalletDirFunction · 0.85
GetWalletsFunction · 0.85
typeMethod · 0.80
whatMethod · 0.80
GetNameMethod · 0.45

Tested by

no test coverage detected