Skip to content

Commit 39ec130

Browse files
committed
Merge rejecttokens-28+knots
2 parents 48c848e + 6459647 commit 39ec130

File tree

6 files changed

+23
-0
lines changed

6 files changed

+23
-0
lines changed

src/init.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,10 @@ void SetupServerArgs(ArgsManager& argsman)
699699
OptionsCategory::NODE_RELAY);
700700
argsman.AddArg("-minrelaytxfee=<amt>", strprintf("Fees (in %s/kvB) smaller than this are considered zero fee for relaying, mining and transaction creation (default: %s)",
701701
CURRENCY_UNIT, FormatMoney(DEFAULT_MIN_RELAY_TX_FEE)), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
702+
argsman.AddArg("-rejecttokens",
703+
strprintf("Refuse to relay or mine transactions involving non-bitcoin tokens (default: %u)",
704+
DEFAULT_REJECT_TOKENS),
705+
ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
702706
argsman.AddArg("-spkreuse=<policy>", strprintf("Either \"allow\" to relay/mine transactions reusing addresses or other pubkey scripts, or \"conflict\" to treat them as exclusive prior to being mined (default: %s)", DEFAULT_SPKREUSE), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
703707
argsman.AddArg("-whitelistforcerelay", strprintf("Add 'forcerelay' permission to whitelisted peers with default permissions. This will relay transactions even if the transactions were already in the mempool. (default: %d)", DEFAULT_WHITELISTFORCERELAY), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);
704708
argsman.AddArg("-whitelistrelay", strprintf("Add 'relay' permission to whitelisted peers with default permissions. This will accept relayed transactions even when not relaying transactions (default: %d)", DEFAULT_WHITELISTRELAY), ArgsManager::ALLOW_ANY, OptionsCategory::NODE_RELAY);

src/kernel/mempool_options.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct MemPoolOptions {
7373
bool datacarrier_fullcount{DEFAULT_DATACARRIER_FULLCOUNT};
7474
bool permit_bare_pubkey{DEFAULT_PERMIT_BAREPUBKEY};
7575
bool permit_bare_multisig{DEFAULT_PERMIT_BAREMULTISIG};
76+
bool reject_tokens{DEFAULT_REJECT_TOKENS};
7677
bool accept_non_std_datacarrier{DEFAULT_ACCEPT_NON_STD_DATACARRIER};
7778
bool require_standard{true};
7879
RBFPolicy rbf_policy{DEFAULT_MEMPOOL_RBF_POLICY};

src/node/mempool_args.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ util::Result<void> ApplyArgsManOptions(const ArgsManager& argsman, const CChainP
146146

147147
mempool_opts.permit_bare_multisig = argsman.GetBoolArg("-permitbaremultisig", DEFAULT_PERMIT_BAREMULTISIG);
148148

149+
mempool_opts.reject_tokens = argsman.GetBoolArg("-rejecttokens", DEFAULT_REJECT_TOKENS);
150+
149151
if (argsman.GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER)) {
150152
mempool_opts.max_datacarrier_bytes = argsman.GetIntArg("-datacarriersize", MAX_OP_RETURN_RELAY);
151153
} else {

src/policy/policy.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ bool IsStandardTx(const CTransaction& tx, const kernel::MemPoolOptions& opts, st
159159
}
160160

161161
if (whichType == TxoutType::NULL_DATA) {
162+
if (txout.scriptPubKey.size() > 2 && txout.scriptPubKey[1] == OP_13 && opts.reject_tokens) {
163+
MaybeReject("tokens-runes");
164+
}
162165
nDataOut++;
163166
continue;
164167
}

src/policy/policy.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
5050
static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP_STRICT{20};
5151
/** Default for -datacarriercost (multiplied by WITNESS_SCALE_FACTOR) */
5252
static constexpr unsigned int DEFAULT_WEIGHT_PER_DATA_BYTE{1};
53+
/** Default for -rejecttokens */
54+
static constexpr bool DEFAULT_REJECT_TOKENS{false};
5355
/** Default for -permitbarepubkey */
5456
static constexpr bool DEFAULT_PERMIT_BAREPUBKEY{true};
5557
/** Default for -permitbaremultisig */

src/test/transaction_tests.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,17 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
850850
t.vout[0].scriptPubKey = CScript() << OP_1;
851851
CheckIsNotStandard(t, "scriptpubkey");
852852

853+
// Test rejecttokens
854+
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_13 << OP_FALSE;
855+
g_mempool_opts.reject_tokens = false;
856+
CheckIsStandard(t);
857+
g_mempool_opts.reject_tokens = true;
858+
CheckIsNotStandard(t, "tokens-runes");
859+
// At least one data push is needed after OP_13 to match
860+
t.vout[0].scriptPubKey = CScript() << OP_RETURN << OP_13;
861+
CheckIsStandard(t);
862+
g_mempool_opts.reject_tokens = false;
863+
853864
// MAX_OP_RETURN_RELAY-byte TxoutType::NULL_DATA (standard)
854865
t.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef3804678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38");
855866
BOOST_CHECK_EQUAL(MAX_OP_RETURN_RELAY, t.vout[0].scriptPubKey.size());

0 commit comments

Comments
 (0)