mirror of
https://github.com/Retropex/bitcoin.git
synced 2025-05-29 13:32:33 +02:00

This commit does not change to any code and behavior. It it is easily reviewed with the --color-moved=dimmed_zebra git diff option. Motivation for this change is to: - Consolidate redundant functions IsBDBFile /ExistsBerkeleyDatabase / SplitWalletPath, and IsSQLiteFile / ExistsSQLiteDatabase in the next commits - Detect SQLite wallets consistently regardless whether bitcoin is built with SQLite support in the next commits - Avoid attempting to open SQLite databases with the BDB library when bitcoin is built without SQLite support in the next commits
45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
// Copyright (c) 2017-2019 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <wallet/walletutil.h>
|
|
|
|
#include <logging.h>
|
|
#include <util/system.h>
|
|
|
|
fs::path GetWalletDir()
|
|
{
|
|
fs::path path;
|
|
|
|
if (gArgs.IsArgSet("-walletdir")) {
|
|
path = gArgs.GetArg("-walletdir", "");
|
|
if (!fs::is_directory(path)) {
|
|
// If the path specified doesn't exist, we return the deliberately
|
|
// invalid empty string.
|
|
path = "";
|
|
}
|
|
} else {
|
|
path = GetDataDir();
|
|
// If a wallets directory exists, use that, otherwise default to GetDataDir
|
|
if (fs::is_directory(path / "wallets")) {
|
|
path /= "wallets";
|
|
}
|
|
}
|
|
|
|
return path;
|
|
}
|
|
|
|
bool IsFeatureSupported(int wallet_version, int feature_version)
|
|
{
|
|
return wallet_version >= feature_version;
|
|
}
|
|
|
|
WalletFeature GetClosestWalletFeature(int version)
|
|
{
|
|
static constexpr std::array wallet_features{FEATURE_LATEST, FEATURE_PRE_SPLIT_KEYPOOL, FEATURE_NO_DEFAULT_KEY, FEATURE_HD_SPLIT, FEATURE_HD, FEATURE_COMPRPUBKEY, FEATURE_WALLETCRYPT, FEATURE_BASE};
|
|
for (const WalletFeature& wf : wallet_features) {
|
|
if (version >= wf) return wf;
|
|
}
|
|
return static_cast<WalletFeature>(0);
|
|
}
|