fix: properly serialize Solana transactions with empty signature placeholders#2089
Open
fix: properly serialize Solana transactions with empty signature placeholders#2089
Conversation
…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 <noreply@anthropic.com>
|
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
| Array.from(buffer.slice(0, 32)), | ||
| ); | ||
|
|
||
| return buffer; |
There was a problem hiding this comment.
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)
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
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.