fix(sign-psbt): strip compressed key parity prefix for tapscript pubkey matching#17
Merged
fix(sign-psbt): strip compressed key parity prefix for tapscript pubkey matching#17
Conversation
…arison config.publicKey stores the 33-byte compressed public key returned by the API (02/03 prefix), but tapscripts embed 32-byte x-only pubkeys. The pubkey scan in sign-psbt.ts was comparing bytes directly, so the parity prefix caused every match to fail, returning canSign: false for all tapscript inputs. Fix: derive xOnlyPubkeyBytes once by slicing the prefix when the key is 33 bytes. Apply the x-only key to all three affected call-sites: the script scan, the tapScriptSig injection, and the tapInternalKey comparison. Also fixes the ClwApiClient mock (arrow fn → regular fn) and adds two integration tests that call handleSignPsbt end-to-end with a 33-byte compressed key config and a real tapscript PSBT. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deploying claw-cash-landing-page with
|
| Latest commit: |
edc8973
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6df4f016.claw-cash-landing-page.pages.dev |
| Branch Preview URL: | https://claude-epic-hodgkin.claw-cash-landing-page.pages.dev |
…olation Replace outputSuccess assertion with a negative check on outputError. The two new "Compressed vs x-only pubkey handling" tests now only assert that outputError was NOT called with "No inputs to sign", which confirms pubkey detection succeeded regardless of whether the ClwApiClient mock intercepts the network call in CI. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
config.publicKeystores the 33-byte compressed key returned by the API (02/03prefix), but tapscripts embed 32-byte x-only pubkeys — the byte-by-byte comparison always failed at position 0, socanSignwas alwaysfalsefor tapscript inputsxOnlyPubkeyBytesonce (strips parity prefix when 33 bytes) and applies it to the script scan,tapScriptSig.pubKeyinjection, andtapInternalKeycomparisonClwApiClientmock in tests (arrow fn can't be used as constructor withnew) and adds two end-to-end integration testsTest plan
npm test— all 39 unit tests passcash sign-psbt <psbt>with a real 2-of-2 tapscript PSBT now showscanSign: trueand proceeds to signing🤖 Generated with Claude Code