Skip to content

Commit 5f72054

Browse files
committed
wallet: Add GetClosestWalletFeature function
Given a version number, get the closest supported WalletFeature for a version number.
1 parent 842ae38 commit 5f72054

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/wallet/walletutil.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,16 @@ bool IsFeatureSupported(int wallet_version, int feature_version)
7575
{
7676
return wallet_version >= feature_version;
7777
}
78+
79+
WalletFeature GetClosestWalletFeature(int version)
80+
{
81+
if (version >= FEATURE_LATEST) return FEATURE_LATEST;
82+
if (version >= FEATURE_PRE_SPLIT_KEYPOOL) return FEATURE_PRE_SPLIT_KEYPOOL;
83+
if (version >= FEATURE_NO_DEFAULT_KEY) return FEATURE_NO_DEFAULT_KEY;
84+
if (version >= FEATURE_HD_SPLIT) return FEATURE_HD_SPLIT;
85+
if (version >= FEATURE_HD) return FEATURE_HD;
86+
if (version >= FEATURE_COMPRPUBKEY) return FEATURE_COMPRPUBKEY;
87+
if (version >= FEATURE_WALLETCRYPT) return FEATURE_WALLETCRYPT;
88+
if (version >= FEATURE_BASE) return FEATURE_BASE;
89+
return static_cast<WalletFeature>(0);
90+
}

src/wallet/walletutil.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ enum WalletFeature
3030
};
3131

3232
bool IsFeatureSupported(int wallet_version, int feature_version);
33+
WalletFeature GetClosestWalletFeature(int version);
3334

3435
enum WalletFlags : uint64_t {
3536
// wallet flags in the upper section (> 1 << 31) will lead to not opening the wallet if flag is unknown

0 commit comments

Comments
 (0)