rpc: print P2WSH witScript in getrawtransaction #31252

pull polespinasa wants to merge 1 commits into bitcoin:master from polespinasa:p2wsh_redeem changing 2 files +14 −0
  1. polespinasa commented at 8:39 pm on November 7, 2024: none

    This PR is motivated by #27391. And inspired by a previous PR #8849 that proposed something similar.

    This issue is partially solved as this PR only prints P2WSH.

    This is an example with a real mainnet transaction (3-5 multisig) and using decoderawtransaction (also works for getrawtransaction 'raw' 1).

     0{
     1  "txid": "6346e552f62281314dfeace8f977e056f251bc55d15b24ec14f73b34387357cf",
     2  "hash": "6feae897bafa067ebdb37ec5459632a3d7adad7a43ba4c5cd986290601890dfc",
     3  "version": 2,
     4  "size": 995,
     5  "vsize": 406,
     6  "weight": 1622,
     7  "locktime": 866335,
     8  "vin": [
     9    {
    10      "txid": "ca7449fc71dd22be5cf5102403fa533ed1a60568be189cc2634eda7ea1cda8b0",
    11      "vout": 1,
    12      "scriptSig": {
    13        "asm": "",
    14        "hex": ""
    15      },
    16      "txinwitness": [
    17        "",
    18      "304402200d7fa3b5f9e120bc745eddc04f15a8dcc0d5de94094cfd51108a05316f6e057f02204a91eb5181de60badde799b634bea62c9c48cbf1b2db41e103683cfbdc3b27f801",
    19        "30440220589560381db4faa1860fbc6062e0bbf0bdfed9fa4487a62f93138c6dfc0323c302202027c17a359d638534576c5360b8fc68370eb05dfdf0cf090421be538439500a01",
    20        "304402207fa11c62520f28f1020aeaca8f33b24785adcabaf8d1b0b02cb575d0854816d5022038ebbbccff03e291f0af3ab25380b7bfae9cc0ae1894fd43de61d7dd37c4f42e01",
    21        "532102315dc82d3cbfc3db0ded614b503060869f70d41a6880762d154da586f020ccee210266e3d4116335998f218bcc7287d58452552ac9b2180cdfb038f21455d058bedc21027b61ce3da654c6481cb7252f810f54a4be4e6446a9578ca6e6351f3068feab1d2102aee061de64c6cb29835d81a599b3d7b6977298b34fd50d51f8557861e71a6ffe2102e3fea7eaa609f3294b9a98037ede530afdfa6ea34bb8a93c1d15527bf026d2da55ae"
    22      ],
    23      "witScript": {
    24        "asm": "3 02315dc82d3cbfc3db0ded614b503060869f70d41a6880762d154da586f020ccee 0266e3d4116335998f218bcc7287d58452552ac9b2180cdfb038f21455d058bedc 027b61ce3da654c6481cb7252f810f54a4be4e6446a9578ca6e6351f3068feab1d 02aee061de64c6cb29835d81a599b3d7b6977298b34fd50d51f8557861e71a6ffe 02e3fea7eaa609f3294b9a98037ede530afdfa6ea34bb8a93c1d15527bf026d2da 5 OP_CHECKMULTISIG",
    25        "desc": "multi(3,02315dc82d3cbfc3db0ded614b503060869f70d41a6880762d154da586f020ccee,0266e3d4116335998f218bcc7287d58452552ac9b2180cdfb038f21455d058bedc,027b61ce3da654c6481cb7252f810f54a4be4e6446a9578ca6e6351f3068feab1d,02aee061de64c6cb29835d81a599b3d7b6977298b34fd50d51f8557861e71a6ffe,02e3fea7eaa609f3294b9a98037ede530afdfa6ea34bb8a93c1d15527bf026d2da)#yf60teq5",
    26        "type": "multisig"
    27      },
    28      "sequence": 4294967293
    29    },
    30    {
    31        other inputs ... 
    32     }
    33  ],
    34  "vout": [
    35    {
    36      outputs ...
    37     }
    38    ]
    39}
    
  2. DrahtBot commented at 8:39 pm on November 7, 2024: contributor

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

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/31252.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  3. DrahtBot added the label RPC/REST/ZMQ on Nov 7, 2024
  4. polespinasa renamed this:
    rpc: print P2WSH redeemScript in getrawtransaction
    rpc: print P2WSH witScript in getrawtransaction
    on Nov 7, 2024
  5. polespinasa marked this as a draft on Nov 7, 2024
  6. DrahtBot added the label CI failed on Nov 7, 2024
  7. DrahtBot removed the label CI failed on Nov 8, 2024
  8. polespinasa marked this as ready for review on Nov 8, 2024
  9. in src/core_write.cpp:215 in 66ea8941de outdated
    206@@ -207,6 +207,14 @@ void TxToUniv(const CTransaction& tx, const uint256& block_hash, UniValue& entry
    207                 txinwitness.push_back(HexStr(item));
    208             }
    209             in.pushKV("txinwitness", std::move(txinwitness));
    210+            CPubKey pubkey(tx.vin[i].scriptWitness.stack.back());
    211+            if (!pubkey.IsFullyValid()){
    212+                CScript witnessScript(tx.vin[i].scriptWitness.stack.back().begin(), tx.vin[i].scriptWitness.stack.back().end());
    213+                UniValue witScript(UniValue::VOBJ);
    214+                ScriptToUniv(witnessScript, witScript, false, true);
    215+                in.pushKV("witScript", std::move(witScript));
    


    kevkevinpal commented at 3:10 am on November 13, 2024:

    I think it might make more sense to name it “witnessScript” instead of “witScript”, It might be confusing to some if it is abbreviated

    0                in.pushKV("witnessScript", std::move(witScript));
    

    polespinasa commented at 11:36 am on November 13, 2024:
    I agree, it needs to be changed in one more place apart from this line but yes I will apply it. Thanks!
  10. kevkevinpal commented at 3:12 am on November 13, 2024: contributor
    can we squash 66ea8941de3dfd498319c6390655a165f6a5a92b and 84fb299de72ca9e08fe5029380a779d57d302347 to a single commit
  11. Decode P2WSH on decodingawtransaction functions 4e128d4f9b
  12. polespinasa force-pushed on Nov 13, 2024
  13. polespinasa requested review from kevkevinpal on Nov 13, 2024

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 06:12 UTC

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