mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-10 10:52:31 -05:00
[rpc] require package to be a tree in submitpackage
This commit is contained in:
parent
e32ba1599c
commit
5b9087a9a7
2 changed files with 5 additions and 1 deletions
|
@ -820,6 +820,7 @@ static RPCHelpMan submitpackage()
|
||||||
{
|
{
|
||||||
return 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 (-regtest only).\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"
|
"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"
|
"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"
|
"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()
|
||||||
}
|
}
|
||||||
txns.emplace_back(MakeTransactionRef(std::move(mtx)));
|
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);
|
NodeContext& node = EnsureAnyNodeContext(request.context);
|
||||||
CTxMemPool& mempool = EnsureMemPool(node);
|
CTxMemPool& mempool = EnsureMemPool(node);
|
||||||
|
|
|
@ -335,7 +335,7 @@ class RPCPackagesTest(BitcoinTestFramework):
|
||||||
self.log.info("Submitpackage only allows packages of 1 child with its parents")
|
self.log.info("Submitpackage only allows packages of 1 child with its parents")
|
||||||
# Chain of 3 transactions has too many generations
|
# Chain of 3 transactions has too many generations
|
||||||
chain_hex = [t["hex"] for t in self.wallet.create_self_transfer_chain(chain_length=25)]
|
chain_hex = [t["hex"] for t in self.wallet.create_self_transfer_chain(chain_length=25)]
|
||||||
assert_raises_rpc_error(-25, "not-child-with-parents", node.submitpackage, chain_hex)
|
assert_raises_rpc_error(-25, "package topology disallowed", node.submitpackage, chain_hex)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Add table
Reference in a new issue