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.
Description
In
detect_address_type(), testnet P2SH addresses (prefix2) are grouped withm/nprefixes and returnADDR_TYPE_P2PKH. On mainnet, prefix3correctly returnsADDR_TYPE_P2SH_P2WPKH(line 27), but the testnet equivalent2is misclassified.The companion function
_to_mainnet_address(line 58-61) correctly identifies2-prefix as P2SH (converts version byte0xC4to0x05), 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_lightweightwhich derives the script type fromdetect_address_type.Fix
Split the condition so
2returnsADDR_TYPE_P2SH_P2WPKHwhilem/ncontinue to returnADDR_TYPE_P2PKH.