bitcoin-tx: Add the "-txid" option and add hex-encoded transaction to JSON #5207

pull mruddy wants to merge 1 commits into bitcoin:master from mruddy:dev2 changing 2 files +12 −0
  1. mruddy commented at 6:05 PM on November 4, 2014: contributor

    Add option to include computed transaction hash in output when hex-encoding is selected.

    The hash gets output already for JSON.

    When selected, the hex tx hash will be output on another line so as to not break things that are already scripted to the output of this utility.

  2. sipa commented at 6:23 PM on November 4, 2014: member

    Looks good to me. Opinions, @jgarzik ?

  3. jgarzik commented at 7:51 PM on November 4, 2014: contributor

    No objection to outputting the hash somewhere. The norm is providing the txid and hex-encoded TX in JSON output.

    Providing the hash as a key=value line separate from the hex-encoded output is a bit odd.

  4. mruddy commented at 8:33 PM on November 4, 2014: contributor

    Thanks for the feedback.

    I agree, it's a little awkward. My main reason for the key-value pair was to make sure that users did not think that the hex-encoded hash was part of the hex-encoded transaction. I can bring it all onto one line since it's a new flag that won't break anybody yet.

    Three options that come to mind:

    1. Like Jeff said: {"txid":"hex tx hash", "tx":"hex tx"}
    2. hex tx,hex tx hash
    3. tx=hex tx,txid=hex tx hash

    Option 1 is clean and makes sense to look at. Option 2 is easier to command line script (e.g.- use "cut" instead of going to python, ruby, etc...). Option 3 is a mix.

    I kind of like option 2 for scripting ease, but it's not a strong preference. I'll update to use Jeff's idea (option 1) if I don't get any conflicting feedback within a few hours.

  5. jgarzik commented at 8:57 PM on November 4, 2014: contributor

    Another option is "-hash" command line option, which only outputs the hash. That turns some operations into a two-step process, but is clean and util-friendly. No 'cut' or 'awk' required.

  6. mruddy commented at 10:15 PM on November 4, 2014: contributor

    Good idea Jeff! I've incorporated both of your inputs. Now, there is a "-hash" that outputs only the computed transaction hash. There is also a new "-hexhash" that creates the JSON formatted output containing both the hex-encoded transaction and the hex-encoded transaction id. I like this updated commit much more than my original submission.

  7. jgarzik commented at 10:21 PM on November 4, 2014: contributor

    For the latter, I would recommend simply modifying the "-json" output to include the txid and hex-encoded tx.

    That then mirrors what bitcoind produces in some of its output, such as 'getrawtransaction' when 'verbose' flag is true.

  8. mruddy commented at 11:11 PM on November 4, 2014: contributor

    Ah, cool, I wasn't aware of that, even better. I looked at getrawtransaction and this latest commit changes course a bit in order to be consistent with that. Now, there are -txid and -verbose options instead of -hash and -hexhash. The -txid is the case where we only show the hex-encoded transaction id/hash. The -verbose option now simply adds the "hex" member to the JSON output. This also makes the "-verbose" flag available for expansion later.

  9. jgarzik commented at 11:13 PM on November 4, 2014: contributor

    I think we are pretty close. Consider that bitcoind interprets "verbose" as implying the entire JSON output. i.e. "not verbose" is the hex-encoded binary form.

    Therefore, (1) -txid as you have it and (2) added "hex" to JSON output should be sufficient. No need for an additional -verbose.

  10. mruddy commented at 11:29 PM on November 4, 2014: contributor

    OK, what I hear you saying is that requesting JSON output is synonymous with requesting verbose output in this context. Sounds fine, commit updated.

  11. jgarzik commented at 11:34 PM on November 4, 2014: contributor

    Looks good to me. Wait a bit for others' comments (if any), rebase into a single commit, and we're done.

  12. bitcoin-tx: Add the "-txid" option. Also add the hex-encoded transaction to the JSON output as the "hex" property. 84877904c0
  13. mruddy force-pushed on Nov 5, 2014
  14. mruddy renamed this:
    bitcoin-tx: Add option to include computed transaction hash in output
    bitcoin-tx: Add the "-txid" option and add hex-encoded transaction to JSON
    on Nov 5, 2014
  15. mruddy commented at 3:31 AM on November 5, 2014: contributor

    Cool, re-based, should be good to go. Thanks for the help and feedback!

  16. jgarzik commented at 3:34 AM on November 5, 2014: contributor

    ut ACK -- looks good to me

  17. mruddy commented at 4:01 PM on November 7, 2014: contributor

    Anything else I need to do to get this request merged in? Thanks!

  18. jgarzik commented at 4:10 PM on November 7, 2014: contributor

    @mruddy Nothing on your side, besides waiting. We need another dev to ACK it, as we require multiple reviews before merging non-trivial patches.

  19. gmaxwell commented at 7:13 PM on November 8, 2014: contributor

    ACK

  20. sipa commented at 4:17 PM on November 17, 2014: member

    utACK

  21. laanwj added the label Improvement on Dec 5, 2014
  22. laanwj merged this on Dec 5, 2014
  23. laanwj closed this on Dec 5, 2014

  24. laanwj referenced this in commit 7d42644dda on Dec 5, 2014
  25. mruddy deleted the branch on Dec 5, 2014
  26. MarcoFalke locked this on Sep 8, 2021

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-04-22 06:15 UTC

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