rpc: Disallow non-matching transactions in combinerawtransaction #31091

pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:2024-10-non_matching_combineraw changing 2 files +14 −0
  1. instagibbs commented at 10:06 am on October 15, 2024: member
    Resolves #25980 by disallowing obviously broken usage. If txid doesn’t match, we can’t sensibly combine it.
  2. DrahtBot commented at 10:06 am on October 15, 2024: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  3. DrahtBot added the label RPC/REST/ZMQ on Oct 15, 2024
  4. rpc: Disallow non-matching transactions in combinerawtransaction 601478629d
  5. instagibbs force-pushed on Oct 15, 2024
  6. in src/rpc/rawtransaction.cpp:661 in 601478629d
    656     for (unsigned int idx = 0; idx < txs.size(); idx++) {
    657         if (!DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
    658             throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d. Make sure the tx has at least one input.", idx));
    659         }
    660+        if (txid.has_value() && txid.value() != txVariants[idx].GetHash()) {
    661+            throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Transactions to be combine do not match."));
    


    maflcko commented at 10:43 am on October 15, 2024:
    0            throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Transactions to be combined do not match."));
    

    nit?

  7. instagibbs commented at 10:44 am on October 15, 2024: member
    nevermind, pre-segwit is lame, im outta here
  8. instagibbs closed this on Oct 15, 2024

  9. in src/rpc/rawtransaction.cpp:660 in 601478629d
    651@@ -652,10 +652,16 @@ static RPCHelpMan combinerawtransaction()
    652     UniValue txs = request.params[0].get_array();
    653     std::vector<CMutableTransaction> txVariants(txs.size());
    654 
    655+    std::optional<Txid> txid;
    656     for (unsigned int idx = 0; idx < txs.size(); idx++) {
    657         if (!DecodeHexTx(txVariants[idx], txs[idx].get_str())) {
    658             throw JSONRPCError(RPC_DESERIALIZATION_ERROR, strprintf("TX decode failed for tx %d. Make sure the tx has at least one input.", idx));
    659         }
    660+        if (txid.has_value() && txid.value() != txVariants[idx].GetHash()) {
    


    achow101 commented at 10:48 am on October 15, 2024:
    For txs with pre-segwit and nested segwit inputs, txids will not match because the scriptSigs will be different. This check is actually more involved as the transactions need to have scriptSigs stripped.
  10. bitcoin locked this on Oct 15, 2025

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-10-23 03:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me