Branch data Line data Source code
# 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 : 2253 : { # 12 : 2253 : fs::path path; # 13 : : # 14 [ + + ]: 2253 : if (gArgs.IsArgSet("-walletdir")) { # 15 : 38 : path = gArgs.GetArg("-walletdir", ""); # 16 [ - + ]: 38 : if (!fs::is_directory(path)) { # 17 : : // If the path specified doesn't exist, we return the deliberately # 18 : : // invalid empty string. # 19 : 0 : path = ""; # 20 : 0 : } # 21 : 2215 : } else { # 22 : 2215 : path = gArgs.GetDataDirNet(); # 23 : : // If a wallets directory exists, use that, otherwise default to GetDataDir # 24 [ + + ]: 2215 : if (fs::is_directory(path / "wallets")) { # 25 : 1563 : path /= "wallets"; # 26 : 1563 : } # 27 : 2215 : } # 28 : : # 29 : 2253 : return path; # 30 : 2253 : } # 31 : : # 32 : : bool IsFeatureSupported(int wallet_version, int feature_version) # 33 : 89187 : { # 34 : 89187 : return wallet_version >= feature_version; # 35 : 89187 : } # 36 : : # 37 : : WalletFeature GetClosestWalletFeature(int version) # 38 : 0 : { # 39 : 0 : 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 [ # # ]: 0 : for (const WalletFeature& wf : wallet_features) { # 41 [ # # ]: 0 : if (version >= wf) return wf; # 42 : 0 : } # 43 : 0 : return static_cast<WalletFeature>(0); # 44 : 0 : }