From fd9d6eebc1eabb4675a118d19d38283da2dead39 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 5 Dec 2019 18:01:30 -0500 Subject: [PATCH] Add GetEncryptionKey() and HasEncryptionKeys() to WalletStorage Adds functions in WalletStorage that allow ScriptPubKeyMans to check and get encryption keys from the wallet. --- src/wallet/scriptpubkeyman.h | 2 ++ src/wallet/wallet.cpp | 10 ++++++++++ src/wallet/wallet.h | 3 +++ 3 files changed, 15 insertions(+) diff --git a/src/wallet/scriptpubkeyman.h b/src/wallet/scriptpubkeyman.h index 6ed9a4787a..d738418a69 100644 --- a/src/wallet/scriptpubkeyman.h +++ b/src/wallet/scriptpubkeyman.h @@ -31,6 +31,8 @@ public: virtual void UnsetBlankWalletFlag(WalletBatch&) = 0; virtual bool CanSupportFeature(enum WalletFeature) const = 0; virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr, bool = false) = 0; + virtual const CKeyingMaterial& GetEncryptionKey() const = 0; + virtual bool HasEncryptionKeys() const = 0; virtual bool IsLocked() const = 0; }; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index abee497c1d..af3b7cf613 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4056,3 +4056,13 @@ LegacyScriptPubKeyMan* CWallet::GetLegacyScriptPubKeyMan() const { return m_spk_man.get(); } + +const CKeyingMaterial& CWallet::GetEncryptionKey() const +{ + return vMasterKey; +} + +bool CWallet::HasEncryptionKeys() const +{ + return !mapMasterKeys.empty(); +} diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index b02e092f0a..82661fcc31 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -1136,6 +1136,9 @@ public: LegacyScriptPubKeyMan* GetLegacyScriptPubKeyMan() const; + const CKeyingMaterial& GetEncryptionKey() const override; + bool HasEncryptionKeys() const override; + // Temporary LegacyScriptPubKeyMan accessors and aliases. friend class LegacyScriptPubKeyMan; std::unique_ptr m_spk_man = MakeUnique(*this);