Skip to content

Commit 5b9087a

Browse files
committed
[rpc] require package to be a tree in submitpackage
1 parent e32ba15 commit 5b9087a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/rpc/mempool.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ static RPCHelpMan submitpackage()
820820
{
821821
return RPCHelpMan{"submitpackage",
822822
"Submit a package of raw transactions (serialized, hex-encoded) to local node (-regtest only).\n"
823+
"The package must consist of a child with its parents, and none of the parents may depend on one another.\n"
823824
"The package will be validated according to consensus and mempool policy rules. If all transactions pass, they will be accepted to mempool.\n"
824825
"This RPC is experimental and the interface may be unstable. Refer to doc/policy/packages.md for documentation on package policies.\n"
825826
"Warning: until package relay is in use, successful submission does not mean the transaction will propagate to other nodes on the network.\n"
@@ -881,6 +882,9 @@ static RPCHelpMan submitpackage()
881882
}
882883
txns.emplace_back(MakeTransactionRef(std::move(mtx)));
883884
}
885+
if (!IsChildWithParentsTree(txns)) {
886+
throw JSONRPCTransactionError(TransactionError::INVALID_PACKAGE, "package topology disallowed. not child-with-parents or parents depend on each other.");
887+
}
884888

885889
NodeContext& node = EnsureAnyNodeContext(request.context);
886890
CTxMemPool& mempool = EnsureMemPool(node);

test/functional/rpc_packages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ def test_submitpackage(self):
335335
self.log.info("Submitpackage only allows packages of 1 child with its parents")
336336
# Chain of 3 transactions has too many generations
337337
chain_hex = [t["hex"] for t in self.wallet.create_self_transfer_chain(chain_length=25)]
338-
assert_raises_rpc_error(-25, "not-child-with-parents", node.submitpackage, chain_hex)
338+
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, chain_hex)
339339

340340

341341
if __name__ == "__main__":

0 commit comments

Comments
 (0)