mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-17 13:07:54 +02:00
Disallow encryption of watchonly wallets
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.
Github-Pull: bitcoin-core/gui#631
Rebased-From: 4c495413e1
(cherry picked from commit 7b7bbc145aedf149c6d8675c7e252b0767bb8652)
This commit is contained in:
parent
47a07facdf
commit
a12aceedf7
3 changed files with 12 additions and 0 deletions
|
|
@ -1283,6 +1283,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);
|
||||
|
|
|
|||
|
|
@ -343,6 +343,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
Add a link
Reference in a new issue