GUI/Options: Configure datacarriercost using settings

This commit is contained in:
Luke Dashjr 2025-02-04 01:31:27 +00:00
parent 60dea73864
commit 3e1b343fef
4 changed files with 30 additions and 0 deletions

View File

@ -32,6 +32,7 @@
#include <QBoxLayout> #include <QBoxLayout>
#include <QDataWidgetMapper> #include <QDataWidgetMapper>
#include <QDir> #include <QDir>
#include <QDoubleSpinBox>
#include <QFontDialog> #include <QFontDialog>
#include <QGroupBox> #include <QGroupBox>
#include <QHBoxLayout> #include <QHBoxLayout>
@ -312,6 +313,20 @@ OptionsDialog::OptionsDialog(QWidget* parent, bool enableWallet)
datacarriersize->setToolTip(tr("While Bitcoin itself does not support attaching arbitrary data to transactions, despite that various methods for disguising it have been devised over the years. Since it is sometimes impractical to detect small spam disguised as ordinary transactions, it is sometimes considered beneficial to tolerate certain kinds of less harmful data attachments.")); datacarriersize->setToolTip(tr("While Bitcoin itself does not support attaching arbitrary data to transactions, despite that various methods for disguising it have been devised over the years. Since it is sometimes impractical to detect small spam disguised as ordinary transactions, it is sometimes considered beneficial to tolerate certain kinds of less harmful data attachments."));
CreateOptionUI(verticalLayout_Spamfiltering, datacarriersize, tr("Ignore transactions with additional data larger than %s bytes.")); CreateOptionUI(verticalLayout_Spamfiltering, datacarriersize, tr("Ignore transactions with additional data larger than %s bytes."));
datacarriercost = new QDoubleSpinBox(groupBox_Spamfiltering);
datacarriercost->setDecimals(2);
datacarriercost->setStepType(QAbstractSpinBox::DefaultStepType);
datacarriercost->setSingleStep(0.25);
datacarriercost->setMinimum(0.25);
datacarriercost->setMaximum(MAX_BLOCK_SERIALIZED_SIZE);
datacarriercost->setToolTip(tr("As an alternative to, or in addition to, limiting the size of disguised data, you can also configure how it is accounted for in comparison to legitimate transaction data. For example, 1 vbyte per actual byte would count it as equivalent to ordinary transaction data; 0.25 vB/B would allow it to benefit from the so-called \"segwit discount\"; or 2 vB/B would establish a bias toward legitimate transactions."));
CreateOptionUI(verticalLayout_Spamfiltering, datacarriercost, tr("Weigh embedded data as %s virtual bytes per actual byte."));
connect(datacarriercost, QOverload<double>::of(&QDoubleSpinBox::valueChanged), [&](double d){
const double w = d * 4;
const double wf = floor(w);
if (w != wf) datacarriercost->setValue(wf / 4);
});
dustrelayfee = new BitcoinAmountField(groupBox_Spamfiltering); dustrelayfee = new BitcoinAmountField(groupBox_Spamfiltering);
CreateOptionUI(verticalLayout_Spamfiltering, dustrelayfee, tr("Ignore transactions with values that would cost more to spend at a fee rate of %s per kvB.")); CreateOptionUI(verticalLayout_Spamfiltering, dustrelayfee, tr("Ignore transactions with values that would cost more to spend at a fee rate of %s per kvB."));
@ -612,6 +627,7 @@ void OptionsDialog::setMapper()
mapper->addMapping(limitdescendantcount, OptionsModel::limitdescendantcount); mapper->addMapping(limitdescendantcount, OptionsModel::limitdescendantcount);
mapper->addMapping(limitdescendantsize, OptionsModel::limitdescendantsize); mapper->addMapping(limitdescendantsize, OptionsModel::limitdescendantsize);
mapper->addMapping(rejectbaremultisig, OptionsModel::rejectbaremultisig); mapper->addMapping(rejectbaremultisig, OptionsModel::rejectbaremultisig);
mapper->addMapping(datacarriercost, OptionsModel::datacarriercost);
mapper->addMapping(datacarriersize, OptionsModel::datacarriersize); mapper->addMapping(datacarriersize, OptionsModel::datacarriersize);
mapper->addMapping(dustrelayfee, OptionsModel::dustrelayfee); mapper->addMapping(dustrelayfee, OptionsModel::dustrelayfee);

View File

@ -17,6 +17,7 @@ QT_BEGIN_NAMESPACE
class QBoxLayout; class QBoxLayout;
class QCheckBox; class QCheckBox;
class QDataWidgetMapper; class QDataWidgetMapper;
class QDoubleSpinBox;
class QSpinBox; class QSpinBox;
class QString; class QString;
class QValueComboBox; class QValueComboBox;
@ -115,6 +116,7 @@ private:
QSpinBox *limitdescendantsize; QSpinBox *limitdescendantsize;
QCheckBox *rejectbaremultisig; QCheckBox *rejectbaremultisig;
QSpinBox *datacarriersize; QSpinBox *datacarriersize;
QDoubleSpinBox *datacarriercost;
BitcoinAmountField *dustrelayfee; BitcoinAmountField *dustrelayfee;
BitcoinAmountField *blockmintxfee; BitcoinAmountField *blockmintxfee;

View File

@ -12,6 +12,7 @@
#include <chainparams.h> #include <chainparams.h>
#include <common/args.h> #include <common/args.h>
#include <consensus/consensus.h>
#include <index/blockfilterindex.h> #include <index/blockfilterindex.h>
#include <interfaces/node.h> #include <interfaces/node.h>
#include <kernel/mempool_options.h> // for DEFAULT_MAX_MEMPOOL_SIZE_MB, DEFAULT_MEMPOOL_EXPIRY_HOURS #include <kernel/mempool_options.h> // for DEFAULT_MAX_MEMPOOL_SIZE_MB, DEFAULT_MEMPOOL_EXPIRY_HOURS
@ -75,6 +76,7 @@ static const char* SettingName(OptionsModel::OptionID option)
case OptionsModel::maxuploadtarget: return "maxuploadtarget"; case OptionsModel::maxuploadtarget: return "maxuploadtarget";
case OptionsModel::peerbloomfilters: return "peerbloomfilters"; case OptionsModel::peerbloomfilters: return "peerbloomfilters";
case OptionsModel::peerblockfilters: return "peerblockfilters"; case OptionsModel::peerblockfilters: return "peerblockfilters";
case OptionsModel::datacarriercost: return "datacarriercost";
default: throw std::logic_error(strprintf("GUI option %i has no corresponding node setting.", option)); default: throw std::logic_error(strprintf("GUI option %i has no corresponding node setting.", option));
} }
} }
@ -673,6 +675,8 @@ QVariant OptionsModel::getOption(OptionID option, const std::string& suffix) con
return qlonglong(node().mempool().m_opts.limits.descendant_size_vbytes / 1'000); return qlonglong(node().mempool().m_opts.limits.descendant_size_vbytes / 1'000);
case rejectbaremultisig: case rejectbaremultisig:
return !node().mempool().m_opts.permit_bare_multisig; return !node().mempool().m_opts.permit_bare_multisig;
case datacarriercost:
return double(::g_weight_per_data_byte) / WITNESS_SCALE_FACTOR;
case datacarriersize: case datacarriersize:
return qlonglong(node().mempool().m_opts.max_datacarrier_bytes.value_or(0)); return qlonglong(node().mempool().m_opts.max_datacarrier_bytes.value_or(0));
case dustrelayfee: case dustrelayfee:
@ -1171,6 +1175,13 @@ bool OptionsModel::setOption(OptionID option, const QVariant& value, const std::
gArgs.ModifyRWConfigFile("permitbaremultisig", strprintf("%d", fNewValue)); gArgs.ModifyRWConfigFile("permitbaremultisig", strprintf("%d", fNewValue));
} }
break; break;
case datacarriercost:
if (changed()) {
const double nNewSize = value.toDouble();
update(nNewSize);
::g_weight_per_data_byte = nNewSize * WITNESS_SCALE_FACTOR;
}
break;
case datacarriersize: case datacarriersize:
if (changed()) { if (changed()) {
const int nNewSize = value.toInt(); const int nNewSize = value.toInt();

View File

@ -96,6 +96,7 @@ public:
limitdescendantcount, limitdescendantcount,
limitdescendantsize, limitdescendantsize,
rejectbaremultisig, // bool rejectbaremultisig, // bool
datacarriercost, // double
datacarriersize, datacarriersize,
dustrelayfee, dustrelayfee,
blockmintxfee, blockmintxfee,