Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/qt/appearancewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private Q_SLOTS:
private:
Ui::AppearanceWidget* ui;
QDataWidgetMapper* mapper;
OptionsModel* model;
OptionsModel* model{nullptr};
bool fAcceptChanges{false};
QString prevTheme;
int prevScale;
Expand Down
1 change: 1 addition & 0 deletions src/qt/clientfeeds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ void ProposalFeed::fetch()

const auto data_mn = m_feed_masternode.data();
if (!data_mn || !data_mn->m_valid) {
m_retry_pending.store(true);
return;
}

Expand Down
2 changes: 2 additions & 0 deletions src/qt/clientmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ void ClientModel::stop()
{
unsubscribeFromCoreSignals();

m_feeds->stop();

m_thread->quit();
m_thread->wait();
}
Expand Down
21 changes: 17 additions & 4 deletions src/qt/masternodedialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ MasternodeActionDialog::MasternodeActionDialog(interfaces::Node& node, WalletMod
m_wallet_model{wallet_model},
m_protx_hash{entry.proTxHashRaw()},
m_operator_pubkey{entry.operatorPubKeyBytes()},
m_is_shared{entry.isShared()},
m_runner{wallet_model ? new MasternodeOperationRunner(node.evo(), wallet_model->wallet(), this) : nullptr}
{
}
Expand Down Expand Up @@ -228,10 +229,11 @@ bool MasternodeActionDialog::canSign() const
return m_wallet_model != nullptr && !m_wallet_model->wallet().privateKeysDisabled();
}

void MasternodeActionDialog::setOkValid(bool valid)
void MasternodeActionDialog::setOkValid(bool valid, const QString& tooltip)
{
m_valid = valid;
if (m_ok_button) m_ok_button->setEnabled(valid && canSign() && !m_busy);
if (m_ok_button && canSign()) m_ok_button->setToolTip(tooltip);
}

void MasternodeActionDialog::showError(const QString& message)
Expand Down Expand Up @@ -279,7 +281,7 @@ void MasternodeActionDialog::setBusy(bool busy)
QApplication::restoreOverrideCursor();
}
if (m_button_box) m_button_box->setEnabled(!busy);
setOkValid(m_valid);
if (m_ok_button) setOkValid(m_valid, m_ok_button->toolTip());
}

void MasternodeActionDialog::resolveOperatorKey(OperatorSecretWidget& widget, SecretCallback callback)
Expand Down Expand Up @@ -421,6 +423,8 @@ UpdateServiceDialog::UpdateServiceDialog(interfaces::Node& node, WalletModel* wa
"payout. Select an address only to override that choice."));
}

connect(m_fee_source, qOverload<int>(&QComboBox::currentIndexChanged), this, &UpdateServiceDialog::validate);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

setupUi(m_type == MnType::Evo ? tr("Update EvoNode Service") : tr("Update Masternode Service"),
tr("Update the registered service endpoints. A successful update also revives a PoSe-banned "
"masternode. Every current value is prefilled so unchanged fields are preserved."),
Expand All @@ -438,7 +442,9 @@ void UpdateServiceDialog::validate()
if (m_type == MnType::Evo) {
ok &= IsValidPlatformNodeId(m_platform_node_id_edit->text().trimmed());
}
setOkValid(ok);
const bool has_fee_source{!m_is_shared || !m_fee_source->selectedAddress().isEmpty()};
setOkValid(ok && has_fee_source,
has_fee_source ? QString{} : tr("Select a wallet address with funds to pay the transaction fee."));
}

std::optional<interfaces::ProviderNetInfo> UpdateServiceDialog::buildNetInfo(QString& error) const
Expand Down Expand Up @@ -681,13 +687,20 @@ RevokeDialog::RevokeDialog(interfaces::Node& node, WalletModel* wallet_model, co
"payout. Select an address only to override that choice."));
}

connect(m_fee_source, qOverload<int>(&QComboBox::currentIndexChanged), this, &RevokeDialog::validate);

setupUi(tr("Revoke Masternode Service"),
tr("Revoking clears the service address and PoSe-bans the masternode until its owner changes the "
"operator key. The collateral is not affected."),
form, tr("Revoke"));
}

void RevokeDialog::validate() { setOkValid(m_operator_key->isValid()); }
void RevokeDialog::validate()
{
const bool has_fee_source{!m_is_shared || !m_fee_source->selectedAddress().isEmpty()};
setOkValid(m_operator_key->isValid() && has_fee_source,
has_fee_source ? QString{} : tr("Select a wallet address with funds to pay the transaction fee."));
}

std::optional<interfaces::ProviderRevokeRequest> RevokeDialog::buildRequest(CBLSSecretKey operator_key, QString& error) const
{
Expand Down
3 changes: 2 additions & 1 deletion src/qt/masternodedialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public Q_SLOTS:
FeeSourcePicker* addFeeSourceRow(QFormLayout* form, const QString& automatic_note);

bool canSign() const;
void setOkValid(bool valid);
void setOkValid(bool valid, const QString& tooltip = {});
void showError(const QString& message);
void clearError();
void abortOperation(const QString& message);
Expand All @@ -106,6 +106,7 @@ public Q_SLOTS:
WalletModel* const m_wallet_model;
const uint256 m_protx_hash;
const std::vector<unsigned char> m_operator_pubkey;
const bool m_is_shared;
MasternodeOperationRunner* const m_runner;

protected Q_SLOTS:
Expand Down
19 changes: 11 additions & 8 deletions src/qt/optionsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
#endif

pageButtons = new QButtonGroup(this);
pageButtons->addButton(ui->btnMain, pageButtons->buttons().size());
pageButtons->addButton(ui->btnMain, TAB_MAIN);
pageButtons->addButton(ui->btnWallet, TAB_WALLET);
pageButtons->addButton(ui->btnCoinJoin, TAB_COINJOIN);
pageButtons->addButton(ui->btnNetwork, TAB_NETWORK);
pageButtons->addButton(ui->btnDisplay, TAB_DISPLAY);
pageButtons->addButton(ui->btnAppearance, TAB_APPEARANCE);

/* Remove Wallet/CoinJoin tabs and 3rd party-URL textbox in case of -disablewallet */
if (!m_enable_wallet) {
ui->stackedWidgetOptions->removeWidget(ui->pageWallet);
Expand All @@ -124,16 +130,11 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
ui->showGovernanceCycleIcon->hide();
} else {
ui->btnCoinJoin->setText(QString::fromStdString(gCoinJoinName));
pageButtons->addButton(ui->btnWallet, pageButtons->buttons().size());
pageButtons->addButton(ui->btnCoinJoin, pageButtons->buttons().size());
}
pageButtons->addButton(ui->btnNetwork, pageButtons->buttons().size());
pageButtons->addButton(ui->btnDisplay, pageButtons->buttons().size());
pageButtons->addButton(ui->btnAppearance, pageButtons->buttons().size());

connect(pageButtons, &QButtonGroup::idClicked, this, &OptionsDialog::showPage);

showPage(0);
showPage(TAB_MAIN);

#ifdef ENABLE_EXTERNAL_SIGNER
ui->externalSignerPath->setToolTip(ui->externalSignerPath->toolTip().arg(PACKAGE_NAME));
Expand Down Expand Up @@ -416,7 +417,9 @@ void OptionsDialog::showPage(int index)
GUIUtil::setFont(vecNormal, GUIUtil::FontWeight::Normal, 16);
GUIUtil::updateFonts();

ui->stackedWidgetOptions->setCurrentIndex(index);
QWidget* const pages[]{ui->pageMain, ui->pageWallet, ui->pageCoinJoin,
ui->pageNetwork, ui->pageDisplay, ui->pageAppearance};
ui->stackedWidgetOptions->setCurrentWidget(pages[index]);
btnActive->setChecked(true);
}

Expand Down
8 changes: 6 additions & 2 deletions src/qt/psbtoperationsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,13 @@ void PSBTOperationsDialog::saveTransaction() {
if (filename.isEmpty()) {
return;
}
std::ofstream out{filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary};
std::ofstream out(GUIUtil::QStringToPath(filename), std::ofstream::out | std::ofstream::binary);
out << ssTx.str();
out.close();
if (!out) {
showStatus(tr("Failed to save PSBT to disk."), StatusLevel::ERR);
return;
}
showStatus(tr("PSBT saved to disk."), StatusLevel::INFO);
}

Expand Down Expand Up @@ -190,7 +194,7 @@ QString PSBTOperationsDialog::renderTransaction(const PartiallySignedTransaction

PSBTAnalysis analysis = AnalyzePSBT(psbtx);
tx_description.append(bullet_point);
if (!*analysis.fee) {
if (!analysis.fee.has_value()) {
// This happens if the transaction is missing input UTXO information.
tx_description.append(tr("Unable to calculate transaction fee or total transaction amount."));
} else {
Expand Down
10 changes: 7 additions & 3 deletions src/qt/sendcoinsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void SendCoinsDialog::setModel(WalletModel *_model)
fKeepChangeAddress = _model->getOptionsModel()->getKeepChangeAddress();

QSettings settings;
if (fKeepChangeAddress && settings.contains("sCustomChangeAddress")) {
if (!m_coin_control->IsUsingCoinJoin() && fKeepChangeAddress && settings.contains("sCustomChangeAddress")) {
ui->checkBoxCoinControlChange->setChecked(true);
ui->lineEditCoinControlChange->setText(settings.value("sCustomChangeAddress").toString());
coinControlChangeEdited(ui->lineEditCoinControlChange->text());
Expand Down Expand Up @@ -249,7 +249,7 @@ void SendCoinsDialog::setModel(WalletModel *_model)
SendCoinsDialog::~SendCoinsDialog()
{
QSettings settings;
if (fKeepChangeAddress) {
if (fKeepChangeAddress && !m_coin_control->IsUsingCoinJoin()) {
settings.setValue("sCustomChangeAddress", ui->lineEditCoinControlChange->text());
}
Comment thread
PastaPastaPasta marked this conversation as resolved.
Resolved
settings.setValue("fFeeSectionMinimized", fFeeMinimized);
Expand Down Expand Up @@ -528,9 +528,13 @@ void SendCoinsDialog::presentPSBT(PartiallySignedTransaction& psbtx)
if (filename.isEmpty()) {
return;
}
std::ofstream out{filename.toLocal8Bit().data(), std::ofstream::out | std::ofstream::binary};
std::ofstream out(GUIUtil::QStringToPath(filename), std::ofstream::out | std::ofstream::binary);
out << ssTx.str();
out.close();
if (!out) {
Q_EMIT message(tr("PSBT save failed"), tr("Failed to save PSBT to disk"), CClientUIInterface::MSG_ERROR);
break;
}
//: Popup message when a PSBT has been saved to a file
Q_EMIT message(tr("PSBT saved"), tr("PSBT saved to disk"), CClientUIInterface::MSG_INFORMATION);
break;
Expand Down
1 change: 0 additions & 1 deletion src/qt/sharedmndialogs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,6 @@ bool ComputeSharedSignHash(SharedSigCollector::Kind kind, const QString& pro_tx_
UpdateShareDialog::UpdateShareDialog(interfaces::Node& node, WalletModel* wallet_model, const MasternodeEntry& entry, QWidget* parent) :
MasternodeActionDialog(node, wallet_model, entry, parent),
m_v24_active{node.isV24Active()},
m_is_shared{entry.isShared()},
m_voting_address{entry.votingAddress()},
m_shares{entry.shares()}
{
Expand Down
1 change: 0 additions & 1 deletion src/qt/sharedmndialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class UpdateShareDialog : public MasternodeActionDialog
void useNewAddress();

const bool m_v24_active;
const bool m_is_shared;
const QString m_voting_address;
const std::vector<interfaces::MnShare> m_shares;

Expand Down
34 changes: 34 additions & 0 deletions src/qt/test/masternodemaintenancetests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <QApplication>
#include <QClipboard>
#include <QComboBox>
#include <QDialogButtonBox>
#include <QDir>
#include <QFile>
#include <QFocusEvent>
Expand Down Expand Up @@ -300,6 +301,39 @@ void MasternodeMaintenanceTests::automaticFeeSource()
const auto shared_revocation{shared_revoke.buildRequest(shared->operatorSecret(), error)};
QVERIFY2(shared_revocation.has_value(), qPrintable(error));
QVERIFY(shared_revocation->fee_source == std::optional<CTxDestination>{funded});

const auto empty_wallet{MakeTestWallet(m_node, context, "unfunded_operator")};
QVERIFY(empty_wallet != nullptr);
guard.keep(empty_wallet);
WalletModel empty_model(interfaces::MakeWallet(context, empty_wallet), models.client);
UpdateServiceDialog unfunded_service(m_node, &empty_model, shared_entry, capabilities, nullptr);
RevokeDialog unfunded_revoke(m_node, &empty_model, shared_entry, nullptr);
auto check_fee_selection = [&](MasternodeActionDialog& dialog, bool has_funds) {
auto* key_widget = dialog.findChild<OperatorSecretWidget*>();
QVERIFY(key_widget);
key_widget->findChild<QLineEdit*>()->setText(QString::fromStdString(shared->operatorSecret().ToString(false)));
QVERIFY(key_widget->isValid());
auto* fee_picker = dialog.findChild<FeeSourcePicker*>();
auto* buttons = dialog.findChild<QDialogButtonBox*>();
QVERIFY(fee_picker);
QVERIFY(buttons);
QCOMPARE(fee_picker->count(), has_funds ? 1 : 0);
auto* ok_button = buttons->button(QDialogButtonBox::Ok);
QCOMPARE(ok_button->isEnabled(), has_funds);
QCOMPARE(ok_button->toolTip().isEmpty(), has_funds);
if (has_funds) {
fee_picker->setCurrentIndex(-1);
QVERIFY(!ok_button->isEnabled());
QVERIFY(!ok_button->toolTip().isEmpty());
fee_picker->setCurrentIndex(0);
QVERIFY(ok_button->isEnabled());
QVERIFY(ok_button->toolTip().isEmpty());
}
};
check_fee_selection(unfunded_service, false);
check_fee_selection(unfunded_revoke, false);
check_fee_selection(shared_service, true);
check_fee_selection(shared_revoke, true);
}

void MasternodeMaintenanceTests::operatorSecretValidation()
Expand Down
15 changes: 15 additions & 0 deletions src/qt/test/optiontests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#include <init.h>
#include <qt/bitcoin.h>
#include <qt/guiutil.h>
#include <qt/optionsdialog.h>
#include <qt/test/optiontests.h>
#include <test/util/setup_common.h>

#include <QApplication>
#include <QFont>
#include <QLabel>
#include <QSettings>
#include <QStackedWidget>
#include <QTest>
#include <QWidget>

Expand Down Expand Up @@ -325,3 +327,16 @@ void OptionTests::fontScaleSources()
set_sources(none, none, none);
GUIUtil::setFontScale(previous_scale);
}

void OptionTests::tabsWithoutWallet()
{
OptionsDialog dialog{nullptr, /*enableWallet=*/false};
auto* pages = dialog.findChild<QStackedWidget*>("stackedWidgetOptions");
Comment thread
PastaPastaPasta marked this conversation as resolved.
Resolved
QVERIFY(pages);
dialog.setCurrentTab(OptionsDialog::TAB_NETWORK);
QCOMPARE(pages->currentWidget()->objectName(), QString{"pageNetwork"});
dialog.setCurrentTab(OptionsDialog::TAB_DISPLAY);
QCOMPARE(pages->currentWidget()->objectName(), QString{"pageDisplay"});
dialog.setCurrentTab(OptionsDialog::TAB_APPEARANCE);
QCOMPARE(pages->currentWidget()->objectName(), QString{"pageAppearance"});
}
1 change: 1 addition & 0 deletions src/qt/test/optiontests.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ private Q_SLOTS:
void invalidLangSetting();
void parametersInteraction();
void extractFilter();
void tabsWithoutWallet();
void effectivePointSize();
void updateFontsWithPixelSizedWidget();
void fontScaleSources();
Expand Down
18 changes: 15 additions & 3 deletions src/qt/walletcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,15 +573,27 @@ void MigrateWalletActivity::migrate(WalletModel* wallet_model)
"an incorrect migration, the backup can be restored with the \"Restore Wallet\" functionality."));
box.setStandardButtons(QMessageBox::Yes|QMessageBox::Cancel);
box.setDefaultButton(QMessageBox::Yes);
if (box.exec() != QMessageBox::Yes) return;
if (box.exec() != QMessageBox::Yes) {
Q_EMIT finished();
return;
}

// Get the passphrase if it is encrypted regardless of it is locked or unlocked. We need the passphrase itself.
SecureString passphrase;
WalletModel::EncryptionStatus enc_status = wallet_model->getEncryptionStatus();
if (enc_status == WalletModel::EncryptionStatus::Locked || enc_status == WalletModel::EncryptionStatus::Unlocked) {
if (enc_status == WalletModel::EncryptionStatus::Locked ||
enc_status == WalletModel::EncryptionStatus::Unlocked ||
enc_status == WalletModel::EncryptionStatus::UnlockedForMixingOnly) {
AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, m_parent_widget, &passphrase);
dlg.setModel(wallet_model);
dlg.exec();
if (dlg.exec() != QDialog::Accepted) {
// A failed unlock attempt can leave the wallet unlocked.
if (enc_status != WalletModel::EncryptionStatus::Unlocked) {
wallet_model->setWalletLocked(true, {}, enc_status == WalletModel::EncryptionStatus::UnlockedForMixingOnly);
}
Q_EMIT finished();
return;
Comment thread
PastaPastaPasta marked this conversation as resolved.
Resolved
Comment thread
PastaPastaPasta marked this conversation as resolved.
Resolved
}
}

// GUI needs to remove the wallet so that it can actually be unloaded by migration
Expand Down
Loading