Skip to content

gettransaction: add an argument to decode the transaction - #16185

Merged
meshcollider merged 3 commits into
bitcoin:masterfrom
darosior:decode_tx_gettransaction
Sep 2, 2019
Merged

meshcollider merged 3 commits into
bitcoin:masterfrom
darosior:decode_tx_gettransaction

Conversation

@darosior

Copy link
Copy Markdown
Member

This PR adds a new parameter to the gettransaction call : decode. If set to true, it will add a new decoded field to the response. This mimics the behavior of getrawtransaction's verbose argument to avoid using 2 calls if we want to decode a wallet transaction (gettransaction then decoderawtransaction).

Fix #16181 .

@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.

Concept ACK, please include tests and a release note.

Comment thread src/wallet/rpcwallet.cpp Resolved
Comment thread src/wallet/rpcwallet.cpp Resolved
Comment thread src/wallet/rpcwallet.cpp Resolved
@darosior
darosior force-pushed the decode_tx_gettransaction branch from 7894189 to 0622d5b Compare June 10, 2019 22:44
@darosior

Copy link
Copy Markdown
Member Author

@promag thank you for the review. I added the changes and will include the tests and release note soon.

@DrahtBot

DrahtBot commented Jun 10, 2019 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #16365 (Log RPC parameters (arguments) if -debug=rpcparams by LarryRuane)
  • #16199 (rpc: fix showing wrong amount when not all inputs are from me in gettransaction by shannon1916)
  • #14707 ([RPC] Include coinbase transactions in receivedby RPCs by andrewtoth)

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.

@darosior

Copy link
Copy Markdown
Member Author

Concept ACK, please include tests and a release note.

Since there was no functional test for the gettransaction I created a new one. However it only tests the decoded field since I don't know if testing other would not be overkill.

Comment thread test/functional/rpc_gettransaction.py Resolved
Comment thread test/functional/rpc_gettransaction.py Resolved
@darosior
darosior force-pushed the decode_tx_gettransaction branch 2 times, most recently from b351a12 to 9759da2 Compare June 12, 2019 22:44
@darosior

Copy link
Copy Markdown
Member Author

Moved the test to test/functional/wallet_basic.py and used named arguments.

Comment thread test/functional/test_runner.py Resolved
@darosior
darosior force-pushed the decode_tx_gettransaction branch from 9759da2 to 676b504 Compare June 13, 2019 09:52
@darosior
darosior force-pushed the decode_tx_gettransaction branch 2 times, most recently from 8ccc657 to 7cf832a Compare July 10, 2019 14:06
@darosior
darosior force-pushed the decode_tx_gettransaction branch 2 times, most recently from 8e78c0b to 91f15c8 Compare July 10, 2019 21:26
@darosior

Copy link
Copy Markdown
Member Author

Rebased.

Comment thread src/wallet/rpcwallet.cpp Resolved
Comment thread src/wallet/rpcwallet.cpp Resolved
Comment thread src/wallet/rpcwallet.cpp Resolved
Comment thread test/functional/wallet_basic.py Resolved
Comment thread test/functional/wallet_basic.py Resolved
Comment thread test/functional/wallet_basic.py Resolved
@darosior
darosior force-pushed the decode_tx_gettransaction branch 2 times, most recently from 769a0ea to 5f96ab3 Compare July 18, 2019 19:49
@darosior

Copy link
Copy Markdown
Member Author

Some minor corrections according to last review.

@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.

You could use 0b6ba66#diff-0f596a69ccfb4d07c007cd6fc993898dR50 (not yet in master) to do:

assert_no_key('decoded', self.nodes[0].gettransaction(txid, decode=False))

@jb55 jb55 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.

Concept ACK

Comment thread test/functional/wallet_basic.py Resolved
Comment thread doc/release-notes.md Resolved
@darosior
darosior force-pushed the decode_tx_gettransaction branch from 5f96ab3 to 5c28a1f Compare August 4, 2019 18:39
@darosior

darosior commented Aug 4, 2019 •

Copy link
Copy Markdown
Member Author

Rebased.
(And addressed the spacing nits pointed by @jb55 :-) )

@darosior

Copy link
Copy Markdown
Member Author

You must make linters happy.

No that's a Travis error : curl: (7) Failed to connect to storage.googleapis.com port 443: Connection timed out

This adds a new boolean parameter 'decode' to the gettransaction call, which, if set to true, add a 'decoded' field to the result containing the decoded transaction
@darosior
darosior force-pushed the decode_tx_gettransaction branch from 50d0174 to 9965940 Compare August 30, 2019 09:41

@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.

re-utACK 9965940

meshcollider added a commit that referenced this pull request Sep 2, 2019
9965940 doc: Add release note for the new gettransaction argument (darosior)
b8b3f04 tests: Add a new functional test for gettransaction (darosior)
7f3bb24 gettransaction: add an argument to decode the transaction (darosior)

Pull request description:

  This PR adds a new parameter to the `gettransaction` call : `decode`. If set to `true`, it will add a new `decoded` field to the response. This mimics the behavior of `getrawtransaction`'s `verbose` argument to avoid using 2 calls if we want to decode a wallet transaction (`gettransaction` then `decoderawtransaction`).

  Fix #16181 .

ACKs for top commit:
  meshcollider:
    re-utACK 9965940

Tree-SHA512: bcb6b4bd252b3488d6afc77659c499c2ad99fd58661eb24b6a2e17014c74f22e47fde70e00fedb4f4754915786622ad02483b2cf2c4dea0ab0eb4ac8276dbeee
@meshcollider
meshcollider merged commit 9965940 into bitcoin:master Sep 2, 2019
@darosior
darosior deleted the decode_tx_gettransaction branch September 2, 2019 11:33
Comment thread src/wallet/rpcwallet.cpp
" ,...\n"
" ],\n"
" \"hex\" : \"data\" (string) Raw data for transaction\n"
" \"decoded\" : transaction (json object) Optional, the decoded transaction\n"

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.

Should mention that the field is identical to decoderawtransaction?

@jnewbery

Copy link
Copy Markdown
Contributor

Sorry for the post-merge review comment, but would it make sense to call the new parameter verbose, to mirror the verbose argument in getrawtransaction?

If so, we should make that change before v0.19 to avoid an API change.

@ryanofsky

Copy link
Copy Markdown
Contributor

Sorry for the post-merge review comment, but would it make sense to call the new parameter verbose, to mirror the verbose argument in getrawtransaction?

If so, we should make that change before v0.19 to avoid an API change.

This seems like a good idea. You could open a one-line PR and add the milestone to get more feedback.

@promag

promag commented Sep 12, 2019

Copy link
Copy Markdown
Contributor

+1 for API consistency.

jonatack added a commit to jonatack/bitcoin-core that referenced this pull request Sep 14, 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.
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
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 19, 2019
This adds a new boolean parameter 'decode' to the gettransaction call, which, if set to true, add a 'decoded' field to the result containing the decoded transaction

Github-Pull: bitcoin#16185
Rebased-From: 7f3bb24
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Sep 19, 2019
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
barrystyle pushed a commit to zentoshi/zentoshi that referenced this pull request Nov 11, 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/bitcoin#16185 (comment)) to mention that the 'decoded' field is identical to decoderawtransaction.

Update the RPC help, functional test, and release note.
SmarterHomes pushed a commit to SmarterHomes/chaincoin that referenced this pull request Nov 17, 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.
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 5, 2020
…ansaction

Summary:
This adds a new boolean parameter 'decode' to the gettransaction call, which, if set to true, add a 'decoded' field to the result containing the decoded transaction

bitcoin/bitcoin@7f3bb24

---

Partial backport of Core [[bitcoin/bitcoin#16185 | PR16185]]

Test Plan:
  ninja check check-functional

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7370
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 5, 2020
Summary:
bitcoin/bitcoin@b8b3f04

---

Depends on D7370

Partial backport of Core [[bitcoin/bitcoin#16185 | PR16185]]

Test Plan:
  test_runner.py wallet_basic

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7371
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Sep 5, 2020
… argument

Summary:
bitcoin/bitcoin@9965940

---

Depends on D7371

Concludes backport of Core [[bitcoin/bitcoin#16185 | PR16185]]

Test Plan:
  read release notes

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7372
@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.

wallet: decode raw transaction in gettransaction