Wallet Integration
How the BSV TypeScript SDK connects with Bitcoin wallets and manages user authentication.
Wallet Connection Model
The SDK uses a standardized approach to connect with Bitcoin wallets:
import { WalletClient } from '@bsv/sdk'
// Connect to a wallet
const wallet = new WalletClient('https://wallet-url')
// Authenticate with the wallet
await wallet.authenticate()
BRC-100 Compliance
The SDK follows the BRC-100 standard for wallet communication:
- Standardized APIs: Consistent interface across different wallets
- Authentication: Secure identity verification
- Transaction Signing: Wallet handles private key operations
- UTXO Management: Wallet manages available funds
Authentication Flow
- Connection: Establish connection to wallet service
- Identity: Wallet provides user identity information
- Capabilities: Discover what the wallet can do
- Authorization: User grants permission for specific operations
Transaction Creation
The wallet handles sensitive operations:
// Create a transaction action
const action = await wallet.createAction({
description: 'Payment transaction',
outputs: [{
satoshis: 1000,
lockingScript: recipientScript
}]
})
// Wallet signs and broadcasts automatically
Key Benefits
Security
- Private keys never leave the wallet
- User controls transaction approval
- Secure authentication protocols
User Experience
- Familiar wallet interface
- Consistent across applications
- Single sign-on capabilities
Developer Simplicity
- No key management complexity
- Standardized APIs
- Automatic UTXO handling
Wallet Types
The SDK works with various wallet implementations:
- Desktop Wallets: Local applications with full control
- Web Wallets: Browser-based wallet services
- Mobile Wallets: Smartphone applications
- Hardware Wallets: Secure hardware devices
Error Handling
Common wallet integration scenarios:
- Wallet not available or offline
- User denies transaction approval
- Insufficient funds in wallet
- Network connectivity issues
Best Practices
- Always handle wallet connection failures gracefully
- Provide clear transaction descriptions to users
- Implement retry logic for network issues
- Cache wallet capabilities to improve performance
Next Steps