Skip to content

Commit fd9d6ee

Browse files
committed
Add GetEncryptionKey() and HasEncryptionKeys() to WalletStorage
Adds functions in WalletStorage that allow ScriptPubKeyMans to check and get encryption keys from the wallet.
1 parent 4ee8a58 commit fd9d6ee

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/wallet/scriptpubkeyman.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ class WalletStorage
3131
virtual void UnsetBlankWalletFlag(WalletBatch&) = 0;
3232
virtual bool CanSupportFeature(enum WalletFeature) const = 0;
3333
virtual void SetMinVersion(enum WalletFeature, WalletBatch* = nullptr, bool = false) = 0;
34+
virtual const CKeyingMaterial& GetEncryptionKey() const = 0;
35+
virtual bool HasEncryptionKeys() const = 0;
3436
virtual bool IsLocked() const = 0;
3537
};
3638

src/wallet/wallet.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4056,3 +4056,13 @@ LegacyScriptPubKeyMan* CWallet::GetLegacyScriptPubKeyMan() const
40564056
{
40574057
return m_spk_man.get();
40584058
}
4059+
4060+
const CKeyingMaterial& CWallet::GetEncryptionKey() const
4061+
{
4062+
return vMasterKey;
4063+
}
4064+
4065+
bool CWallet::HasEncryptionKeys() const
4066+
{
4067+
return !mapMasterKeys.empty();
4068+
}

src/wallet/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,9 @@ class CWallet final : public WalletStorage, private interfaces::Chain::Notificat
11361136

11371137
LegacyScriptPubKeyMan* GetLegacyScriptPubKeyMan() const;
11381138

1139+
const CKeyingMaterial& GetEncryptionKey() const override;
1140+
bool HasEncryptionKeys() const override;
1141+
11391142
// Temporary LegacyScriptPubKeyMan accessors and aliases.
11401143
friend class LegacyScriptPubKeyMan;
11411144
std::unique_ptr<LegacyScriptPubKeyMan> m_spk_man = MakeUnique<LegacyScriptPubKeyMan>(*this);

0 commit comments

Comments
 (0)