rpc: unify the TX decode failure error message #36273

pull MrHodlX wants to merge 2 commits into bitcoin:master from MrHodlX:rpc-uniform-decode-message changing 11 files +31 −14
  1. MrHodlX commented at 2:16 PM on September 16, 2026: none

    The "Make sure the tx has at least one input." advice is copied into every DecodeHexTx() error, even though that message also fires on bad hex and truncated or padded serialization. This moves the advice into one shared constant so the eight RPCs using it can't drift. The #19836 hint stays; it just now also names serialization and hex separately.

    Array RPCs report the failing index instead of echoing the raw hex back. simulaterawtransaction's different wording is left alone.

    Tests updated to match, plus malformed-payload coverage.

  2. DrahtBot added the label RPC/REST/ZMQ on Sep 16, 2026
  3. DrahtBot commented at 2:16 PM on September 16, 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/36273.

    <!--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-->

  4. maflcko commented at 2:28 PM on September 16, 2026: member

    Eight RPCs had the same "TX decode failed" advice pasted in, and it was drifting between wordings. This puts the advice in one inline constexpr string_view constant (TX_DECODE_ERROR_HINT) in rpc/util.h and uses it from sendrawtransaction, testmempoolaccept, submitpackage, generateblock, combinerawtransaction, signrawtransactionwithkey, signrawtransactionwithwallet, and importprunedfunds.

    Again, please do not use LLM generated messages: https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md No one cares if those are 7 or 9 RPCs, or a full list with their names, in the pull description. Also, implementation details like inline constexpr string_view are irrelevant here. If anyone wanted to see the changes, they can just look at the changes themselves.

    Please write comments yourself and explain why the change is needed. I am sure reviewers here have seen enough LLM-sounding output to be turned off by it. So seeing comments written with a human touch will likely attract more reviewers.

  5. rpc: unify the TX decode failure error message 3b7360ce02
  6. test: cover malformed sendrawtransaction payloads 5b71447c63
  7. in src/rpc/util.h:41 in 4ccf5a8b66
      33 | @@ -34,6 +34,14 @@ struct FlatSigningProvider;
      34 |  struct bilingual_str;
      35 |  class CBlockIndex;
      36 |  
      37 | +// The shared advice in every "TX decode failed" RPC error. DecodeHexTx()
      38 | +// fails on invalid hex and incomplete or malformed serialization too, not
      39 | +// only on the zero-input case it was written for (#19836); it never checks
      40 | +// vin emptiness (an empty-input transaction that decodes is rejected later
      41 | +// by CheckTransaction() as bad-txns-vin-empty).
    


    maflcko commented at 2:29 PM on September 16, 2026:
    /// The shared advice in every "TX decode failed" RPC error. DecodeHexTx()
    /// fails on invalid hex and incomplete or malformed serialization too, not
    // only on the zero-input case it was written for (#19836); it never checks
    // vin emptiness (an empty-input transaction that decodes is rejected later
    // by CheckTransaction() as bad-txns-vin-empty).
    

    nit: I think doxygen requires three /// for this to end up in the docs.

  8. MrHodlX force-pushed on Sep 16, 2026
  9. DrahtBot added the label CI failed on Sep 18, 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 03:52 UTC

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