rpc: show P2(W)SH redeemScript in getrawtransaction (and friends) #27391

issue Sjors openend this issue on April 1, 2023
  1. Sjors commented at 6:26 pm on April 1, 2023: member

    Please describe the feature you’d like to see added.

    I’d like to be able to get the (decompiled) P2SH redeemScript and P2WSH witnessScript when calling getrawtransaction and getblock … 2.

    I found myself having a hard time counting sigops in the recently invalid block. For scriptPubKey it’s easy:

    0# Raw OP_CHECKMULTISIG: 20 x 4 sigops each
    1bitcoin-cli getblock 00000000000000000002ec935e245f8ae70fc68cc828f05bf4cfa002668599e4 2 | jq -r '.tx[].vout[].scriptPubKey.asm' | grep OP_CHECKMULTISIG | wc -l
    2# Raw OP_CHECKSIG(VERIFY): 4 sigops each
    3bitcoin-cli getblock 00000000000000000002ec935e245f8ae70fc68cc828f05bf4cfa002668599e4 2 | jq -r '.tx[].vout[].scriptPubKey.asm' | grep OP_CHECKSIG | wc -l
    

    Ideally something like this should work:

    0# TODO: OP_CHECK(MULTI)SIG in redeemScript:
    1…  jq -r '.tx[].vin[].redeemScript.asm …
    2…  jq -r '.tx[].vin[].witnesScript.asm …
    

    https://twitter.com/provoost/status/1642165984629780481

    Describe the solution you’d like

    An attempt was made in #8849.

    Describe any alternatives you’ve considered

    Inferred miniscript would catch many common P2WSH scripts, but not regular P2SH.

    Please leave any additional context

    No response

  2. Sjors added the label Feature on Apr 1, 2023
  3. Riahiamirreza commented at 12:21 pm on April 28, 2023: contributor
    Can I work on it? Isn’t it much hard as the first time contribution?
  4. michaelfolkson commented at 12:46 pm on April 28, 2023: contributor
    @Riahiamirreza: You don’t need to ask but stating you are planning to work on this is helpful for others. If you look at the linked attempt in #8849 it looks doable as a first contribution but I don’t know your skillset, level of understanding.
  5. Riahiamirreza commented at 1:01 pm on April 28, 2023: contributor
    @michaelfolkson Thanks for your reply. I think I have a good background in c++ and I’m familiar with the source code. But to start is I really need help.
  6. michaelfolkson commented at 1:11 pm on April 28, 2023: contributor
    @Riahiamirreza: Look at that attempt at changing rawtransaction.cpp and then ask questions on IRC #bitcoin-core-pr-reviews or Bitcoin StackExchange about the code in that file or the PR.
  7. Riahiamirreza commented at 6:05 pm on April 28, 2023: contributor
    I’m currently working on this issue. But it may take a while, since this is my first contribution.
  8. Riahiamirreza commented at 8:27 pm on April 29, 2023: contributor
    For backward compatibility, Should I add another level of verbosity that includes redeemScript in the scriptSig?
  9. michaelfolkson commented at 7:36 pm on May 1, 2023: contributor
    @Riahiamirreza: I suspect IRC (#bitcoin-core-pr-reviews) is better for these conversations as some have email notifications turned on for every comment in this repo. I wouldn’t have thought there was a backward compatibility issue here if you are adding a field rather than say removing a field that external software is relying upon.
  10. bitcoin deleted a comment on May 2, 2023
  11. Sjors commented at 3:20 pm on May 8, 2023: member
    I think adding fields is fine, unless determining their values is slow for some reason.
  12. willcl-ark added the label good first issue on Oct 14, 2024
  13. naiyoma commented at 10:11 am on October 23, 2024: contributor
    Picking this up since all previous attempts are now closed.

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: 2024-11-21 09:12 UTC

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