rpc: clarify tx decode error in remaining RPCs #36263

pull MrHodlX wants to merge 4 commits into bitcoin:master from MrHodlX:rpc-uniform-tx-decode-error changing 14 files +68 −17
  1. MrHodlX commented at 3:15 PM on September 15, 2026: none

    Follow-up to #36250 (currently based on its head; will rebase onto master after it merges).

    The same error is returned for every DecodeHexTx() failure — invalid hex, incomplete or malformed serialization — and DecodeHexTx() does not check that vin is nonempty (an empty-input transaction that decodes is rejected later by CheckTransaction() as bad-txns-vin-empty). This applies the message agreed in #36250 to the remaining DecodeHexTx() error paths: testmempoolaccept, submitpackage, generateblock, combinerawtransaction, signrawtransactionwithkey, signrawtransactionwithwallet, and importprunedfunds. simulaterawtransaction is unchanged: its "Transaction hex string decoding failure." message is already generic and accurate.

    The first commit changes only the wording, retaining the payload echo in the array RPCs so it passes independently. The second commit replaces the echoed raw hex with the failing element's index (e.g. "TX decode failed for tx 1. ..."), matching combinerawtransaction's existing behavior: the echo can be hundreds of KB and returns data the caller already has, while the index identifies the failing array element.

    Tests verify the reported index for malformed elements in non-first positions and that the raw hex is no longer echoed; full-message assertions now cover testmempoolaccept, submitpackage, generateblock, combinerawtransaction (index preserved), signrawtransactionwithkey, signrawtransactionwithwallet, and importprunedfunds.

  2. rpc: clarify sendrawtransaction decode error
    The same error is returned for every DecodeHexTx() failure, including
    invalid hex and incomplete or malformed serialization, so mention the
    serialization and hex encoding requirements alongside the existing
    input hint (added deliberately in #19836 for zero-input transaction
    decode failures).
    
    Update the rpc_echo_payload expectation, which asserts the exact
    message.
    42675f617b
  3. test: cover sendrawtransaction decode failures
    Add assertions for invalid hex, truncated, and trailing-byte payloads
    in sendrawtransaction_tests.
    94a616d700
  4. rpc: clarify tx decode error in remaining RPCs
    Follow-up to #36250. The "Make sure the tx has at least one input."
    hint is returned for every DecodeHexTx() failure, including invalid
    hex and incomplete or malformed serialization. Mention the
    serialization and hex encoding requirements alongside the input hint
    (which is retained, as it was added deliberately in #19836) in the
    remaining DecodeHexTx() error paths: testmempoolaccept,
    submitpackage, generateblock, combinerawtransaction,
    signrawtransactionwithkey, signrawtransactionwithwallet, and
    importprunedfunds.
    
    simulaterawtransaction is unchanged: its "Transaction hex string
    decoding failure." message is already generic and accurate.
    
    The array RPCs still echo the offending hex for now; the next commit
    replaces that with the failing element's index.
    9d2ca4e66b
  5. rpc: report failing tx index instead of echoing hex in array RPCs
    testmempoolaccept, submitpackage, and generateblock echoed the
    offending raw transaction back in the decode error, which can produce
    oversized error responses and returns data the caller already has.
    Report the failing element's index instead, matching the existing
    behavior of combinerawtransaction.
    
    Tests verify the reported index for malformed elements in non-first
    positions and that the raw hex is no longer echoed.
    78953cfc65
  6. DrahtBot added the label RPC/REST/ZMQ on Sep 15, 2026
  7. DrahtBot commented at 3:15 PM on September 15, 2026: 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/36263.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

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

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #32468 (rpc: generateblock to allow multiple outputs by polespinasa)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  8. l0rinc commented at 11:31 PM on September 15, 2026: contributor

    If this depends on #36250, could you please either make sure the changes don't actually belong there instead. If this is genuinely a follow-up, please make it into a draft to signal that it's not ready for review yet.

  9. MrHodlX marked this as a draft on Sep 16, 2026
  10. MrHodlX commented at 2:15 PM on September 16, 2026: none

    Superseded by the unified PR that puts the message in one place (rpc/util.h constant). Closing so there is a single PR for this change.

  11. MrHodlX closed this on Sep 16, 2026


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-09-21 02:52 UTC

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