mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-26 19:23:26 -03:00
wallet: Add HasCryptedKeys
This commit is contained in:
parent
0ca1d1bf69
commit
813a16a463
4 changed files with 24 additions and 0 deletions
|
@ -525,6 +525,12 @@ bool LegacyScriptPubKeyMan::HavePrivateKeys() const
|
||||||
return !mapKeys.empty() || !mapCryptedKeys.empty();
|
return !mapKeys.empty() || !mapCryptedKeys.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool LegacyScriptPubKeyMan::HaveCryptedKeys() const
|
||||||
|
{
|
||||||
|
LOCK(cs_KeyStore);
|
||||||
|
return !mapCryptedKeys.empty();
|
||||||
|
}
|
||||||
|
|
||||||
void LegacyScriptPubKeyMan::RewriteDB()
|
void LegacyScriptPubKeyMan::RewriteDB()
|
||||||
{
|
{
|
||||||
LOCK(cs_KeyStore);
|
LOCK(cs_KeyStore);
|
||||||
|
@ -2392,6 +2398,12 @@ bool DescriptorScriptPubKeyMan::HavePrivateKeys() const
|
||||||
return m_map_keys.size() > 0 || m_map_crypted_keys.size() > 0;
|
return m_map_keys.size() > 0 || m_map_crypted_keys.size() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DescriptorScriptPubKeyMan::HaveCryptedKeys() const
|
||||||
|
{
|
||||||
|
LOCK(cs_desc_man);
|
||||||
|
return !m_map_crypted_keys.empty();
|
||||||
|
}
|
||||||
|
|
||||||
std::optional<int64_t> DescriptorScriptPubKeyMan::GetOldestKeyPoolTime() const
|
std::optional<int64_t> DescriptorScriptPubKeyMan::GetOldestKeyPoolTime() const
|
||||||
{
|
{
|
||||||
// This is only used for getwalletinfo output and isn't relevant to descriptor wallets.
|
// This is only used for getwalletinfo output and isn't relevant to descriptor wallets.
|
||||||
|
|
|
@ -221,6 +221,7 @@ public:
|
||||||
virtual bool Upgrade(int prev_version, int new_version, bilingual_str& error) { return true; }
|
virtual bool Upgrade(int prev_version, int new_version, bilingual_str& error) { return true; }
|
||||||
|
|
||||||
virtual bool HavePrivateKeys() const { return false; }
|
virtual bool HavePrivateKeys() const { return false; }
|
||||||
|
virtual bool HaveCryptedKeys() const { return false; }
|
||||||
|
|
||||||
//! The action to do when the DB needs rewrite
|
//! The action to do when the DB needs rewrite
|
||||||
virtual void RewriteDB() {}
|
virtual void RewriteDB() {}
|
||||||
|
@ -472,6 +473,7 @@ public:
|
||||||
bool Upgrade(int prev_version, int new_version, bilingual_str& error) override;
|
bool Upgrade(int prev_version, int new_version, bilingual_str& error) override;
|
||||||
|
|
||||||
bool HavePrivateKeys() const override;
|
bool HavePrivateKeys() const override;
|
||||||
|
bool HaveCryptedKeys() const override;
|
||||||
|
|
||||||
void RewriteDB() override;
|
void RewriteDB() override;
|
||||||
|
|
||||||
|
@ -659,6 +661,7 @@ public:
|
||||||
bool HasPrivKey(const CKeyID& keyid) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
bool HasPrivKey(const CKeyID& keyid) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
||||||
//! Retrieve the particular key if it is available. Returns nullopt if the key is not in the wallet, or if the wallet is locked.
|
//! Retrieve the particular key if it is available. Returns nullopt if the key is not in the wallet, or if the wallet is locked.
|
||||||
std::optional<CKey> GetKey(const CKeyID& keyid) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
std::optional<CKey> GetKey(const CKeyID& keyid) const EXCLUSIVE_LOCKS_REQUIRED(cs_desc_man);
|
||||||
|
bool HaveCryptedKeys() const override;
|
||||||
|
|
||||||
std::optional<int64_t> GetOldestKeyPoolTime() const override;
|
std::optional<int64_t> GetOldestKeyPoolTime() const override;
|
||||||
unsigned int GetKeyPoolSize() const override;
|
unsigned int GetKeyPoolSize() const override;
|
||||||
|
|
|
@ -3695,6 +3695,14 @@ bool CWallet::HasEncryptionKeys() const
|
||||||
return !mapMasterKeys.empty();
|
return !mapMasterKeys.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CWallet::HaveCryptedKeys() const
|
||||||
|
{
|
||||||
|
for (const auto& spkm : GetAllScriptPubKeyMans()) {
|
||||||
|
if (spkm->HaveCryptedKeys()) return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void CWallet::ConnectScriptPubKeyManNotifiers()
|
void CWallet::ConnectScriptPubKeyManNotifiers()
|
||||||
{
|
{
|
||||||
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
|
for (const auto& spk_man : GetActiveScriptPubKeyMans()) {
|
||||||
|
|
|
@ -969,6 +969,7 @@ public:
|
||||||
bool WithEncryptionKey(std::function<bool (const CKeyingMaterial&)> cb) const override;
|
bool WithEncryptionKey(std::function<bool (const CKeyingMaterial&)> cb) const override;
|
||||||
|
|
||||||
bool HasEncryptionKeys() const override;
|
bool HasEncryptionKeys() const override;
|
||||||
|
bool HaveCryptedKeys() const;
|
||||||
|
|
||||||
/** Get last block processed height */
|
/** Get last block processed height */
|
||||||
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
|
int GetLastBlockHeight() const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet)
|
||||||
|
|
Loading…
Add table
Reference in a new issue