Overview
This guide shows you how to import existing Bitcoin private keys into Dynamic’s MPC wallet system. This is useful when migrating from traditional Bitcoin wallets or integrating with existing systems.Prerequisites
- Set up your Dynamic project
- Have your existing Bitcoin private key ready in WIF format
WIF Format
Bitcoin private keys are imported in WIF (Wallet Import Format). WIF is a base58-encoded format that includes:- Network identifier (mainnet or testnet)
- The 32-byte private key
- Compression flag
- Checksum
- Mainnet compressed:
L...orK...(52 characters) - Testnet compressed:
c...(52 characters)
Supported Address Types
When importing a private key, you must specify the address type. Currently supported:- Native SegWit (P2WPKH):
BitcoinAddressType.NATIVE_SEGWIT - Taproot (P2TR):
BitcoinAddressType.TAPROOT
Import Your Bitcoin Private Key
wallet.walletMetadata. You pass it to signMessage, signTransaction and exportPrivateKey. Read the private key from a secret store or an environment variable, and never hard-code it.
Import with Different Address Types
Native SegWit
Taproot
Export Private Key
You can export an imported wallet’s private key back to WIF format:exportPrivateKey returns the key in mainnet WIF format (starting with K or L), including for a wallet you use on testnet. Treat the exported key as highly sensitive and don’t log it.Offline Export
If you need to export the private key from existing key shares without a network call, useofflineExportPrivateKey():
Error Handling
The SDK supports both Bitcoin Mainnet and Testnet. Use
BitcoinNetwork.MAINNET for production and BitcoinNetwork.TESTNET for development and testing.Security Considerations
- Private Key Format: Ensure your private key is in valid WIF format
- Password Security: Use a strong, unique password
- Key Storage: Never store private keys in plain text after import
- Backup: Ensure you have a secure backup of your original private key
- Key Share Backup: Use
backUpToDynamic: truefor secure key share storage
Threshold Signature Schemes
Choose based on your security and availability needs:TWO_OF_TWO: Maximum security, requires both server and DynamicTWO_OF_THREE: Balanced security and availability