Skip to content

Commit 6d35627

Browse files
committed
RPC/mempool: Accept ignore_rejects in sendrawtransaction's 2nd & 3rd params for backward compatibility with Knots <25
1 parent adf4ddf commit 6d35627

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

src/rpc/mempool.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ static RPCHelpMan sendrawtransaction()
4949
{"hexstring", RPCArg::Type::STR_HEX, RPCArg::Optional::NO, "The hex string of the raw transaction"},
5050
{"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
5151
"Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
52-
"/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
52+
"/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate.",
53+
RPCArgOptions{.skip_type_check = true} // for ignore_rejects compatibility
54+
},
5355
{"maxburnamount", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_BURN_AMOUNT)},
5456
"Reject transactions with provably unspendable outputs (e.g. 'datacarrier' outputs that use the OP_RETURN opcode) greater than the specified value, expressed in " + CURRENCY_UNIT + ".\n"
5557
"If burning funds through unspendable outputs is desired, increase this value.\n"
56-
"This check is based on heuristics and does not guarantee spendability of outputs.\n"},
58+
"This check is based on heuristics and does not guarantee spendability of outputs.\n",
59+
RPCArgOptions{.skip_type_check = true} // for ignore_rejects compatibility
60+
},
5761
{"ignore_rejects", RPCArg::Type::ARR, RPCArg::Default{UniValue::VARR}, "Rejection conditions to ignore, eg 'txn-mempool-conflict'",
5862
{
5963
{"reject_reason", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
@@ -75,7 +79,24 @@ static RPCHelpMan sendrawtransaction()
7579
},
7680
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
7781
{
78-
const CAmount max_burn_amount = request.params[2].isNull() ? 0 : AmountFromValue(request.params[2]);
82+
CFeeRate max_raw_tx_fee_rate{DEFAULT_MAX_RAW_TX_FEE_RATE};
83+
CAmount max_burn_amount{0};
84+
const UniValue* json_ign_rejs = &request.params[3];
85+
86+
if (request.params[1].isArray() && request.params[2].isNull() && request.params[3].isNull()) {
87+
// ignore_rejects used to occupy this position (v0.12.0.knots20160226.rc1-v0.17.1.knots20181229)
88+
json_ign_rejs = &request.params[1];
89+
} else {
90+
if (!request.params[1].isNull()) {
91+
max_raw_tx_fee_rate = ParseFeeRate(self.Arg<UniValue>("maxfeerate"));
92+
}
93+
if (request.params[2].isArray() && request.params[3].isNull()) {
94+
// ignore_rejects used to occupy this position (v0.18.0.knots20190502-v23.0.knots20220529)
95+
json_ign_rejs = &request.params[2];
96+
} else if (!request.params[2].isNull()) {
97+
max_burn_amount = AmountFromValue(request.params[2]);
98+
}
99+
}
79100

80101
CMutableTransaction mtx;
81102
if (!DecodeHexTx(mtx, request.params[0].get_str())) {
@@ -90,10 +111,6 @@ static RPCHelpMan sendrawtransaction()
90111

91112
CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
92113

93-
const UniValue* json_ign_rejs = &request.params[3];
94-
95-
const CFeeRate max_raw_tx_fee_rate{ParseFeeRate(self.Arg<UniValue>("maxfeerate"))};
96-
97114
ignore_rejects_type ignore_rejects;
98115
if (!json_ign_rejs->isNull()) {
99116
for (size_t i = 0; i < json_ign_rejs->size(); ++i) {

0 commit comments

Comments
 (0)