aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-10-05 19:02:02 -0400
committerAndrew Chow <github@achow101.com>2023-10-05 19:08:19 -0400
commit54bdb6e0745934ad9ae6c77628f2382a83b9a1f0 (patch)
tree7644dd0f9bee6d342b5cc9999d0fb2a3a679d289 /src/rpc
parentcf553e3ab7b3827c9c1b91fcc50082856f761913 (diff)
parent5b878be742dbfcd232d949d2df1fff4743aec3d8 (diff)
downloadbitcoin-54bdb6e0745934ad9ae6c77628f2382a83b9a1f0.tar.xz
Merge bitcoin/bitcoin#27609: rpc: allow submitpackage to be called outside of regtest
5b878be742dbfcd232d949d2df1fff4743aec3d8 [doc] add release note for submitpackage (glozow) 7a9bb2a2a59ba49f80519c8435229abec2432486 [rpc] allow submitpackage to be called outside of regtest (glozow) 5b9087a9a7da2602485e85e0b163dc3cbd2daf31 [rpc] require package to be a tree in submitpackage (glozow) e32ba1599c599e75b1da3393f71f633de860505f [txpackages] IsChildWithParentsTree() (glozow) b4f28cc345ef9c5261c4a8d743654a44784c7802 [doc] parent pay for child in aggregate CheckFeeRate (glozow) Pull request description: Permit (restricted topology) submitpackage RPC outside of regtest. Suggested in https://github.com/bitcoin/bitcoin/pull/26933#issuecomment-1510851570 This RPC should be safe but still experimental - interface may change, not all features (e.g. package RBF) are implemented, etc. If a miner wants to expose this to people, they can effectively use "package relay" before the p2p changes are implemented. However, please note **this is not package relay**; transactions submitted this way will not relay to other nodes if the feerates are below their mempool min fee. Users should put this behind some kind of rate limit or permissions. ACKs for top commit: instagibbs: ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 achow101: ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 dergoegge: Code review ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 ajtowns: ACK 5b878be742dbfcd232d949d2df1fff4743aec3d8 ariard: Code Review ACK 5b878be742. Though didn’t manually test the PR. Tree-SHA512: 610365c0b2ffcccd55dedd1151879c82de1027e3319712bcb11d54f2467afaae4d05dca5f4b25f03354c80845fef538d3938b958174dda8b14c10670537a6524
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/mempool.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/rpc/mempool.cpp b/src/rpc/mempool.cpp
index 705608bd47..136969eb87 100644
--- a/src/rpc/mempool.cpp
+++ b/src/rpc/mempool.cpp
@@ -819,11 +819,11 @@ static RPCHelpMan savemempool()
static RPCHelpMan submitpackage()
{
return RPCHelpMan{"submitpackage",
- "Submit a package of raw transactions (serialized, hex-encoded) to local node (-regtest only).\n"
+ "Submit a package of raw transactions (serialized, hex-encoded) to local node.\n"
+ "The package must consist of a child with its parents, and none of the parents may depend on one another.\n"
"The package will be validated according to consensus and mempool policy rules. If all transactions pass, they will be accepted to mempool.\n"
"This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.\n"
- "Warning: until package relay is in use, successful submission does not mean the transaction will propagate to other nodes on the network.\n"
- "Currently, each transaction is broadcasted individually after submission, which means they must meet other nodes' feerate requirements alone.\n"
+ "Warning: successful submission does not mean the transactions will propagate throughout the network.\n"
,
{
{"package", RPCArg::Type::ARR, RPCArg::Optional::NO, "An array of raw transactions.",
@@ -862,9 +862,6 @@ static RPCHelpMan submitpackage()
},
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
{
- if (Params().GetChainType() != ChainType::REGTEST) {
- throw std::runtime_error("submitpackage is for regression testing (-regtest mode) only");
- }
const UniValue raw_transactions = request.params[0].get_array();
if (raw_transactions.size() < 1 || raw_transactions.size() > MAX_PACKAGE_COUNT) {
throw JSONRPCError(RPC_INVALID_PARAMETER,
@@ -881,6 +878,9 @@ static RPCHelpMan submitpackage()
}
txns.emplace_back(MakeTransactionRef(std::move(mtx)));
}
+ if (!IsChildWithParentsTree(txns)) {
+ throw JSONRPCTransactionError(TransactionError::INVALID_PACKAGE, "package topology disallowed. not child-with-parents or parents depend on each other.");
+ }
NodeContext& node = EnsureAnyNodeContext(request.context);
CTxMemPool& mempool = EnsureMemPool(node);
@@ -983,7 +983,7 @@ void RegisterMempoolRPCCommands(CRPCTable& t)
{"blockchain", &getrawmempool},
{"blockchain", &importmempool},
{"blockchain", &savemempool},
- {"hidden", &submitpackage},
+ {"rawtransactions", &submitpackage},
};
for (const auto& c : commands) {
t.appendCommand(c.name, &c);