HD Wallet
The MNEE SDK includes a complete BIP32/BIP44 hierarchical deterministic (HD) wallet implementation. This allows you to manage multiple addresses from a single mnemonic seed phrase, perfect for wallet applications and advanced key management.
Setup
import Mnee, { HDWallet } from '@mnee/ts-sdk';
// Initialize MNEE SDK
const mnee = new Mnee({
environment: 'sandbox',
apiKey: 'your-api-key'
});
// For examples below, assume these are already set upStatic Methods
Generate Mnemonic
Generate a new BIP39 mnemonic phrase (12 words).
const mnemonic = HDWallet.generateMnemonic();
console.log('New mnemonic:', mnemonic);
// Output: "abandon abandon abandon ... about"Validate Mnemonic
Check if a mnemonic phrase is valid.
Creating an HD Wallet
Parameters
mnemonic: BIP39 mnemonic phrase (12-24 words)
options:
HDWalletOptionsobjectderivationPath: BIP44 derivation path (e.g.,
"m/44'/236'/0'")cacheSize (optional): Number of derived addresses to cache (default: 1000)
Deriving Addresses
Single Address
Multiple Addresses
Response Structure
Each derived address returns an AddressInfo object:
Getting Private Keys for Addresses
Retrieve private keys for specific addresses by scanning the HD wallet.
With Scan Options
Common Use Cases
Create New Wallet
Restore Wallet from Mnemonic
HD Wallet Send
Address Labeling System
Backup and Recovery
Simplified Private Key Retrieval
The getPrivateKeys method provides a simpler interface for just getting private keys:
Scan Addresses with Gap Limit
Use the BIP44 standard gap limit scanning to find all used addresses:
Cache Management
Best Practices
Security
Never store mnemonics in plain text
Use secure key storage solutions
Implement proper access controls
Clear sensitive data from memory when done
Performance
Use appropriate cache sizes based on your needs
Batch operations when deriving multiple addresses
Scan efficiently using gap limits
Address Management
Follow BIP44 standards for derivation paths
Use separate addresses for each transaction (privacy)
Track address indexes to avoid reuse
Implement gap limit scanning (typically 20)
Derivation Paths
Standard BIP44 path format: m/purpose'/coin'/account'/change/index
Purpose: 44' (BIP44)
Coin: 236' (BSV)
Account: 0' (first account)
Change: 0 (external) or 1 (internal)
Index: Address index (0, 1, 2, ...)
Example paths:
First receive address:
m/44'/236'/0'/0/0First change address:
m/44'/236'/0'/1/010th receive address:
m/44'/236'/0'/0/9
See Also
Transfer Multi - Use HD wallet addresses for transfers
Get UTXOs - Scan HD addresses for UTXOs
Batch Operations - Process many HD addresses efficiently
See Also
Transfer Multi - Use HD wallet addresses for transfers
Get UTXOs - Scan HD addresses for UTXOs
Batch Operations - Process many HD addresses efficiently
Last updated