RPC: sendrawtransaction: Replace boolean allowhighfees with an Array of rejections to ignore (in a backward compatible manner)

This commit is contained in:
Luke Dashjr 2023-08-01 18:27:49 +00:00
parent 99f70a4af3
commit b4f6e44d2c
2 changed files with 17 additions and 1 deletions

View File

@ -119,6 +119,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
{ "signrawtransactionwithwallet", 1, "prevtxs" }, { "signrawtransactionwithwallet", 1, "prevtxs" },
{ "sendrawtransaction", 1, "maxfeerate" }, { "sendrawtransaction", 1, "maxfeerate" },
{ "sendrawtransaction", 2, "maxburnamount" }, { "sendrawtransaction", 2, "maxburnamount" },
{ "sendrawtransaction", 3, "ignore_rejects" },
{ "testmempoolaccept", 0, "rawtxs" }, { "testmempoolaccept", 0, "rawtxs" },
{ "testmempoolaccept", 1, "maxfeerate" }, { "testmempoolaccept", 1, "maxfeerate" },
{ "submitpackage", 0, "package" }, { "submitpackage", 0, "package" },

View File

@ -50,6 +50,11 @@ static RPCHelpMan sendrawtransaction()
"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" "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"
"If burning funds through unspendable outputs is desired, increase this value.\n" "If burning funds through unspendable outputs is desired, increase this value.\n"
"This check is based on heuristics and does not guarantee spendability of outputs.\n"}, "This check is based on heuristics and does not guarantee spendability of outputs.\n"},
{"ignore_rejects", RPCArg::Type::ARR, RPCArg::Default{UniValue::VARR}, "Rejection conditions to ignore, eg 'txn-mempool-conflict'",
{
{"reject_reason", RPCArg::Type::STR, RPCArg::Optional::OMITTED, ""},
},
},
}, },
RPCResult{ RPCResult{
RPCResult::Type::STR_HEX, "", "The transaction hash in hex" RPCResult::Type::STR_HEX, "", "The transaction hash in hex"
@ -81,15 +86,25 @@ static RPCHelpMan sendrawtransaction()
CTransactionRef tx(MakeTransactionRef(std::move(mtx))); CTransactionRef tx(MakeTransactionRef(std::move(mtx)));
const UniValue* json_ign_rejs = &request.params[3];
const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ? const CFeeRate max_raw_tx_fee_rate = request.params[1].isNull() ?
DEFAULT_MAX_RAW_TX_FEE_RATE : DEFAULT_MAX_RAW_TX_FEE_RATE :
CFeeRate(AmountFromValue(request.params[1])); CFeeRate(AmountFromValue(request.params[1]));
ignore_rejects_type ignore_rejects;
if (!json_ign_rejs->isNull()) {
for (size_t i = 0; i < json_ign_rejs->size(); ++i) {
const UniValue& json_ign_rej = (*json_ign_rejs)[i];
ignore_rejects.insert(json_ign_rej.get_str());
}
}
std::string err_string; std::string err_string;
AssertLockNotHeld(cs_main); AssertLockNotHeld(cs_main);
NodeContext& node = EnsureAnyNodeContext(request.context); NodeContext& node = EnsureAnyNodeContext(request.context);
const TransactionError err = BroadcastTransaction(node, tx, err_string, max_raw_tx_fee_rate, /*relay=*/true, /*wait_callback=*/true); const TransactionError err = BroadcastTransaction(node, tx, err_string, max_raw_tx_fee_rate, /*relay=*/true, /*wait_callback=*/true, ignore_rejects);
if (TransactionError::OK != err) { if (TransactionError::OK != err) {
throw JSONRPCTransactionError(err, err_string); throw JSONRPCTransactionError(err, err_string);
} }