Bitcoin Core
21.99.0
P2P Digital Currency
src
wallet
walletutil.cpp
Go to the documentation of this file.
1
// Copyright (c) 2017-2020 The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#include <
wallet/walletutil.h
>
6
7
#include <
logging.h
>
8
#include <
util/system.h
>
9
10
fs::path
GetWalletDir
()
11
{
12
fs::path path;
13
14
if
(
gArgs
.
IsArgSet
(
"-walletdir"
)) {
15
path =
gArgs
.
GetArg
(
"-walletdir"
,
""
);
16
if
(!fs::is_directory(path)) {
17
// If the path specified doesn't exist, we return the deliberately
18
// invalid empty string.
19
path =
""
;
20
}
21
}
else
{
22
path =
GetDataDir
();
23
// If a wallets directory exists, use that, otherwise default to GetDataDir
24
if
(fs::is_directory(path /
"wallets"
)) {
25
path /=
"wallets"
;
26
}
27
}
28
29
return
path;
30
}
31
32
bool
IsFeatureSupported
(
int
wallet_version,
int
feature_version)
33
{
34
return
wallet_version >= feature_version;
35
}
36
37
WalletFeature
GetClosestWalletFeature
(
int
version)
38
{
39
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
};
40
for
(
const
WalletFeature
& wf : wallet_features) {
41
if
(version >= wf)
return
wf;
42
}
43
return
static_cast<
WalletFeature
>
(0);
44
}
GetDataDir
const fs::path & GetDataDir(bool fNetSpecific)
Definition:
system.cpp:770
FEATURE_HD_SPLIT
@ FEATURE_HD_SPLIT
Definition:
walletutil.h:23
FEATURE_NO_DEFAULT_KEY
@ FEATURE_NO_DEFAULT_KEY
Definition:
walletutil.h:25
FEATURE_HD
@ FEATURE_HD
Definition:
walletutil.h:21
FEATURE_BASE
@ FEATURE_BASE
Definition:
walletutil.h:16
ArgsManager::IsArgSet
bool IsArgSet(const std::string &strArg) const
Return true if the given argument has been manually set.
Definition:
system.cpp:407
FEATURE_WALLETCRYPT
@ FEATURE_WALLETCRYPT
Definition:
walletutil.h:18
FEATURE_PRE_SPLIT_KEYPOOL
@ FEATURE_PRE_SPLIT_KEYPOOL
Definition:
walletutil.h:27
walletutil.h
FEATURE_COMPRPUBKEY
@ FEATURE_COMPRPUBKEY
Definition:
walletutil.h:19
ArgsManager::GetArg
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition:
system.cpp:503
IsFeatureSupported
bool IsFeatureSupported(int wallet_version, int feature_version)
Definition:
walletutil.cpp:32
system.h
FEATURE_LATEST
@ FEATURE_LATEST
Definition:
walletutil.h:29
GetClosestWalletFeature
WalletFeature GetClosestWalletFeature(int version)
Definition:
walletutil.cpp:37
gArgs
ArgsManager gArgs
Definition:
system.cpp:79
logging.h
WalletFeature
WalletFeature
(client) version numbers for particular wallet features
Definition:
walletutil.h:14
GetWalletDir
fs::path GetWalletDir()
Get the path of the wallet directory.
Definition:
walletutil.cpp:10
Generated on Mon Apr 19 2021 20:03:54 for Bitcoin Core by
1.8.17