Skip to content

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

@andronoob

Description

@andronoob

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"
  }
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions