2010-08-29 16:58:15 +00:00
|
|
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
2020-01-15 02:17:38 +07:00
|
|
|
// Copyright (c) 2009-2020 The Bitcoin Core developers
|
2014-12-13 12:09:33 +08:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2012-05-18 22:02:28 +08:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2010-08-29 16:58:15 +00:00
|
|
|
|
2020-06-15 14:29:29 -04:00
|
|
|
#include <fs.h>
|
2017-11-10 13:57:53 +13:00
|
|
|
#include <wallet/db.h>
|
2013-04-13 00:13:08 -05:00
|
|
|
|
2020-06-15 14:29:29 -04:00
|
|
|
#include <string>
|
2018-09-25 21:56:16 +08:00
|
|
|
|
2020-06-15 14:14:51 -04:00
|
|
|
void SplitWalletPath(const fs::path& wallet_path, fs::path& env_directory, std::string& database_filename)
|
2017-11-13 21:25:46 -05:00
|
|
|
{
|
2017-11-15 15:44:36 -05:00
|
|
|
if (fs::is_regular_file(wallet_path)) {
|
|
|
|
// Special case for backwards compatibility: if wallet path points to an
|
|
|
|
// existing file, treat it as the path to a BDB data file in a parent
|
|
|
|
// directory that also contains BDB log files.
|
|
|
|
env_directory = wallet_path.parent_path();
|
|
|
|
database_filename = wallet_path.filename().string();
|
|
|
|
} else {
|
|
|
|
// Normal case: Interpret wallet path as a directory path containing
|
|
|
|
// data and log files.
|
|
|
|
env_directory = wallet_path;
|
|
|
|
database_filename = "wallet.dat";
|
|
|
|
}
|
2018-10-23 13:26:27 +08:00
|
|
|
}
|
|
|
|
|
2019-03-06 13:22:41 -08:00
|
|
|
fs::path WalletDataFilePath(const fs::path& wallet_path)
|
|
|
|
{
|
|
|
|
fs::path env_directory;
|
|
|
|
std::string database_filename;
|
|
|
|
SplitWalletPath(wallet_path, env_directory, database_filename);
|
|
|
|
return env_directory / database_filename;
|
|
|
|
}
|