From 0551bcd0ff9f219229a782a3280a42b39b25f681 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Tue, 4 Feb 2025 00:08:02 +0000 Subject: [PATCH] Qt/Options: Configure spkreuse using rwconf --- src/qt/optionsdialog.cpp | 9 +++++++++ src/qt/optionsdialog.h | 1 + src/qt/optionsmodel.cpp | 12 ++++++++++++ src/qt/optionsmodel.h | 2 ++ 4 files changed, 24 insertions(+) diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index fca06369a6..d3ce3e529a 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -260,6 +260,12 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) verticalLayout_Spamfiltering->addWidget(rejectunknownscripts); FixTabOrder(rejectunknownscripts); + rejectspkreuse = new QCheckBox(groupBox_Spamfiltering); + rejectspkreuse->setText(tr("Disallow most address reuse")); + rejectspkreuse->setToolTip(tr("With this option enabled, your memory pool will only allow each unique payment destination to be used once, effectively deprioritising address reuse. Address reuse is not technically supported, and harms the privacy of all Bitcoin users. It also has limited real-world utility, and has been known to be common with spam.")); + verticalLayout_Spamfiltering->addWidget(rejectspkreuse); + FixTabOrder(rejectspkreuse); + minrelaytxfee = new BitcoinAmountField(groupBox_Spamfiltering); CreateOptionUI(verticalLayout_Spamfiltering, minrelaytxfee, tr("Ignore transactions offering miners less than %s per kvB in transaction fees.")); @@ -499,6 +505,8 @@ void OptionsDialog::setModel(OptionsModel *_model) connect(ui->connectSocksTor, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); connect(ui->peerbloomfilters, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); connect(ui->peerblockfilters, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); + /* Mempool */ + connect(rejectspkreuse, &QCheckBox::clicked, this, &OptionsDialog::showRestartWarning); /* Display */ connect(ui->lang, qOverload<>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); }); connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); }); @@ -594,6 +602,7 @@ void OptionsDialog::setMapper() mapper->addMapping(mempoolexpiry, OptionsModel::mempoolexpiry); mapper->addMapping(rejectunknownscripts, OptionsModel::rejectunknownscripts); + mapper->addMapping(rejectspkreuse, OptionsModel::rejectspkreuse); mapper->addMapping(minrelaytxfee, OptionsModel::minrelaytxfee); mapper->addMapping(bytespersigop, OptionsModel::bytespersigop); mapper->addMapping(bytespersigopstrict, OptionsModel::bytespersigopstrict); diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 642ceabfae..cd7051b885 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -106,6 +106,7 @@ private: QSpinBox *mempoolexpiry; QCheckBox *rejectunknownscripts; + QCheckBox *rejectspkreuse; BitcoinAmountField *minrelaytxfee; QSpinBox *bytespersigop, *bytespersigopstrict; QSpinBox *limitancestorcount; diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 20cb8a6c91..7a04fbf2ad 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -350,7 +350,9 @@ bool OptionsModel::Init(bilingual_str& error) addOverriddenOption("-port"); // rwconf settings that require a restart + // Caution: This is before general initialisation occurs! f_peerbloomfilters = gArgs.GetBoolArg("-peerbloomfilters", DEFAULT_PEERBLOOMFILTERS); + f_rejectspkreuse = !(gArgs.GetArg("-spkreuse", DEFAULT_SPKREUSE) == "allow" || gArgs.GetBoolArg("-spkreuse", false)); // Display if (settings.contains("FontForMoney")) { @@ -653,6 +655,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con return qlonglong(std::chrono::duration_cast(node().mempool().m_opts.expiry).count()); case rejectunknownscripts: return node().mempool().m_opts.require_standard; + case rejectspkreuse: + return f_rejectspkreuse; case minrelaytxfee: return qlonglong(node().mempool().m_opts.min_relay_feerate.GetFeePerK()); case bytespersigop: @@ -1093,6 +1097,14 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std:: } break; } + case rejectspkreuse: + if (changed()) { + const bool fNewValue = value.toBool(); + gArgs.ModifyRWConfigFile("spkreuse", fNewValue ? "conflict" : "allow"); + f_rejectspkreuse = fNewValue; + setRestartRequired(true); + } + break; case minrelaytxfee: if (changed()) { CAmount nNv = value.toLongLong(); diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 333c0ea256..b04e1dd098 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -87,6 +87,7 @@ public: incrementalrelayfee, mempoolexpiry, rejectunknownscripts, // bool + rejectspkreuse, // bool minrelaytxfee, bytespersigop, bytespersigopstrict, @@ -178,6 +179,7 @@ private: /* rwconf settings that require a restart */ bool f_peerbloomfilters; + bool f_rejectspkreuse; // Add option to list of GUI options overridden through command line/config file void addOverriddenOption(const std::string &option);