Prevent possible footgun caused by decodescript converting P2PKH with uncompressed pubkey into SegWit addresses #19383

issue andronoob opened this issue on June 26, 2020
  1. andronoob commented at 4:05 AM on June 26, 2020: none

    Is your feature request related to a problem? Please describe.

    <!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

    If I'm not mistaken, a SegWit address with an uncompressed pubkey is not spendable. However the decodescript RPC call can still convert any P2PKH output script into SegWit addresses by default. I think this may cause footguns.

    Describe the solution you'd like

    <!-- A clear and concise description of what you want to happen. -->

    An additional optional argument to enable SegWit conversions, rather than providing SegWit addresses by default.

    Describe alternatives you've considered

    <!-- A clear and concise description of any alternative solutions or features you've considered. -->

    Show more warning messages in the help information and/or JSON response data.

    Additional context

    <!-- Add any other context or screenshots about the feature request here. -->

    https://github.com/bitcoinjs/bitcoinjs-lib/issues/1405

    getaddressinfo 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
    
    {
      "address": "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa",
      "scriptPubKey": "76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac",
      "ismine": false,
      "solvable": true,
      "desc": "pkh([62e907b1]04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f)#txu8e08h",
      "iswatchonly": true,
      "isscript": false,
      "iswitness": false,
      "pubkey": "04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5f",
      "iscompressed": false,
      "ischange": false,
      "timestamp": 1,
      "labels": [
        "Bitcoin Genesis"
      ]
    }
    
    decodescript 76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac
    
    {
      "asm": "OP_DUP OP_HASH160 62e907b15cbf27d5425399ebf6f0fb50ebb88f18 OP_EQUALVERIFY OP_CHECKSIG",
      "reqSigs": 1,
      "type": "pubkeyhash",
      "addresses": [
        "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
      ],
      "p2sh": "3AvCTuWxratRphL933Tw21eN5wecHCVd36",
      "segwit": {
        "asm": "0 62e907b15cbf27d5425399ebf6f0fb50ebb88f18",
        "hex": "001462e907b15cbf27d5425399ebf6f0fb50ebb88f18",
        "reqSigs": 1,
        "type": "witness_v0_keyhash",
        "addresses": [
          "bc1qvt5s0v2uhuna2sjnn84ldu8m2r4m3rcc4048ry"
        ],
        "p2sh-segwit": "33XqwwEZdYUj5bjyncxSWybiQTSjF66r2t"
      }
    }
    
  2. andronoob added the label Feature on Jun 26, 2020
  3. willcl-ark commented at 10:41 AM on February 7, 2023: member

    I think this issue should be closed.

    In principle it might sound dangerous but:

    1. The issue comes beforehand. If your program generates a script with an uncompressed key and queries a segwit address from decodescript, aside from the fact it makes no sense to use an RPC for this the issue is not with the RPC but with the logic of your program.
    2. It's not that dangerous; it's not like it's a wallet RPC that may return an unspendable address.
    3. The proposed fix is overkill (and any fix would be i think)
    4. Worst case funds are not completely unspendable, only by standardness rules...

    h/t darosior

  4. pinheadmz assigned achow101 on Apr 27, 2023
  5. achow101 commented at 9:19 PM on April 30, 2023: member

    We generally avoid showing things to users that can result in funds being "stuck", even if technically still valid.

    The feature request didn't seem to attract much attention in the past. Also, the issue seems not important enough right now to keep it sitting around idle in the list of open issues.

    Closing due to lack of interest. Pull requests with improvements are always welcome.

  6. achow101 closed this on Apr 30, 2023

  7. bitcoin locked this on Apr 29, 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: 2026-04-25 00:14 UTC

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