Skip to content

Commit b399472

Browse files
committed
GUI/Options: Configure mempooltruc using settings
1 parent fdfc57b commit b399472

File tree

4 files changed

+45
-0
lines changed

4 files changed

+45
-0
lines changed

src/qt/optionsdialog.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
237237
mempoolreplacement->addItem(QString("with a higher mining fee (no opt-out)"), QVariant("fee,-optin"));
238238
CreateOptionUI(verticalLayout_Mempool, mempoolreplacement, tr("Transaction &replacement: %s"));
239239

240+
mempooltruc = new QValueComboBox(tabMempool);
241+
mempooltruc->addItem(QString("do not relay or mine at all"), QVariant("reject"));
242+
mempooltruc->addItem(QString("handle the same as other transactions"), QVariant("accept"));
243+
mempooltruc->addItem(QString("impose stricter limits requested (DRAFT)"), QVariant("enforce"));
244+
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."));
245+
CreateOptionUI(verticalLayout_Mempool, mempooltruc, tr("Transactions requesting more restrictive policy limits (TRUC): %s"));
246+
240247
maxorphantx = new QSpinBox(tabMempool);
241248
maxorphantx->setMinimum(0);
242249
maxorphantx->setMaximum(std::numeric_limits<int>::max());
@@ -707,6 +714,14 @@ void OptionsDialog::setMapper()
707714
}
708715
mempoolreplacement->setCurrentIndex(current_mempoolreplacement_index);
709716

717+
QVariant current_mempooltruc = model->data(model->index(OptionsModel::mempooltruc, 0), Qt::EditRole);
718+
int current_mempooltruc_index = mempooltruc->findData(current_mempooltruc);
719+
if (current_mempooltruc_index == -1) {
720+
mempooltruc->addItem(current_mempooltruc.toString(), current_mempooltruc);
721+
current_mempooltruc_index = mempooltruc->count() - 1;
722+
}
723+
mempooltruc->setCurrentIndex(current_mempooltruc_index);
724+
710725
mapper->addMapping(maxorphantx, OptionsModel::maxorphantx);
711726
mapper->addMapping(maxmempool, OptionsModel::maxmempool);
712727
mapper->addMapping(incrementalrelayfee, OptionsModel::incrementalrelayfee);
@@ -920,6 +935,7 @@ void OptionsDialog::on_okButton_clicked()
920935
}
921936

922937
model->setData(model->index(OptionsModel::mempoolreplacement, 0), mempoolreplacement->itemData(mempoolreplacement->currentIndex()));
938+
model->setData(model->index(OptionsModel::mempooltruc, 0), mempooltruc->itemData(mempooltruc->currentIndex()));
923939

924940
if (dustdynamic_enable->isChecked()) {
925941
if (dustdynamic_target->isChecked()) {

src/qt/optionsdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ private Q_SLOTS:
103103
QSpinBox *blockreconstructionextratxn;
104104

105105
QValueComboBox *mempoolreplacement;
106+
QValueComboBox *mempooltruc;
106107
QSpinBox *maxorphantx;
107108
BitcoinAmountField *incrementalrelayfee;
108109
QSpinBox *maxmempool;

src/qt/optionsmodel.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,16 @@ static QString CanonicalMempoolReplacement(const OptionsModel& model)
223223
assert(0);
224224
}
225225

226+
static QString CanonicalMempoolTRUC(const OptionsModel& model)
227+
{
228+
switch (model.node().mempool().m_opts.truc_policy) {
229+
case TRUCPolicy::Reject: return "reject";
230+
case TRUCPolicy::Accept: return "accept";
231+
case TRUCPolicy::Enforce: return "enforce";
232+
}
233+
assert(0);
234+
}
235+
226236
OptionsModel::OptionsModel(interfaces::Node& node, QObject *parent) :
227237
QAbstractListModel(parent), m_node{node}
228238
{
@@ -650,6 +660,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
650660
return gArgs.GetBoolArg("-peerblockfilters", DEFAULT_PEERBLOCKFILTERS);
651661
case mempoolreplacement:
652662
return CanonicalMempoolReplacement(*this);
663+
case mempooltruc:
664+
return CanonicalMempoolTRUC(*this);
653665
case maxorphantx:
654666
return qlonglong(gArgs.GetIntArg("-maxorphantx", DEFAULT_MAX_ORPHAN_TRANSACTIONS));
655667
case maxmempool:
@@ -1049,6 +1061,21 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
10491061
}
10501062
break;
10511063
}
1064+
case mempooltruc:
1065+
{
1066+
if (changed()) {
1067+
QString nv = value.toString();
1068+
if (nv == "reject") {
1069+
node().mempool().m_opts.truc_policy = TRUCPolicy::Reject;
1070+
} else if (nv == "accept") {
1071+
node().mempool().m_opts.truc_policy = TRUCPolicy::Accept;
1072+
} else if (nv == "enforce") {
1073+
node().mempool().m_opts.truc_policy = TRUCPolicy::Enforce;
1074+
}
1075+
node().updateRwSetting("mempooltruc", nv.toStdString());
1076+
}
1077+
break;
1078+
}
10521079
case maxorphantx:
10531080
{
10541081
if (changed()) {

src/qt/optionsmodel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class OptionsModel : public QAbstractListModel
8282
peerbloomfilters, // bool
8383
peerblockfilters, // bool
8484
mempoolreplacement,
85+
mempooltruc,
8586
maxorphantx,
8687
maxmempool,
8788
incrementalrelayfee,

0 commit comments

Comments
 (0)