| 2892 | } |
| 2893 | |
| 2894 | std::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 | |
| 2918 | std::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 | { |