Skip to content

fix: classify testnet P2SH addresses (prefix '2') as P2SH_P2WPKH#34

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

fix: classify testnet P2SH addresses (prefix '2') as P2SH_P2WPKH#34
Grizouforever wants to merge 1 commit intoentrius:testfrom
Grizouforever:fix/testnet-p2sh-address-type

Conversation

@Grizouforever
Copy link
Copy Markdown

Summary

Fixes #33

Testnet P2SH addresses (prefix 2) are misclassified as P2PKH in detect_address_type(). On mainnet, prefix 3 correctly returns P2SH_P2WPKH, and _to_mainnet_address also correctly identifies 2 as P2SH (version byte 0xC40x05).

Changes

allways/chain_providers/bitcoin.py: Split the testnet condition so 2 returns ADDR_TYPE_P2SH_P2WPKH while m/n continue to return ADDR_TYPE_P2PKH.

Impact

Fixes incorrect signing/verification for testnet P2SH-P2WPKH addresses and correct script type derivation in send_amount_lightweight.

Testnet P2SH addresses with prefix '2' are incorrectly classified
as P2PKH. On mainnet, prefix '3' correctly returns P2SH_P2WPKH,
and _to_mainnet_address also correctly identifies '2' as P2SH
(version byte 0xC4 -> 0x05).

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

Fixes entrius#33
@Grizouforever
Copy link
Copy Markdown
Author

Hi! This PR is ready for review — all 139/139 tests pass locally. It covers several high-impact fixes and I'm happy to walk through any part of it. Let me know if you'd like changes. Thanks!

@Grizouforever Grizouforever changed the base branch from main to test April 11, 2026 19:58
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