Skip to content

Conversation

@broody
Copy link
Contributor

@broody broody commented Oct 2, 2025

Summary

Fixes the Solana/Phantom purchase flow error: Reader(signatures/0): readBytes: Unexpected end of buffer

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 a deserialization error when trying to parse the transaction.

Changes

Updated packages/controller/src/utils/solana/index.ts:

  • Modified the serialize() method to properly format transactions with empty signature placeholders
  • Collects all unique signers (feePayer + instruction signers)
  • Creates 64-byte empty signature placeholders for each signer
  • Encodes the complete transaction structure using sol.Transaction.encode()

This ensures Phantom can successfully deserialize and sign the transaction.

Test Plan

  • Test starter pack purchase flow with Phantom wallet on Solana devnet
  • Verify transaction is properly deserialized by Phantom
  • Confirm transaction can be signed and submitted successfully

🤖 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.

  • Solana utils:
    • packages/controller/src/utils/solana/index.ts:
      • Update Transaction.serialize() to handle base64 from createTxComplex, decoding to bytes; re-encode when _transaction exists; add detailed debug logs.
    • packages/keychain/src/utils/solana/index.ts:
      • Update Transaction.serialize() to decode base64 from createTxComplex to Uint8Array; add debug logs.
  • Wallets:
    • packages/controller/src/wallets/phantom/index.ts:
      • Enhance sendTransaction() with pre/post deserialization logging using Transaction.from() and provider signAndSendTransaction().

Written by Cursor Bugbot for commit faf2f19. This will update automatically on new commits. Configure here.

…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]>
@vercel
Copy link

vercel bot commented Oct 2, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
controller-example-next Ready Ready Preview Oct 2, 2025 8:17pm
controller-example-next-compat Ready Ready Preview Oct 2, 2025 8:17pm
keychain Ready Ready Preview Oct 2, 2025 8:17pm
keychain-storybook Ready Ready Preview Oct 2, 2025 8:17pm

cursor[bot]

This comment was marked as outdated.

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]>
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

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;
Copy link

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)

Fix in Cursor Fix in Web

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.

3 participants