MCPcopy Create free account
hub / github.com/ElementsProject/elements / MakeWalletDatabase

Function MakeWalletDatabase

src/wallet/wallet.cpp:2894–2916  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2892}
2893
2894std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error_string)
2895{
2896 // Do some checking on wallet path. It should be either a:
2897 //
2898 // 1. Path where a directory can be created.
2899 // 2. Path to an existing directory.
2900 // 3. Path to a symlink to a directory.
2901 // 4. For backwards compatibility, the name of a data file in -walletdir.
2902 const fs::path wallet_path = fsbridge::AbsPathJoin(GetWalletDir(), fs::PathFromString(name));
2903 fs::file_type path_type = fs::symlink_status(wallet_path).type();
2904 if (!(path_type == fs::file_type::not_found || path_type == fs::file_type::directory ||
2905 (path_type == fs::file_type::symlink && fs::is_directory(wallet_path)) ||
2906 (path_type == fs::file_type::regular && fs::PathFromString(name).filename() == fs::PathFromString(name)))) {
2907 error_string = Untranslated(strprintf(
2908 "Invalid -wallet path '%s'. -wallet path should point to a directory where wallet.dat and "
2909 "database/log.?????????? files can be stored, a location where such a directory could be created, "
2910 "or (for backwards compatibility) the name of an existing data file in -walletdir (%s)",
2911 name, fs::quoted(fs::PathToString(GetWalletDir()))));
2912 status = DatabaseStatus::FAILED_BAD_PATH;
2913 return nullptr;
2914 }
2915 return MakeDatabase(wallet_path, options, status, error_string);
2916}
2917
2918std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::string& name, std::unique_ptr<WalletDatabase> database, uint64_t wallet_creation_flags, bilingual_str& error, std::vector<bilingual_str>& warnings)
2919{

Callers 5

LoadWalletInternalFunction · 0.85
CreateWalletFunction · 0.85
VerifyWalletsFunction · 0.85
LoadWalletsFunction · 0.85
TestLoadWalletFunction · 0.85

Calls 9

AbsPathJoinFunction · 0.85
GetWalletDirFunction · 0.85
PathFromStringFunction · 0.85
UntranslatedFunction · 0.85
quotedFunction · 0.85
PathToStringFunction · 0.85
MakeDatabaseFunction · 0.85
typeMethod · 0.80
filenameMethod · 0.80

Tested by 1

TestLoadWalletFunction · 0.68