mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 14:53:43 +01:00
Merge bitcoin/bitcoin#28724: wallet: Cleanup accidental encryption keys in watchonly wallets
69e95c2b4ftests: Test cleanup of mkeys from wallets without privkeys (Andrew Chow)2b9279b50awallet: Remove unused encryption keys from watchonly wallets (Andrew Chow)813a16a463wallet: Add HasCryptedKeys (Andrew Chow) Pull request description: An earlier version allowed users to create watchonly wallets (wallets without private keys) that were "encrypted". Such wallets would have a stored encryption keys, but nothing would actually be encrypted with them. This can cause unexpected behavior such as https://github.com/bitcoin-core/gui/issues/772. We can detect such wallets as they will have the disable private keys flag set, no encrypted keys, and encryption keys. For such wallets, we can remove those encryption keys thereby avoiding any issues that may result from this unexpected situation. ACKs for top commit: sipa: utACK69e95c2b4f. laanwj: Code review re-ACK69e95c2b4ffurszy: Code review ACK69e95c2b4fTree-SHA512: 901932cd709c57e66c598f011f0105a243b5a8b539db2ef3fcf370dca4cf35ae09bc1110e8fca8353be470f159468855a4dd96b99bc9c1112adc86ccc50e1b9d
This commit is contained in:
@@ -525,6 +525,12 @@ bool LegacyScriptPubKeyMan::HavePrivateKeys() const
|
||||
return !mapKeys.empty() || !mapCryptedKeys.empty();
|
||||
}
|
||||
|
||||
bool LegacyScriptPubKeyMan::HaveCryptedKeys() const
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
return !mapCryptedKeys.empty();
|
||||
}
|
||||
|
||||
void LegacyScriptPubKeyMan::RewriteDB()
|
||||
{
|
||||
LOCK(cs_KeyStore);
|
||||
@@ -2411,6 +2417,12 @@ bool DescriptorScriptPubKeyMan::HavePrivateKeys() const
|
||||
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
|
||||
{
|
||||
// This is only used for getwalletinfo output and isn't relevant to descriptor wallets.
|
||||
|
||||
Reference in New Issue
Block a user