MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / submitpackage

Function submitpackage

src/rpc/mempool.cpp:1326–1538  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1324}
1325
1326static RPCMethod submitpackage()
1327{
1328 return RPCMethod{"submitpackage",
1329 "Submit a package of raw transactions (serialized, hex-encoded) to local node.\n"
1330 "The package will be validated according to consensus and mempool policy rules. If any transaction passes, it will be accepted to mempool.\n"
1331 "This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.\n"
1332 "Warning: successful submission does not mean the transactions will propagate throughout the network.\n"
1333 ,
1334 {
1335 {"package", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of raw transactions.\n"
1336 "The package must consist of a transaction with (some, all, or none of) its unconfirmed parents. A single transaction is permitted.\n"
1337 "None of the parents may depend on each other. Parents that are already in mempool do not need to be present in the package.\n"
1338 "The package must be topologically sorted, with the child being the last element in the array if there are multiple elements.",
1339 {
1340 {"rawtx", RPCArg::Type::STR_HEX, RPCArg::Optional::OMITTED, ""},
1341 },
1342 },
1343 {"maxfeerate", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_RAW_TX_FEE_RATE.GetFeePerK())},
1344 "Reject transactions whose fee rate is higher than the specified value, expressed in " + CURRENCY_UNIT +
1345 "/kvB.\nFee rates larger than 1BTC/kvB are rejected.\nSet to 0 to accept any fee rate."},
1346 {"maxburnamount", RPCArg::Type::AMOUNT, RPCArg::Default{FormatMoney(DEFAULT_MAX_BURN_AMOUNT)},
1347 "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"
1348 "If burning funds through unspendable outputs is desired, increase this value.\n"
1349 "This check is based on heuristics and does not guarantee spendability of outputs.\n"
1350 },
1351 },
1352 RPCResult{
1353 RPCResult::Type::OBJ, "", "",
1354 {
1355 {RPCResult::Type::STR, "package_msg", "The transaction package result message. \"success\" indicates all transactions were accepted into or are already in the mempool."},
1356 {RPCResult::Type::OBJ_DYN, "tx-results", "The transaction results keyed by wtxid. An entry is returned for every submitted wtxid.",
1357 {
1358 {RPCResult::Type::OBJ, "wtxid", "transaction wtxid", {
1359 {RPCResult::Type::STR_HEX, "txid", "The transaction hash in hex"},
1360 {RPCResult::Type::STR_HEX, "other-wtxid", /*optional=*/true, "The wtxid of a different transaction with the same txid but different witness found in the mempool. This means the submitted transaction was ignored."},
1361 {RPCResult::Type::NUM, "vsize", /*optional=*/true, "Sigops-adjusted virtual transaction size."},
1362 {RPCResult::Type::OBJ, "fees", /*optional=*/true, "Transaction fees", {
1363 {RPCResult::Type::STR_AMOUNT, "base", "transaction fee in " + CURRENCY_UNIT},
1364 {RPCResult::Type::STR_AMOUNT, "effective-feerate", /*optional=*/true, "if the transaction was not already in the mempool, the effective feerate in " + CURRENCY_UNIT + " per KvB. For example, the package feerate and/or feerate with modified fees from prioritisetransaction."},
1365 {RPCResult::Type::ARR, "effective-includes", /*optional=*/true, "if effective-feerate is provided, the wtxids of the transactions whose fees and vsizes are included in effective-feerate.",
1366 {{RPCResult::Type::STR_HEX, "", "transaction wtxid in hex"},
1367 }},
1368 }},
1369 {RPCResult::Type::STR, "error", /*optional=*/true, "Error string if rejected from mempool, or \"package-not-validated\" when the package aborts before any per-tx processing."},
1370 }}
1371 }},
1372 {RPCResult::Type::ARR, "replaced-transactions", /*optional=*/true, "List of txids of replaced transactions",
1373 {
1374 {RPCResult::Type::STR_HEX, "", "The transaction id"},
1375 }},
1376 },
1377 },
1378 RPCExamples{
1379 HelpExampleRpc("submitpackage", R"(["raw-parent-tx-1", "raw-parent-tx-2", "raw-child-tx"])") +
1380 HelpExampleCli("submitpackage", R"('["raw-tx-without-unconfirmed-parents"]')")
1381 },
1382 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
1383 {

Callers

nothing calls this directly

Calls 15

FormatMoneyFunction · 0.85
HelpExampleRpcFunction · 0.85
HelpExampleCliFunction · 0.85
JSONRPCErrorFunction · 0.85
ParseFeeRateFunction · 0.85
DecodeHexTxFunction · 0.85
JSONRPCTransactionErrorFunction · 0.85
MakeTransactionRefFunction · 0.85
IsChildWithParentsTreeFunction · 0.85
ProcessNewPackageFunction · 0.85
BroadcastTransactionFunction · 0.85
ValueFromAmountFunction · 0.85

Tested by

no test coverage detected