Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
andronoob opened this issue Jun 26, 2020 · 2 comments
Assignees
Labels

Comments

@andronoob
Copy link

andronoob commented Jun 26, 2020

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

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

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

Describe alternatives you've considered

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

Additional context

bitcoinjs/bitcoinjs-lib#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"
  }
}
@willcl-ark
Copy link
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

@achow101
Copy link
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.

@achow101 achow101 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 30, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
@achow101 @andronoob @willcl-ark and others