6 #include <chainparams.h>
15 #include <system_error>
21 std::vector<fs::path> paths;
24 for (
auto it = fs::recursive_directory_iterator(wallet_dir, ec); it != fs::recursive_directory_iterator(); it.increment(ec)) {
26 if (fs::is_directory(*it)) {
27 it.disable_recursion_pending();
36 const fs::path path{it->
path().lexically_relative(wallet_dir)};
38 if (it->status().type() == fs::file_type::directory &&
41 paths.emplace_back(path);
42 }
else if (it.depth() == 0 && it->symlink_status().type() == fs::file_type::regular &&
IsBDBFile(it->path())) {
43 if (it->path().filename() ==
"wallet.dat") {
52 paths.emplace_back(path);
55 }
catch (
const std::exception& e) {
57 it.disable_recursion_pending();
66 if (fs::is_regular_file(wallet_path)) {
74 return wallet_path /
"wallet.dat";
80 return path /
"wallet.dat";
90 auto size = fs::file_size(path, ec);
92 if (size < 4096)
return false;
94 std::ifstream file{path, std::ios::binary};
95 if (!file.is_open())
return false;
97 file.seekg(12, std::ios::beg);
99 file.read((
char*) &data,
sizeof(data));
105 return data == 0x00053162 || data == 0x62310500;
114 auto size = fs::file_size(path, ec);
116 if (size < 512)
return false;
118 std::ifstream file{path, std::ios::binary};
119 if (!file.is_open())
return false;
123 file.read(magic, 16);
126 file.seekg(68, std::ios::beg);
128 file.read(app_id, 4);
133 std::string magic_str(magic, 16);
134 if (magic_str != std::string(
"SQLite format 3", 16)) {
139 return memcmp(
Params().MessageStart(), app_id, 4) == 0;
const CChainParams & Params()
Return the currently selected parameters.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
path(std::filesystem::path path)
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to a byte string.
void ReadDatabaseArgs(const ArgsManager &args, DatabaseOptions &options)
fs::path SQLiteDataFile(const fs::path &path)
std::vector< fs::path > ListDatabases(const fs::path &wallet_dir)
Recursively list database paths in directory.
bool IsBDBFile(const fs::path &path)
fs::path BDBDataFile(const fs::path &wallet_path)
bool IsSQLiteFile(const fs::path &path)
bool use_shared_memory
Let other processes access the database.
bool use_unsafe_sync
Disable file sync for faster performance.
int64_t max_log_mb
Max log size to allow before consolidating.