print P2WSH redeemScript in getrawtransaction if it s not a pubkey #8849

pull czzarr wants to merge 2 commits into bitcoin:master from ChaincodeResidency:print-p2wsh-redeemscript-in-getrawtransaction changing 1 files +12 −0
  1. czzarr commented at 3:12 pm on September 30, 2016: contributor

    This PR adds code to print a readable asm version of the redeemScript of a P2WSH input in the getrawtransaction RPC call which is useful to explore that kind of transactions.

    Example (on testnet3): ./bitcoin-cli getrawtransaction cd56a4b017bf5aeeb86e1397ac91bb9b4ee091d3be1c89b11b08c196468464bf 1 will output the following (note the new redeemScript key):

     0{
     1  "hex": "020000000001014558b8bc7f79efde796a90dca073e0808115365bb792db673cecf323c4eda2b40000000000ffffffff010eb50c00000000002200201d68ed9621fc634989c9988eda4883de4b3c699a154739a28891cb893ee7335c04004730440220120592e838230fb57292258dc98b6603ffd367adefb8f33fdea8b242f92823bc0220441d5fc90f6a3f61678db7bdb8256a61b08468fccad841841ec53791b27b002901483045022100bb3beffa751d485228d84513d84db6d2125af8f51bbaf6dd9a4a6ecbd7f73766022070b3478448192fd0d386a47e9a80b7d66839594526cdf33819c05449714c1242014752210251873cb58e82b8ba295cbaeb31bf5ce546182c6ff094b8c1fd0b33f82299d57721038f199dfacc8d2c83856d4a2ebda9f676962c880f7df3431fa47175940a1e101b52ae00000000",
     2  "txid": "cd56a4b017bf5aeeb86e1397ac91bb9b4ee091d3be1c89b11b08c196468464bf",
     3  "hash": "28961e39115f22896565e184beeb659ab68f6a8f9f0e4b8ca33699e837c4ca06",
     4  "size": 315,
     5  "vsize": 150,
     6  "version": 2,
     7  "locktime": 0,
     8  "vin": [
     9    {
    10      "txid": "b4a2edc423f3ec3c67db92b75b36158180e073a0dc906a79deef797fbcb85845",
    11      "vout": 0,
    12      "scriptSig": {
    13        "asm": "",
    14        "hex": ""
    15      },
    16      "txinwitness": [
    17        "", 
    18        "30440220120592e838230fb57292258dc98b6603ffd367adefb8f33fdea8b242f92823bc0220441d5fc90f6a3f61678db7bdb8256a61b08468fccad841841ec53791b27b002901", 
    19        "3045022100bb3beffa751d485228d84513d84db6d2125af8f51bbaf6dd9a4a6ecbd7f73766022070b3478448192fd0d386a47e9a80b7d66839594526cdf33819c05449714c124201", 
    20        "52210251873cb58e82b8ba295cbaeb31bf5ce546182c6ff094b8c1fd0b33f82299d57721038f199dfacc8d2c83856d4a2ebda9f676962c880f7df3431fa47175940a1e101b52ae"
    21      ],
    22      "redeemScript": {
    23        "asm": "2 0251873cb58e82b8ba295cbaeb31bf5ce546182c6ff094b8c1fd0b33f82299d577 038f199dfacc8d2c83856d4a2ebda9f676962c880f7df3431fa47175940a1e101b 2 OP_CHECKMULTISIG",
    24        "hex": "52210251873cb58e82b8ba295cbaeb31bf5ce546182c6ff094b8c1fd0b33f82299d57721038f199dfacc8d2c83856d4a2ebda9f676962c880f7df3431fa47175940a1e101b52ae",
    25        "reqSigs": 2,
    26        "type": "multisig",
    27        "addresses": [
    28          "mzLfZ7AJNtrcBZqXYXkMXRty6HoQB31Sbo", 
    29          "n1ANhQLAaEyswK9VWpEqCyTfgFvwtqtAYi"
    30        ]
    31      },
    32      "sequence": 4294967295
    33    }
    34  ],
    35  "vout": [
    36    {
    37      "value": 0.00832782,
    38      "n": 0,
    39      "scriptPubKey": {
    40        "asm": "0 1d68ed9621fc634989c9988eda4883de4b3c699a154739a28891cb893ee7335c",
    41        "hex": "00201d68ed9621fc634989c9988eda4883de4b3c699a154739a28891cb893ee7335c",
    42        "type": "witness_v0_scripthash"
    43      }
    44    }
    45  ],
    46  "blockhash": "00000000000000fd63636cdfdf9b5469b5cc57b379c40e12ecda58b3dcc7e932",
    47  "confirmations": 36672,
    48  "time": 1474472930,
    49  "blocktime": 1474472930
    50}
    
  2. print P2WSH redeemScript in getrawtransaction if it s not a pubkey 5f1800466b
  3. rename redeemScript to witnessScript 0793b62ef4
  4. in src/rpc/rawtransaction.cpp: in 5f1800466b outdated
     98+                CPubKey pubkey(tx.wit.vtxinwit[i].scriptWitness.stack.back().begin(), tx.wit.vtxinwit[i].scriptWitness.stack.back().end());
     99+                if (!pubkey.IsFullyValid()) {
    100+                  CScript redeemScript(tx.wit.vtxinwit[i].scriptWitness.stack.back().begin(), tx.wit.vtxinwit[i].scriptWitness.stack.back().end());
    101+                  UniValue r(UniValue::VOBJ);
    102+                  ScriptPubKeyToJSON(redeemScript, r, true);
    103+                  in.push_back(Pair("redeemScript", r));
    


    jl2012 commented at 4:07 pm on September 30, 2016:
    This is called witnessScript in BIP141

    czzarr commented at 4:46 pm on September 30, 2016:
    I renamed the variables.
  5. laanwj added the label RPC/REST/ZMQ on Sep 30, 2016
  6. fanquake commented at 1:29 pm on January 12, 2017: member
    Closing this due to inactivity. @czzarr If this is something that you would still like to see merged, please rebase and feel free to reopen.
  7. fanquake closed this on Jan 12, 2017

  8. jnewbery deleted the branch on Aug 22, 2019
  9. MarcoFalke locked this on Dec 16, 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: 2024-12-22 00:12 UTC

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