Skip to content

Commit

Permalink
wallet: Add GetClosestWalletFeature function
Browse files Browse the repository at this point in the history
Given a version number, get the closest supported WalletFeature
for a version number.
  • Loading branch information
achow101 committed Oct 19, 2020
1 parent 842ae38 commit 5f72054
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/wallet/walletutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 1 addition & 0 deletions src/wallet/walletutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5f72054

Please sign in to comment.