This implementation adds comprehensive support for Stellar muxed addresses (M...) and federated addresses (name*domain) across the dashboard.
Added new functions to handle multiple address formats:
New Functions:
-
isValidEd25519PublicKey(key)- Validates G... Ed25519 keys -
isValidMuxedAccount(key)- Validates M... muxed accounts -
isFederatedAddress(input)- Validates name*domain federated addresses -
parseMuxedAccount(muxedAddress)- Extracts master account and muxed ID from M... addresses -
resolveFederatedAddress(federatedAddress, network)- Resolves federated addresses via Horizon federation endpoint -
resolveAddress(input, network)- Universal address resolver that:- Accepts G..., M..., or name*domain formats
- Returns resolved account info with metadata
- Returns
ResolvedAddressinterface containing:accountId: The master account (always G...)muxedId: Muxed ID if input was M...inputType: 'ed25519' | 'muxed' | 'federated'federatedAddress: Original federated address if applicablememoId/memoType: From federation resolution
-
isValidPublicKey(key)- Updated to accept all three formats (backward compatible)
Exported Types:
ResolvedAddressinterface for type-safe address resolution results
Enhanced validateStellarAddress() to support all three address formats:
- Added regex patterns for M... and name*domain validation
- Updated error message to reflect supported formats
- Maintains backward compatibility
- Imported
resolveAddressfunction - Added
AddressInfointerface to track resolved address metadata - Updated placeholder text to show all supported formats: "G... public key, M... muxed, or name*domain"
- Updated error messages to mention all supported formats
- Added address resolution step before fetching account data
- Displays master account, muxed ID, and federated address info when applicable
- Shows resolved address information below input field with cyan styling
UI Enhancements:
- Added visual display of muxed ID when applicable
- Added visual display of federated address when applicable
- Improved placeholder text: "G... public key, M... muxed, or name*domain"
- Descriptive subtitle: "Enter a Stellar address: G... • M... • name*domain"
- Updated placeholder text: "G... public key, M... muxed, or name*domain federated"
- Updated error message to reflect all supported formats
- Validation now uses enhanced
isValidPublicKey()function
- Imported
resolveAddressfunction - Updated
handleFetch()to:- Resolve addresses before fetching account data
- Store muxed ID and federated address info with account data
- Use master account for data fetching
- Graceful error handling for unresolvable addresses
✅ Muxed Account Support (M...)
- Validates M... muxed addresses
- Extracts and displays muxed ID alongside master account
- Loads underlying account data for the master account
- Works with ConnectPanel, AddressBook, and AccountComparison
✅ Federated Address Support (name*domain)
- Validates federated address format
- Resolves via Horizon federation endpoint with fallback logic
- Caches federation lookup results
- Handles TOML-based federation server configuration
- Works across all address input components
✅ Backward Compatibility
- All existing code using
isValidPublicKey()continues to work - G... addresses work exactly as before
- No breaking changes to existing APIs
✅ User Experience
- Clear error messages explaining supported formats
- Visual display of resolved address components (master account, muxed ID, federated address)
- Consistent validation across all address input fields
- Improved placeholder text at all input points
Federation Resolution:
- Fetches stellar.toml from domain
- Parses FEDERATION_SERVER URL from TOML
- Falls back to Horizon federation endpoint if TOML lookup fails
- Returns account ID and optional memo information
Address Resolution Flow:
- Check if Ed25519 public key (G...)
- Check if muxed account (M...)
- Check if federated address (name*domain)
- For muxed: Extract master account and muxed ID
- For federated: Resolve via federation endpoint
- Return normalized result with metadata
✅ Valid M... or user*example.com connects and loads underlying account data ✅ UI shows both muxed ID and master G-address where applicable ✅ Federated resolution works via stellar.toml / Horizon federation endpoint ✅ All three address formats work across ConnectPanel, AddressBook, and AccountComparison
Unit tests created in tests/unit/stellar-addresses.test.js:
- Ed25519 validation (G...)
- Muxed account validation (M...)
- Federated address validation
- Muxed account parsing
- Universal address validation
- Address resolution
/src/lib/stellar.ts- Added address resolution functions/src/lib/validation.ts- Enhanced address validation/src/components/dashboard/ConnectPanel.tsx- Added address resolution UI/src/components/preferences/AddressBook.jsx- Updated validation and placeholders/src/components/dashboard/AccountComparison.jsx- Added address resolution support/tests/unit/stellar-addresses.test.js- New test suite (created)