Skip to content

fix: Ledger P2SH-P2WPKH (m/49') signing rejected by BTC app with 0x6a80#122

Open
mfaizan1 wants to merge 1 commit into
swapkit:developfrom
mfaizan1:bug-ledger-with-segwit-p2sh-p2wpkh-appears-broken-eng-2592
Open

fix: Ledger P2SH-P2WPKH (m/49') signing rejected by BTC app with 0x6a80#122
mfaizan1 wants to merge 1 commit into
swapkit:developfrom
mfaizan1:bug-ledger-with-segwit-p2sh-p2wpkh-appears-broken-eng-2592

Conversation

@mfaizan1

Copy link
Copy Markdown
Contributor

https://linear.app/thorswap/issue/ENG-2592/bug-ledger-with-segwit-p2sh-p2wpkh-appears-broken

Ledger BTC sends from a Segwit (m/49', P2SH-P2WPKH) derivation path always failed with 0x6a80 INCORRECT_DATA at the signing step. The legacy hw-app-btc signer hardcoded additionals: ["bech32"] + segwit: true, telling the device to sign under a native-segwit (wpkh) policy that doesn't match the m/49' key origin. Both UTXO signers now derive the policy flags from the path's purpose segment (m/84' → wpkh, m/49' → sh(wpkh), m/44' → pkh); chain-specific overrides (BCH/DOGE/DASH/ZEC) are unaffected.

Extra: fixed the PSBT client's wallet-format detection — it called getWalletFormatFor on an m/-stripped path, misreading the purpose and building a wpkh(@0/**) template for m/49' accounts.

The legacy hw-app-btc signer hardcoded additionals ["bech32"] + segwit
for every path, and the PSBT client misdetected the wallet format on
m/-stripped paths, so m/49' (P2SH-P2WPKH) transactions were signed under
a native-segwit (wpkh) policy and the Ledger BTC app rejected them with
0x6a80 INCORRECT_DATA. Both signers now derive the policy from the
path's purpose segment.
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.

1 participant