Skip to content

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

@Grizouforever

Description

@Grizouforever

Description

In detect_address_type(), testnet P2SH addresses (prefix 2) are grouped with m/n prefixes and return ADDR_TYPE_P2PKH. On mainnet, prefix 3 correctly returns ADDR_TYPE_P2SH_P2WPKH (line 27), but the testnet equivalent 2 is misclassified.

The companion function _to_mainnet_address (line 58-61) correctly identifies 2-prefix as P2SH (converts version byte 0xC4 to 0x05), confirming the intended type.

Impact

On testnet/regtest, signing or verifying messages for P2SH-P2WPKH addresses uses the wrong type, producing invalid signatures. Also affects send_amount_lightweight which derives the script type from detect_address_type.

Fix

Split the condition so 2 returns ADDR_TYPE_P2SH_P2WPKH while m/n continue to return ADDR_TYPE_P2PKH.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions