Skip to content

Commit fee096b

Browse files
committed
RPC: Add support for ignore_rejects in testmempoolaccept
1 parent ce3e33c commit fee096b

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

src/rpc/client.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
128128
{ "sendrawtransaction", 3, "ignore_rejects" },
129129
{ "testmempoolaccept", 0, "rawtxs" },
130130
{ "testmempoolaccept", 1, "maxfeerate" },
131+
{ "testmempoolaccept", 2, "ignore_rejects" },
131132
{ "submitpackage", 0, "package" },
132133
{ "submitpackage", 1, "maxfeerate" },
133134
{ "submitpackage", 2, "maxburnamount" },

src/rpc/mempool.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ static RPCHelpMan testmempoolaccept()
133133
{"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
134134
"Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
135135
"/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
136+
{"ignore_rejects", RPCArg::Type::ARR, RPCArg::Default{UniValue::VARR}, "Rejection conditions to ignore, eg 'txn-mempool-conflict'",
137+
{
138+
{"reject_reason", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
139+
},
140+
},
136141
},
137142
RPCResult{
138143
RPCResult::Type::ARR, "", "The result of the mempool acceptance test for each raw transaction in the input array.\n"
@@ -179,6 +184,16 @@ static RPCHelpMan testmempoolaccept()
179184

180185
const CFeeRate max_raw_tx_fee_rate{ParseFeeRate(self.Arg<UniValue>("maxfeerate"))};
181186

187+
const UniValue* json_ign_rejs = &request.params[2];
188+
ignore_rejects_type ignore_rejects;
189+
if (!json_ign_rejs->isNull()) {
190+
for (size_t i = 0; i < json_ign_rejs->size(); ++i) {
191+
const UniValue& json_ign_rej = (*json_ign_rejs)[i];
192+
const std::string& ign_rej = json_ign_rej.get_str();
193+
ignore_rejects.insert(ign_rej);
194+
}
195+
}
196+
182197
std::vector<CTransactionRef> txns;
183198
txns.reserve(raw_transactions.size());
184199
for (const auto& rawtx : raw_transactions.getValues()) {
@@ -196,9 +211,9 @@ static RPCHelpMan testmempoolaccept()
196211
Chainstate& chainstate = chainman.ActiveChainstate();
197212
const PackageMempoolAcceptResult package_result = [&] {
198213
LOCK(::cs_main);
199-
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true, /*client_maxfeerate=*/{});
214+
if (txns.size() > 1) return ProcessNewPackage(chainstate, mempool, txns, /*test_accept=*/true, /*client_maxfeerate=*/{}, ignore_rejects);
200215
return PackageMempoolAcceptResult(txns[0]->GetWitnessHash(),
201-
chainman.ProcessTransaction(txns[0], /*test_accept=*/true));
216+
chainman.ProcessTransaction(txns[0], /*test_accept=*/true, ignore_rejects));
202217
}();
203218

204219
UniValue rpc_result(UniValue::VARR);
@@ -228,7 +243,8 @@ static RPCHelpMan testmempoolaccept()
228243
// Check that fee does not exceed maximum fee
229244
const int64_t virtual_size = tx_result.m_vsize.value();
230245
const CAmount max_raw_tx_fee = max_raw_tx_fee_rate.GetFee(virtual_size);
231-
if (max_raw_tx_fee && fee > max_raw_tx_fee) {
246+
if (max_raw_tx_fee && fee > max_raw_tx_fee &&
247+
0 == (ignore_rejects.count("absurdly-high-fee") + ignore_rejects.count("max-fee-exceeded"))) {
232248
result_inner.pushKV("allowed", false);
233249
result_inner.pushKV("reject-reason", "max-fee-exceeded");
234250
exit_early = true;

0 commit comments

Comments
 (0)