Fix #25980: Validate transactions in combinerawtransaction #33361

pull jalateras wants to merge 1 commits into bitcoin:master from jalateras:fix-combinerawtransaction-25980 changing 2 files +83 −0
  1. jalateras commented at 7:14 AM on September 11, 2025: none

    Summary

    This PR fixes issue #25980 where combinerawtransaction would silently accept unrelated transactions and only use the first one, ignoring the rest.

    Problem

    When passed two or more unrelated transactions (transactions with different inputs/outputs), combinerawtransaction would:

    • Take the first transaction as the base
    • Silently ignore the unrelated parts of subsequent transactions
    • Only merge signatures for matching inputs

    This behavior was confusing and could lead to unexpected results where users think they're combining transactions but actually only getting the first one back.

    Solution

    Added validation to ensure all transactions being combined are actually the same transaction (with potentially different signatures). The validation checks that all transactions have:

    • The same number of inputs and outputs
    • Identical input outpoints and sequences
    • Identical output values and scripts
    • The same version and locktime

    If any transaction differs from the first, the RPC now throws a descriptive error indicating which transaction is unrelated.

    Testing

    Added test coverage in test/functional/rpc_rawtransaction.py that verifies:

    1. Unrelated transactions are properly rejected with an appropriate error message
    2. Related transactions (same transaction structure) can still be combined successfully

    Fixes #25980

  2. rpc: Add validation to combinerawtransaction for unrelated transactions
    Fixes #25980
    
    Previously, combinerawtransaction would silently accept unrelated
    transactions and only use the first one, ignoring the rest. This was
    confusing and could lead to unexpected behavior.
    
    This commit adds validation to ensure all provided transactions:
    - Have the same number of inputs and outputs
    - Reference the same input outpoints
    - Have identical outputs (same values and scripts)
    - Have the same version and locktime
    
    If any transaction differs from the first, an RPC error is thrown with
    a descriptive message indicating which transaction is unrelated.
    
    Also adds test coverage in rpc_rawtransaction.py to verify that:
    1. Unrelated transactions are properly rejected
    2. Related transactions can still be combined successfully
    111010eefc
  3. DrahtBot commented at 7:14 AM on September 11, 2025: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33361.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. achow101 commented at 8:46 PM on September 17, 2025: member

    #31298 also fixes this issue.

    CI is failing because you've added a test that uses wallet behavior to a non-wallet test.

  5. theStack commented at 1:54 PM on September 24, 2025: contributor

    I'm currently favoring the fix in #31298, as it avoids comparing all the involved transaction fields (and input/output counts) by using the txid instead and is thus much simpler. One potential advantage of the approach of this PR though is that the error messages are more detailed, pointing out where exactly the txs differ -- personally I think just pointing out that the txs are not compatible is sufficient.

  6. maflcko commented at 2:07 PM on September 25, 2025: member

    Closing for now. This is LLM generated and obviously wrong (the tests fail), and the author does not seem to be working on it (no activity since this was opened 2 weeks ago)

  7. maflcko closed this on Sep 25, 2025

  8. maflcko commented at 2:10 PM on September 25, 2025: member

    In the future, instead of creating competing pull requests, it would be better to just review the existing pull request with any feedback you may have.


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: 2026-04-29 03:13 UTC

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