From 842ae3842df489f1b8d68e67a234788966218184 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 29 Apr 2020 14:48:43 -0400 Subject: wallet: Add utility method for CanSupportFeature --- src/wallet/wallet.h | 2 +- src/wallet/walletutil.cpp | 5 +++++ src/wallet/walletutil.h | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 245144a1c9..fcff0c557b 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -801,7 +801,7 @@ public: bool IsTrusted(const CWalletTx& wtx, std::set& trusted_parents) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet); //! check whether we are allowed to upgrade (or already support) to the named feature - bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return nWalletMaxVersion >= wf; } + bool CanSupportFeature(enum WalletFeature wf) const override EXCLUSIVE_LOCKS_REQUIRED(cs_wallet) { AssertLockHeld(cs_wallet); return IsFeatureSupported(nWalletMaxVersion, wf); } /** * populate vCoins with vector of available COutputs. diff --git a/src/wallet/walletutil.cpp b/src/wallet/walletutil.cpp index a2a55f9751..9ac90a21ca 100644 --- a/src/wallet/walletutil.cpp +++ b/src/wallet/walletutil.cpp @@ -70,3 +70,8 @@ std::vector ListWalletDir() return paths; } + +bool IsFeatureSupported(int wallet_version, int feature_version) +{ + return wallet_version >= feature_version; +} diff --git a/src/wallet/walletutil.h b/src/wallet/walletutil.h index afdcb2e18a..b0ab76fc31 100644 --- a/src/wallet/walletutil.h +++ b/src/wallet/walletutil.h @@ -29,7 +29,7 @@ enum WalletFeature FEATURE_LATEST = FEATURE_PRE_SPLIT_KEYPOOL }; - +bool IsFeatureSupported(int wallet_version, int feature_version); enum WalletFlags : uint64_t { // wallet flags in the upper section (> 1 << 31) will lead to not opening the wallet if flag is unknown -- cgit v1.2.3