MCPcopy Create free account
hub / github.com/ElementsProject/elements / testmempoolaccept

Function testmempoolaccept

src/rpc/rawtransaction.cpp:995–1136  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993}
994
995static RPCHelpMan testmempoolaccept()
996{
997 return RPCHelpMan{"testmempoolaccept",
998 "\nReturns result of mempool acceptance tests indicating if raw transaction(s) (serialized, hex-encoded) would be accepted by mempool.\n"
999 "\nIf multiple transactions are passed in, parents must come before children and package policies apply: the transactions cannot conflict with any mempool transactions or each other.\n"
1000 "\nIf one transaction fails, other transactions may not be fully validated (the 'allowed' key will be blank).\n"
1001 "\nThe maximum number of transactions allowed is " + ToString(MAX_PACKAGE_COUNT) + ".\n"
1002 "\nThis checks if transactions violate the consensus or policy rules.\n"
1003 "\nSee sendrawtransaction call.\n",
1004 {
1005 {"rawtxs", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of hex strings of raw transactions.",
1006 {
1007 {"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
1008 },
1009 },
1010 {"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
1011 "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT + "/kvB\n"},
1012 },
1013 RPCResult{
1014 RPCResult::Type::ARR, "", "The result of the mempool acceptance test for each raw transaction in the input array.\n"
1015 "Returns results for each transaction in the same order they were passed in.\n"
1016 "Transactions that cannot be fully validated due to failures in other transactions will not contain an 'allowed' result.\n",
1017 {
1018 {RPCResult::Type::OBJ, "", "",
1019 {
1020 {RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
1021 {RPCResult::Type::STR_HEX, "wtxid", "The transaction witness hash in hex"},
1022 {RPCResult::Type::STR, "package-error", /*optional=*/true, "Package validation error, if any (only possible if rawtxs had more than 1 transaction)."},
1023 {RPCResult::Type::BOOL, "allowed", /*optional=*/true, "Whether this tx would be accepted to the mempool and pass client-specified maxfeerate. "
1024 "If not present, the tx was not fully validated due to a failure in another tx in the list."},
1025 {RPCResult::Type::NUM, "vsize", /*optional=*/true, "Virtual transaction size as defined in BIP 141. This is different from actual serialized size for witness transactions as witness data is discounted (only present when 'allowed' is true)"},
1026 {RPCResult::Type::OBJ, "fees", /*optional=*/true, "Transaction fees (only present if 'allowed' is true)",
1027 {
1028 {RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
1029 }},
1030 {RPCResult::Type::STR, "reject-reason", /*optional=*/true, "Rejection string (only present when 'allowed' is false)"},
1031 }},
1032 }
1033 },
1034 RPCExamples{
1035 "\nCreate a transaction\n"
1036 + HelpExampleCli("createrawtransaction", "\"[{\\\"txid\\\" : \\\"mytxid\\\",\\\"vout\\\":0}]\" \"{\\\"myaddress\\\":0.01}\"") +
1037 "Sign the transaction, and get back the hex\n"
1038 + HelpExampleCli("signrawtransactionwithwallet", "\"myhex\"") +
1039 "\nTest acceptance of the transaction (signed hex)\n"
1040 + HelpExampleCli("testmempoolaccept", R"('["signedhex"]')") +
1041 "\nAs a JSON-RPC call\n"
1042 + HelpExampleRpc("testmempoolaccept", "[\"signedhex\"]")
1043 },
1044 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1045{
1046 RPCTypeCheck(request.params, {
1047 UniValue::VARR,
1048 UniValueType(), // VNUM or VSTR, checked inside AmountFromValue()
1049 });
1050 const UniValue raw_transactions = request.params[0].get_array();
1051 if (raw_transactions.size() < 1 || raw_transactions.size() > MAX_PACKAGE_COUNT) {
1052 throw JSONRPCError(RPC_INVALID_PARAMETER,

Callers

nothing calls this directly

Calls 15

FormatMoneyFunction · 0.85
HelpExampleCliFunction · 0.85
HelpExampleRpcFunction · 0.85
RPCTypeCheckFunction · 0.85
UniValueTypeClass · 0.85
JSONRPCErrorFunction · 0.85
DecodeHexTxFunction · 0.85
ProcessNewPackageFunction · 0.85
ValueFromAmountFunction · 0.85
GetFeePerKMethod · 0.80
emplace_backMethod · 0.80

Tested by

no test coverage detected