Overview
This guide walks you through creating Bitcoin wallets using Dynamic’s Node SDK. You’ll learn how to set up different threshold signature schemes, choose address types, and understand the security implications for Bitcoin blockchain operations.Prerequisites
Before you begin, make sure you have:Step 1: Choose Your Security Model
Dynamic supports two threshold signature schemes for Bitcoin wallets:TWO_OF_TWO (Recommended for most use cases)
- Security: Highest, requiring both your server and Dynamic’s infrastructure
- Availability: Lower, because both parties must be online
- Use case: High-value transactions, maximum security
TWO_OF_THREE
- Security: High, requiring 2 out of 3 shares
- Availability: Medium, because it can tolerate one party being offline
- Use case: Balanced security and availability
Step 2: Choose Your Address Type
Bitcoin supports multiple address types:Native SegWit (P2WPKH)
- Prefix:
bc1q... - Algorithm: ECDSA
- Benefits: Lower transaction fees, widely supported
- Use case: General purpose, most applications (recommended)
Taproot (P2TR)
- Prefix:
bc1p... - Algorithm: Schnorr (BIP-340)
- Benefits: Enhanced privacy, smart contract capabilities
- Use case: Advanced applications, privacy-focused
Step 3: Create Your First Bitcoin Wallet
Here’s a complete example of creating a Bitcoin wallet:A
password is required when backUpToDynamic is true. You need the same password for every later signing or export call.walletMetadata.accountAddress is always the wallet’s mainnet address (bc1q... or bc1p...), even if you plan to use the wallet on testnet. Keep the full walletMetadata object: you pass it to signMessage, signTransaction and exportPrivateKey. To get the testnet address, see Step 6.Step 4: Handle Errors Gracefully
Always implement proper error handling for Bitcoin wallet creation:Step 5: Store Wallet Information Securely
After creating a Bitcoin wallet, you’ll receive important information that should be stored securely:walletMetadata object, not only the address. Signing needs its derivation path and address type.
Step 6: Derive the Bitcoin Address
UsederiveAccountAddress() to get the address for a specific network from the wallet’s public key. The network parameter is required:
Best Practices
- Password Security: Use strong, unique passwords for each Bitcoin wallet
- Error Handling: Always handle potential errors during wallet creation with the
onErrorcallback - Monitoring: Log wallet creation events for audit purposes
- Backup Strategy: Implement secure backup strategies for key shares with
backUpToDynamic: true - Address Type Selection: Choose Native SegWit for most use cases; use Taproot for advanced privacy needs
Bitcoin-Specific Considerations
Address Type Selection
Network Support
The SDK supports both Bitcoin Mainnet and Testnet. Use
BitcoinNetwork.MAINNET for production and BitcoinNetwork.TESTNET for development and testing.You choose the network per call: signMessage, signTransaction and deriveAccountAddress all require a network argument. Creating a wallet does not depend on the network. See Working with testnet.Satoshis
Bitcoin uses satoshis as the smallest unit:1 BTC = 100,000,000 satoshis.