Skip to content

rpc: fix regression in gettransaction - #16873

Merged
meshcollider merged 2 commits into
bitcoin:masterfrom
jonatack:revive-rpc-gettransaction-details
Sep 15, 2019
Merged

meshcollider merged 2 commits into
bitcoin:masterfrom
jonatack:revive-rpc-gettransaction-details

Conversation

@jonatack

@jonatack jonatack commented Sep 14, 2019 •

Copy link
Copy Markdown
Member

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:

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.

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 meshcollider left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! utACK 0f34f54

@promag promag left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jnewbery

Copy link
Copy Markdown
Contributor

concept ACK.

I feel embarrassed for not catching this previously..

... but not as embarrassed as I feel for writing it!

the verbose test is incomplete, it should test the full response if verbose=true

I agree that wallet_basic.py should be updated to test the details field, with verbose set to both True and False.

I think all .pushKV calls to build a response should throw instead of overwriting

Concept ACK. Let me know when there's a PR to review.

@jonatack

Copy link
Copy Markdown
Member Author

@promag, @jnewbery: 👍 agree with both of your ideas for improving the test coverage. I'll do that tomorrow and let @promag add .pushKV throwing instead of overwriting.

@darosior darosior left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK 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.
@jonatack
jonatack force-pushed the revive-rpc-gettransaction-details branch from 47b3e43 to 1b41c2c Compare September 15, 2019 16:56
@jnewbery

Copy link
Copy Markdown
Contributor

tACK 1b41c2c

New tests are great. Thanks Jon!

@jonatack

Copy link
Copy Markdown
Member Author

@meshcollider, @promag, @jnewbery, @darosior thanks for reviewing! Added a follow-up commit with more coverage. EDIT: Thanks, John!

meshcollider added a commit that referenced this pull request Sep 15, 2019
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
@meshcollider
meshcollider merged commit 1b41c2c into bitcoin:master Sep 15, 2019
@jonatack
jonatack deleted the revive-rpc-gettransaction-details branch September 15, 2019 21:45
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 21, 2019
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
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 21, 2019
- 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
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 7, 2020
…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
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RPC gettransaction regression

8 participants