-
Notifications
You must be signed in to change notification settings - Fork 42
fix: properly serialize Solana transactions with empty signature placeholders #2089
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
broody
wants to merge
4
commits into
main
Choose a base branch
from
fix/phantom-transaction-serialization
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
…eholders When serializing unsigned Solana transactions for Phantom wallet, the previous implementation used `sol.createTxComplex()` which returned a hex string that didn't include proper signature slots. This caused Phantom to throw "Reader(signatures/0): readBytes: Unexpected end of buffer" when trying to deserialize the transaction. The fix creates a properly formatted transaction structure with: - A message containing feePayer, instructions, and recentBlockhash - Empty 64-byte signature placeholders for all required signers - Proper encoding using sol.Transaction.encode() This ensures Phantom can successfully deserialize and sign the transaction. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
The previous fix incorrectly assumed createTxComplex returned hex, but it actually returns a base64-encoded transaction string that already includes properly formatted empty signatures. micro-sol-signer's signature format is an object/map where keys are signer addresses and values are 64-byte signature buffers, not an array. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Fixed Transaction.serialize() in both controller and keychain packages to properly decode base64-encoded strings from micro-sol-signer's createTxComplex() function. Previously used hex decoding which resulted in truncated/corrupted transaction data (45 bytes instead of expected 200+), causing "Unexpected end of buffer" errors in Phantom wallet integration. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| Array.from(buffer.slice(0, 32)), | ||
| ); | ||
|
|
||
| return buffer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Unintended Debug Logs in Production Code
Multiple debugging console.log statements were accidentally committed. These logs will clutter production output and may expose sensitive transaction details or internal state.
Additional Locations (2)
kmk142789
approved these changes
Oct 11, 2025
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
Fixes the Solana/Phantom purchase flow error:
Reader(signatures/0): readBytes: Unexpected end of bufferWhen serializing unsigned Solana transactions for Phantom wallet, the previous implementation used
sol.createTxComplex()which returned a hex string that didn't include proper signature slots. This caused Phantom to throw a deserialization error when trying to parse the transaction.Changes
Updated
packages/controller/src/utils/solana/index.ts:serialize()method to properly format transactions with empty signature placeholderssol.Transaction.encode()This ensures Phantom can successfully deserialize and sign the transaction.
Test Plan
🤖 Generated with Claude Code
Note
Switch transaction serialization from hex to base64 across Solana utils and add detailed debug logging, improving Phantom transaction deserialization/sending.
packages/controller/src/utils/solana/index.ts:Transaction.serialize()to handle base64 fromcreateTxComplex, decoding to bytes; re-encode when_transactionexists; add detailed debug logs.packages/keychain/src/utils/solana/index.ts:Transaction.serialize()to decode base64 fromcreateTxComplextoUint8Array; add debug logs.packages/controller/src/wallets/phantom/index.ts:sendTransaction()with pre/post deserialization logging usingTransaction.from()and providersignAndSendTransaction().Written by Cursor Bugbot for commit faf2f19. This will update automatically on new commits. Configure here.