From b399472de8f16c419b2ad79b64ed57fc33153ccd Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Thu, 6 Jun 2024 13:17:55 +0000 Subject: [PATCH] GUI/Options: Configure mempooltruc using settings --- src/qt/optionsdialog.cpp | 16 ++++++++++++++++ src/qt/optionsdialog.h | 1 + src/qt/optionsmodel.cpp | 27 +++++++++++++++++++++++++++ src/qt/optionsmodel.h | 1 + 4 files changed, 45 insertions(+) diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index ebb1d67e06..7ac188cc24 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -237,6 +237,13 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet) mempoolreplacement->addItem(QString("with a higher mining fee (no opt-out)"), QVariant("fee,-optin")); CreateOptionUI(verticalLayout_Mempool, mempoolreplacement, tr("Transaction &replacement: %s")); + mempooltruc = new QValueComboBox(tabMempool); + mempooltruc->addItem(QString("do not relay or mine at all"), QVariant("reject")); + mempooltruc->addItem(QString("handle the same as other transactions"), QVariant("accept")); + mempooltruc->addItem(QString("impose stricter limits requested (DRAFT)"), QVariant("enforce")); + mempooltruc->setToolTip(tr("Some transactions signal a request to limit both themselves and other related transactions to more restrictive expectations. Specifically, this would disallow more than 1 unconfirmed predecessor or spending transaction, as well as smaller size limits (see BIP 431 for details), regardless of what policy you have configured.")); + CreateOptionUI(verticalLayout_Mempool, mempooltruc, tr("Transactions requesting more restrictive policy limits (TRUC): %s")); + maxorphantx = new QSpinBox(tabMempool); maxorphantx->setMinimum(0); maxorphantx->setMaximum(std::numeric_limits::max()); @@ -707,6 +714,14 @@ void OptionsDialog::setMapper() } mempoolreplacement->setCurrentIndex(current_mempoolreplacement_index); + QVariant current_mempooltruc = model->data(model->index(OptionsModel::mempooltruc, 0), Qt::EditRole); + int current_mempooltruc_index = mempooltruc->findData(current_mempooltruc); + if (current_mempooltruc_index == -1) { + mempooltruc->addItem(current_mempooltruc.toString(), current_mempooltruc); + current_mempooltruc_index = mempooltruc->count() - 1; + } + mempooltruc->setCurrentIndex(current_mempooltruc_index); + mapper->addMapping(maxorphantx, OptionsModel::maxorphantx); mapper->addMapping(maxmempool, OptionsModel::maxmempool); mapper->addMapping(incrementalrelayfee, OptionsModel::incrementalrelayfee); @@ -920,6 +935,7 @@ void OptionsDialog::on_okButton_clicked() } model->setData(model->index(OptionsModel::mempoolreplacement, 0), mempoolreplacement->itemData(mempoolreplacement->currentIndex())); + model->setData(model->index(OptionsModel::mempooltruc, 0), mempooltruc->itemData(mempooltruc->currentIndex())); if (dustdynamic_enable->isChecked()) { if (dustdynamic_target->isChecked()) { diff --git a/src/qt/optionsdialog.h b/src/qt/optionsdialog.h index 550e1f7a7d..f6001fe3c5 100644 --- a/src/qt/optionsdialog.h +++ b/src/qt/optionsdialog.h @@ -103,6 +103,7 @@ private: QSpinBox *blockreconstructionextratxn; QValueComboBox *mempoolreplacement; + QValueComboBox *mempooltruc; QSpinBox *maxorphantx; BitcoinAmountField *incrementalrelayfee; QSpinBox *maxmempool; diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index e8013c08a2..86214e4fd2 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -223,6 +223,16 @@ static QString CanonicalMempoolReplacement(const OptionsModel& model) assert(0); } +static QString CanonicalMempoolTRUC(const OptionsModel& model) +{ + switch (model.node().mempool().m_opts.truc_policy) { + case TRUCPolicy::Reject: return "reject"; + case TRUCPolicy::Accept: return "accept"; + case TRUCPolicy::Enforce: return "enforce"; + } + assert(0); +} + OptionsModel::OptionsModel(interfaces::Node& node, QObject *parent) : QAbstractListModel(parent), m_node{node} { @@ -650,6 +660,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con return gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS); case mempoolreplacement: return CanonicalMempoolReplacement(*this); + case mempooltruc: + return CanonicalMempoolTRUC(*this); case maxorphantx: return qlonglong(gArgs.GetIntArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS)); case maxmempool: @@ -1049,6 +1061,21 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std:: } break; } + case mempooltruc: + { + if (changed()) { + QString nv = value.toString(); + if (nv == "reject") { + node().mempool().m_opts.truc_policy = TRUCPolicy::Reject; + } else if (nv == "accept") { + node().mempool().m_opts.truc_policy = TRUCPolicy::Accept; + } else if (nv == "enforce") { + node().mempool().m_opts.truc_policy = TRUCPolicy::Enforce; + } + node().updateRwSetting("mempooltruc", nv.toStdString()); + } + break; + } case maxorphantx: { if (changed()) { diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 7b502f1b14..46f812f808 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -82,6 +82,7 @@ public: peerbloomfilters, // bool peerblockfilters, // bool mempoolreplacement, + mempooltruc, maxorphantx, maxmempool, incrementalrelayfee,