fix: Ledger P2SH-P2WPKH (m/49') signing rejected by BTC app with 0x6a80#122
Open
mfaizan1 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_DATAat the signing step. The legacy hw-app-btc signer hardcodedadditionals: ["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
getWalletFormatForon an m/-stripped path, misreading the purpose and building awpkh(@0/**)template for m/49' accounts.