Skip to content

feat(sdk-coin-sol): implement deriveAddress for SOL#9016

Merged
rajangarg047 merged 1 commit into
masterfrom
rajangarg047/wcn-917-sol-derive-address
Jun 16, 2026
Merged

feat(sdk-coin-sol): implement deriveAddress for SOL#9016
rajangarg047 merged 1 commit into
masterfrom
rajangarg047/wcn-917-sol-derive-address

Conversation

@rajangarg047

Copy link
Copy Markdown
Contributor

Summary

Implements deriveAddress for SOL (Stage A — MPC/TSS), overriding the BaseCoin default. It locally derives a Solana receive address from the wallet's commonKeychain + index, reusing the shared deriveMPCWalletAddress (ed25519) helper. Offline and key-material-free (public keys only); supports the SMC prefix path via derivedFromParentWithSeed.

This is the inverse of isWalletAddress and shares its exact derivation path (deriveMPCWalletAddress), so derive and verify can never diverge.

Context

Part of FR-465 (Bullish local address derivation), Phase 1 Stage A. Builds only on the already-merged primitive (WCN-912) and shared MPC engine (WCN-913) — independent of the Express endpoint (WCN-914) and the other coin PRs.

Test plan

  • tsc --noEmit clean for sdk-coin-sol
  • eslint clean (0 errors)
  • 5 new deriveAddress unit tests pass: exact-vector derivation, distinct address per index, derive→verify round-trip, SMC-seed round-trip, and missing-keychains error. Reuses the existing isWalletAddress test vector.
  • CI

🤖 Generated with Claude Code

Override BaseCoin.deriveAddress on the Sol coin to locally derive a receive
address from the wallet's commonKeychain + index, reusing the shared
deriveMPCWalletAddress (ed25519) helper. This is the inverse of isWalletAddress
and shares its exact derivation path, so derive and verify can never diverge.

Offline and key-material-free (public keys only). Supports the SMC prefix path
via derivedFromParentWithSeed.

Adds unit coverage including a derive->verify round-trip and an SMC-seed case.

WCN-917

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@rajangarg047 rajangarg047 requested a review from a team as a code owner June 12, 2026 19:46
@linear-code

linear-code Bot commented Jun 12, 2026

Copy link
Copy Markdown

WCN-917

@rajangarg047 rajangarg047 marked this pull request as draft June 12, 2026 19:47
@rajangarg047 rajangarg047 marked this pull request as ready for review June 15, 2026 18:15
@rajangarg047

Copy link
Copy Markdown
Contributor Author

@claude

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Claude finished @rajangarg047's task —— View job


Code Review Complete ✅

  • Read repository guidelines (CLAUDE.md)
  • Review implementation in sol.ts
  • Review test coverage in sol.ts test file
  • Check code quality and best practices
  • Provide comprehensive feedback

Summary

This PR successfully implements deriveAddress for SOL (Solana), providing local address derivation from wallet keychains. The implementation is well-structured and follows BitGoJS patterns.

✅ Strengths

  1. Excellent Documentation: The method includes comprehensive JSDoc explaining its purpose, relationship to isWalletAddress, and guarantees about derivation consistency.

  2. Proper Integration: Correctly imports and uses the shared deriveMPCWalletAddress helper from @bitgo/sdk-core, maintaining consistency with the existing codebase architecture.

  3. Complete Test Coverage: The test suite includes 5 comprehensive scenarios:

    • Exact vector derivation test using known commonKeychain → address
    • Different indices produce different addresses
    • Critical round-trip test: derive → verify ensures the methods never diverge
    • SMC seed support with round-trip verification
    • Error handling for missing keychains
  4. Type Safety: Proper TypeScript usage with correct imports of DeriveAddressOptions and DeriveAddressResult interfaces.

  5. Consistent with Existing Code: Reuses the existing getAddressFromPublicKey helper, maintaining the same conversion logic used elsewhere.

🔍 Implementation Details

The implementation at modules/sdk-coin-sol/src/sol.ts:728-742 is concise and correct:

  • Uses deriveMPCWalletAddress with proper parameters including keyCurve: 'ed25519'
  • Delegates address conversion to existing getAddressFromPublicKey method
  • Returns the expected DeriveAddressResult format
  • Handles both regular derivation and SMC seed-based derivation

⚠️ Minor Observations

  1. Runtime Validation: The comment mentions "extractCommonKeychain validates the commonKeychain is present at runtime" but this validation happens within deriveMPCWalletAddress, which is correct.

  2. Error Propagation: The implementation correctly lets deriveMPCWalletAddress handle validation and error cases, maintaining consistency with the shared helper's error handling.

🎯 Architecture Alignment

This implementation perfectly aligns with the stated goal of being "the inverse of isWalletAddress" by:

  • Using identical derivation paths (deriveMPCWalletAddress is shared)
  • Using the same getAddressFromPublicKey conversion
  • Supporting the same SMC seed functionality

The round-trip test in the test suite validates this guarantee, ensuring the two methods can never diverge.

Recommendation: ✅ APPROVE

This is a well-implemented, thoroughly tested feature that correctly integrates with the existing BitGoJS architecture. The code follows repository conventions, includes proper documentation, and maintains consistency with existing patterns.

@rajangarg047 rajangarg047 merged commit 7f4bec1 into master Jun 16, 2026
22 checks passed
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.

2 participants