Skip to content

fix: classify testnet P2SH addresses (prefix '2') as P2SH-P2WPKH#42

Open
t7929375-eng wants to merge 1 commit intoentrius:testfrom
t7929375-eng:fix/testnet-p2sh-address-type
Open

fix: classify testnet P2SH addresses (prefix '2') as P2SH-P2WPKH#42
t7929375-eng wants to merge 1 commit intoentrius:testfrom
t7929375-eng:fix/testnet-p2sh-address-type

Conversation

@t7929375-eng
Copy link
Copy Markdown

Summary

Testnet addresses starting with 2 (e.g., 2N5kNSL...) are P2SH-P2WPKH addresses, but detect_address_type() incorrectly classifies them as P2PKH because they fall through the same branch as m/n prefixes.

This fix separates the prefix 2 check to return ADDR_TYPE_P2SH_P2WPKH, keeping m/n as P2PKH.

Related Issues

Fixes #33

Type of Change

  • Bug fix

Testing

  • Added 3 unit tests covering testnet P2SH (2), P2PKH (m), and P2PKH (n) prefixes
  • All existing tests pass

Checklist

  • Code follows project style guidelines
  • Self-review completed

cc @anderdc @LandynDev

The '2' prefix was grouped with 'm'/'n' (P2PKH) but _to_mainnet_address
already treats it as P2SH (version byte 0xC4 → 0x05). Split the
condition so '2' returns ADDR_TYPE_P2SH_P2WPKH.

Fixes entrius#33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Testnet P2SH addresses (prefix '2') misclassified as P2PKH

1 participant