#36273 rpc: unify the TX decode failure error message
https://github.com/bitcoin/bitcoin/pull/36273 · · +31/-14 in 11 files, 2 commits · labels: RPC/REST/ZMQ
Goal
- Make raw transaction decode error hints consistent across RPC endpoints
- Help RPC users debug failures by giving accurate error hints and pinpointing failing transaction indices
This PR unifies the error message hint returned when raw transaction deserialization fails across eight RPC methods. It defines a shared constant `TX_DECODE_ERROR_HINT` in `src/rpc/util.h` and updates array-based RPCs (`generateblock`, `testmempoolaccept`, `submitpackage`, `combinerawtransaction`) to report the failing transaction index rather than repeating raw hex.
Problem: Different RPC endpoints used copy-pasted, slightly drifting error strings when `DecodeHexTx()` failed, often claiming only that the transaction lacked inputs when malformed hex or truncated bytes were also possible causes.
Category: RPC / REST / ZMQ (#48 of 52)
P4 · cleanup
- P4 because unifying decode error strings across endpoints is a minor cosmetic cleanup
- Provides slightly clearer diagnostics to RPC callers without affecting node stability or consensus
P4 because unifying decode error strings across RPC endpoints is a minor cosmetic cleanup. It provides slightly more accurate hints to developers passing malformed transaction hex, but has no impact on node stability, performance, or consensus.
Membership: Directly alters error message formatting across multiple RPC endpoints and introduces a shared hint in src/rpc/util.h.
Factors: security/stability 0, bug 0, performance 0, user value 1, leverage 0
Reviewability: Ready
- Ready to review
- Clean small change with passing CI
The PR is small, CI is passing, and the author addressed the initial nit with a clean push.
Author status: Active; force-pushed shortly after submission to address the doxygen comment nit.
Resolved concerns:
- maflcko pointed out a doxygen formatting nit on the hint comment in src/rpc/util.h and requested human-written pull request descriptions per the project AI policy.
Agreement: Crickets
- No reviews on the code or concept yet
- Reminder about project AI description policy and comment formatting nit (maflcko)
Crickets: no reviews of the change yet; comment on AI description policy and doxygen format (maflcko).
No contributor has evaluated the code or concept yet. The only comment was a reminder regarding the AI policy and a doxygen formatting nit.
- maflcko reminded the author of the project AI policy regarding description text and noted a three-slash doxygen nit.
Review verdicts (DrahtBot): 0
Files
15 lines under test/bench/ci.
- src/rpc/mempool.cpp +7/-5
- src/rpc/util.h +8/-0
- test/functional/rpc_rawtransaction.py +7/-0
- src/rpc/rawtransaction.cpp +2/-2
- src/rpc/mining.cpp +1/-1
- src/wallet/rpc/backup.cpp +1/-1
- src/wallet/rpc/spend.cpp +1/-1
- test/functional/rpc_echo_payload.py +1/-1
- test/functional/rpc_generate.py +1/-1
- test/functional/rpc_packages.py +1/-1
- test/functional/rpc_signrawtransactionwithkey.py +1/-1
Card
This PR unifies the error message text returned when raw transaction deserialization fails across several RPC methods by introducing a shared constant in src/rpc/util.h. It clarifies that decode failures can stem from serialization issues or invalid hex rather than just missing inputs, and switches multi-transaction RPCs to report the transaction index instead of the raw hex. The change is a minor usability and code cleanup with no behavioral or architectural impact. The code is ready for review, with no substantive feedback posted so far.