diff options
author | Andrew Chow <achow101-github@achow101.com> | 2020-04-29 16:58:12 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2020-10-19 00:14:38 -0400 |
commit | 5f720544f34dedf75b063b962845fa8eca604514 (patch) | |
tree | a59e9dd8ae7ad9f4232f2670ae7c8bd5540a785b | |
parent | 842ae3842df489f1b8d68e67a234788966218184 (diff) | |
download | bitcoin-5f720544f34dedf75b063b962845fa8eca604514.tar.xz |
wallet: Add GetClosestWalletFeature function
Given a version number, get the closest supported WalletFeature
for a version number.
-rw-r--r-- | src/wallet/walletutil.cpp | 13 | ||||
-rw-r--r-- | src/wallet/walletutil.h | 1 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index 9ac90a21ca..0b7cf692ba 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -75,3 +75,16 @@ bool IsFeatureSupported(int wallet_version, int feature_version) { return wallet_version >= feature_version; } + +WalletFeature GetClosestWalletFeature(int version) +{ + if (version >= FEATURE_LATEST) return FEATURE_LATEST; + if (version >= FEATURE_PRE_SPLIT_KEYPOOL) return FEATURE_PRE_SPLIT_KEYPOOL; + if (version >= FEATURE_NO_DEFAULT_KEY) return FEATURE_NO_DEFAULT_KEY; + if (version >= FEATURE_HD_SPLIT) return FEATURE_HD_SPLIT; + if (version >= FEATURE_HD) return FEATURE_HD; + if (version >= FEATURE_COMPRPUBKEY) return FEATURE_COMPRPUBKEY; + if (version >= FEATURE_WALLETCRYPT) return FEATURE_WALLETCRYPT; + if (version >= FEATURE_BASE) return FEATURE_BASE; + return static_cast<WalletFeature>(0); +} diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h index b0ab76fc31..27521abd81 100644 --- a/src/wallet/walletutil.h +++ b/src/wallet/walletutil.h @@ -30,6 +30,7 @@ enum WalletFeature }; bool IsFeatureSupported(int wallet_version, int feature_version); +WalletFeature GetClosestWalletFeature(int version); enum WalletFlags : uint64_t { // wallet flags in the upper section (> 1 << 31) will lead to not opening the wallet if flag is unknown |