mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge bitcoin-core/gui#631: Disallow encryption of watchonly wallets
4c495413e1
Disallow encryption of watchonly wallets (Andrew Chow) Pull request description: Watchonly wallets do not have any private keys to encrypt. It does not make sense to encrypt such wallets, so disable the option to encrypt them. This avoids an assertion that can be hit when encrypting watchonly descriptor wallets. As our current behavior allows for encrypting watchonly wallets (no crash with legacy, crash, but still encrypted with descriptors), the new `NoKeys` status is only returned for unencrypted watchonly wallets. This allows any watchonly wallets that were previously encrypted to show the correct encryption status (they have encryption keys, and so should be indicated as being encrypted). ACKs for top commit: w0xlt: tACK4c495413e1
hebasto: ACK4c495413e1
, tested on Ubuntu 22.04. Tree-SHA512: 054dba0a8c1343a0df17689508cd628a974555828955a3c8820bf020868b95a3df98c47253b0ffe2252765b020160bb76ea21647d76d59ba748b3b41c481f2ae
This commit is contained in:
commit
6d8707b21d
3 changed files with 12 additions and 0 deletions
|
@ -1350,6 +1350,12 @@ void BitcoinGUI::setEncryptionStatus(int status)
|
|||
{
|
||||
switch(status)
|
||||
{
|
||||
case WalletModel::NoKeys:
|
||||
labelWalletEncryptionIcon->hide();
|
||||
encryptWalletAction->setChecked(false);
|
||||
changePassphraseAction->setEnabled(false);
|
||||
encryptWalletAction->setEnabled(false);
|
||||
break;
|
||||
case WalletModel::Unencrypted:
|
||||
labelWalletEncryptionIcon->hide();
|
||||
encryptWalletAction->setChecked(false);
|
||||
|
|
|
@ -306,6 +306,11 @@ WalletModel::EncryptionStatus WalletModel::getEncryptionStatus() const
|
|||
{
|
||||
if(!m_wallet->isCrypted())
|
||||
{
|
||||
// A previous bug allowed for watchonly wallets to be encrypted (encryption keys set, but nothing is actually encrypted).
|
||||
// To avoid misrepresenting the encryption status of such wallets, we only return NoKeys for watchonly wallets that are unencrypted.
|
||||
if (m_wallet->privateKeysDisabled()) {
|
||||
return NoKeys;
|
||||
}
|
||||
return Unencrypted;
|
||||
}
|
||||
else if(m_wallet->isLocked())
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
|
||||
enum EncryptionStatus
|
||||
{
|
||||
NoKeys, // wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)
|
||||
Unencrypted, // !wallet->IsCrypted()
|
||||
Locked, // wallet->IsCrypted() && wallet->IsLocked()
|
||||
Unlocked // wallet->IsCrypted() && !wallet->IsLocked()
|
||||
|
|
Loading…
Add table
Reference in a new issue