diff options
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/receivecoinsdialog.cpp | 7 | ||||
-rw-r--r-- | src/qt/walletmodel.cpp | 12 | ||||
-rw-r--r-- | src/qt/walletmodel.h | 4 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/qt/receivecoinsdialog.cpp b/src/qt/receivecoinsdialog.cpp index 8942188dc9..22a79a12bb 100644 --- a/src/qt/receivecoinsdialog.cpp +++ b/src/qt/receivecoinsdialog.cpp @@ -100,8 +100,13 @@ void ReceiveCoinsDialog::setModel(WalletModel *_model) ui->useBech32->setCheckState(Qt::Unchecked); } - // eventually disable the main receive button if private key operations are disabled + // Set the button to be enabled or disabled based on whether the wallet can give out new addresses. ui->receiveButton->setEnabled(model->canGetAddresses()); + + // Enable/disable the receive button if the wallet is now able/unable to give out new addresses. + connect(model, &WalletModel::canGetAddressesChanged, [this] { + ui->receiveButton->setEnabled(model->canGetAddresses()); + }); } } diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 73fce02554..2a9144bec9 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -423,6 +423,11 @@ static void NotifyWatchonlyChanged(WalletModel *walletmodel, bool fHaveWatchonly Q_ARG(bool, fHaveWatchonly)); } +static void NotifyCanGetAddressesChanged(WalletModel* walletmodel) +{ + QMetaObject::invokeMethod(walletmodel, "canGetAddressesChanged"); +} + void WalletModel::subscribeToCoreSignals() { // Connect signals to wallet @@ -432,6 +437,7 @@ void WalletModel::subscribeToCoreSignals() m_handler_transaction_changed = m_wallet->handleTransactionChanged(std::bind(NotifyTransactionChanged, this, std::placeholders::_1, std::placeholders::_2)); m_handler_show_progress = m_wallet->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2)); m_handler_watch_only_changed = m_wallet->handleWatchOnlyChanged(std::bind(NotifyWatchonlyChanged, this, std::placeholders::_1)); + m_handler_can_get_addrs_changed = m_wallet->handleCanGetAddressesChanged(boost::bind(NotifyCanGetAddressesChanged, this)); } void WalletModel::unsubscribeFromCoreSignals() @@ -443,6 +449,7 @@ void WalletModel::unsubscribeFromCoreSignals() m_handler_transaction_changed->disconnect(); m_handler_show_progress->disconnect(); m_handler_watch_only_changed->disconnect(); + m_handler_can_get_addrs_changed->disconnect(); } // WalletModel::UnlockContext implementation @@ -573,6 +580,11 @@ bool WalletModel::privateKeysDisabled() const bool WalletModel::canGetAddresses() const { + // The wallet can provide a fresh address if: + // * hdEnabled(): an HD seed is present; or + // * it is a legacy wallet, because: + // * !hdEnabled(): an HD seed is not present; and + // * !IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS): private keys have not been disabled (which results in hdEnabled() == true) return m_wallet->hdEnabled() || (!m_wallet->hdEnabled() && !m_wallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)); } diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 8d7b210d2e..b123befbb4 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -233,6 +233,7 @@ private: std::unique_ptr<interfaces::Handler> m_handler_transaction_changed; std::unique_ptr<interfaces::Handler> m_handler_show_progress; std::unique_ptr<interfaces::Handler> m_handler_watch_only_changed; + std::unique_ptr<interfaces::Handler> m_handler_can_get_addrs_changed; interfaces::Node& m_node; bool fHaveWatchOnly; @@ -284,6 +285,9 @@ Q_SIGNALS: // Signal that wallet is about to be removed void unload(); + // Notify that there are now keys in the keypool + void canGetAddressesChanged(); + public Q_SLOTS: /* Wallet status might have changed */ void updateStatus(); |