Merge bitcoin/bitcoin#26521: [22.x] GUI backports

272fa25304 Fixes bitcoin#26490 by preventing notifications (John Moffett)
7b7bbc145a Disallow encryption of watchonly wallets (Andrew Chow)

Pull request description:

  Backports:
  - bitcoin-core/gui#631
  - bitcoin-core/gui#680

ACKs for top commit:
  jarolrod:
    ACK 272fa25304

Tree-SHA512: 4c285327464240ace3884d9653cc46d8e7b60b888f3b096ceb4fd5000d084ea8d97f1ef86ca1dea8dc7d3be8cdd2da19eece2b8c5b7351c5961b50b78fcd4c4d
This commit is contained in:
fanquake 2022-11-22 09:20:42 +00:00
commit c192b86c0b
No known key found for this signature in database
GPG key ID: 2EEB9F5CC09526C1
3 changed files with 14 additions and 2 deletions

View file

@ -488,7 +488,7 @@ void BitcoinGUI::createMenuBar()
connect(minimize_action, &QAction::triggered, [] {
QApplication::activeWindow()->showMinimized();
});
connect(qApp, &QApplication::focusWindowChanged, [minimize_action] (QWindow* window) {
connect(qApp, &QApplication::focusWindowChanged, this, [minimize_action] (QWindow* window) {
minimize_action->setEnabled(window != nullptr && (window->flags() & Qt::Dialog) != Qt::Dialog && window->windowState() != Qt::WindowMinimized);
});
@ -503,7 +503,7 @@ void BitcoinGUI::createMenuBar()
}
});
connect(qApp, &QApplication::focusWindowChanged, [zoom_action] (QWindow* window) {
connect(qApp, &QApplication::focusWindowChanged, this, [zoom_action] (QWindow* window) {
zoom_action->setEnabled(window != nullptr);
});
#endif
@ -1310,6 +1310,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);

View file

@ -305,6 +305,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())

View file

@ -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()