Repository navigation
rpc: fix regression in gettransaction - #16873
Conversation
PR 16866 renamed the 'decode' argument in gettransaction to 'verbose' to make it more consistent with other RPC calls like getrawtransaction. However, it seems it inadvertently overloaded the 'details' fields when 'verbose' is passed. The result is that the original 'details' fields are no longer returned, which seems to be a breaking API change. This PR takes the simplest path to restoring the 'details' fields by renaming them from 'details' back to 'decoded', while leaving the 'verbose' argument for API consistency. It also addresses [this comment](bitcoin#16185 (comment)) to mention that the 'decoded' field is identical to decoderawtransaction. Update the RPC help, functional test, and release note.
meshcollider
left a comment
There was a problem hiding this comment.
Nice catch! utACK 0f34f54
There was a problem hiding this comment.
I feel embarrassed for not catching this previously.. That said, to me this is also an indication that the verbose test is incomplete, it should test the full response if verbose=true. BTW I think this is a good practice because it allows to better test how parameters interact with each other and how it affects the result.
Also related, and I already said this previously in other PR, I think all .pushKV calls to build a response should throw instead of overwriting. I feel that most certainly the developer doesn't want to overwrite, and as such execution should abort (note that these JSON keys are never user input).
Tested ACK 0f34f54.
|
concept ACK.
... but not as embarrassed as I feel for writing it!
I agree that
Concept ACK. Let me know when there's a PR to review. |
- Test gettransaction response without verbose, with verbose=False, and with verbose=True. - In each case, test presence of expected fields in the output, including absence of the "decoded" field when `verbose` is not passed or false. - Test that the "details" field contains the expected receive vout in each case.
47b3e43 to
1b41c2c
Compare
|
tACK 1b41c2c New tests are great. Thanks Jon! |
|
@meshcollider, @promag, @jnewbery, @darosior thanks for reviewing! Added a follow-up commit with more coverage. EDIT: Thanks, John! |
1b41c2c test: improve gettransaction test coverage (Jon Atack) 0f34f54 rpc: fix regression in gettransaction (Jon Atack) Pull request description: Closes #16872. PR #16866 renamed the `decode` argument in gettransaction to `verbose` to make it more consistent with other RPC calls like getrawtransaction. However, it inadvertently overloaded the "details" field when `verbose` is passed. The result is that the original "details" field is no longer returned correctly, which seems to be a breaking API change. This PR: - takes the simplest path to restoring the "details" field by renaming the decoded one back to "decoded" while leaving the `verbose` argument for API consistency, which was the main intent of #16866, - addresses [this comment](#16185 (comment)) by mentioning in the RPC help that the new decoded field is equivalent to decoderawtransaction, and - updates the help, functional test, and release note. Reviewers, to test this manually, build and run `bitcoin-cli help gettransaction` and `bitcoin-cli gettransaction <wallet txid> false true`, and verify that the command returns both `details` and `decoded` fields. ACKs for top commit: jnewbery: tACK 1b41c2c Tree-SHA512: 287edd5db7ed58fe8b548975aba58628bd45ed708b28f40174f10a35a455d89f796fbf27430aa881fc376f47aabda8803f74d4d100683bd86577a02279091cf3
PR 16866 renamed the 'decode' argument in gettransaction to 'verbose' to make it more consistent with other RPC calls like getrawtransaction. However, it seems it inadvertently overloaded the 'details' fields when 'verbose' is passed. The result is that the original 'details' fields are no longer returned, which seems to be a breaking API change. This PR takes the simplest path to restoring the 'details' fields by renaming them from 'details' back to 'decoded', while leaving the 'verbose' argument for API consistency. It also addresses [this comment](bitcoin#16185 (comment)) to mention that the 'decoded' field is identical to decoderawtransaction. Update the RPC help, functional test, and release note. Github-Pull: bitcoin#16873 Rebased-From: 0f34f54
- Test gettransaction response without verbose, with verbose=False, and with verbose=True. - In each case, test presence of expected fields in the output, including absence of the "decoded" field when `verbose` is not passed or false. - Test that the "details" field contains the expected receive vout in each case. Github-Pull: bitcoin#16873 Rebased-From: 1b41c2c
…ethod to 'verbose' Summary: [wallet] Rename 'decode' argument in gettransaction method to 'verbose' (John Newbery) Pull request description: This makes the RPC method consistent with other RPC methods that have a 'verbose' option. Change the name of the return object from 'decoded' to details. Update help text. --- Backport of Core [[bitcoin/bitcoin#16866 | PR16866]] and [[bitcoin/bitcoin#16873 | PR16873]] (required to unbreak [[bitcoin/bitcoin#16866 | PR16866]]) Test Plan: ninja check check-functional Reviewers: #bitcoin_abc, deadalnix Reviewed By: #bitcoin_abc, deadalnix Differential Revision: https://reviews.bitcoinabc.org/D7378
Closes #16872.
PR #16866 renamed the
decodeargument in gettransaction toverboseto make it more consistent with other RPC calls like getrawtransaction. However, it inadvertently overloaded the "details" field whenverboseis passed. The result is that the original "details" field is no longer returned correctly, which seems to be a breaking API change.This PR:
takes the simplest path to restoring the "details" field by renaming the decoded one back to "decoded" while leaving the
verboseargument for API consistency, which was the main intent of wallet: Rename 'decode' argument in gettransaction method to 'verbose' #16866,addresses this comment by mentioning in the RPC help that the new decoded field is equivalent to decoderawtransaction, and
updates the help, functional test, and release note.
Reviewers, to test this manually, build and run
bitcoin-cli help gettransactionandbitcoin-cli gettransaction <wallet txid> false true, and verify that the command returns bothdetailsanddecodedfields.