hd_wallet_kit
A Flutter HD Wallet package which provides implementation of:
- Hierarchical Deterministic Wallets BIP32,
- Mnemonic code for generating deterministic keys BIP39,
- and Multi-Account Hierarchy for Deterministic Wallets BIP44.
Inspired by hd-wallet-kit-android
Features
Mnemonic
- Generate mnemonic
- From mnemonic to seed
- From mnemonic to entropy
- Validate mnemonic
HD Wallet
- Create HD wallet from seed
- Key derivation by path
- Key derivation by purpose, coinType, account, change, and index.
- Key serialization
Support wordlists
- English
- Japanese
- Korean
- Spanish
- Chinese (Simplified)
- Chinese (Traditional)
- French
- Italian
- Czech
- Portuguese
Getting started
To use this plugin, add hd_wallet_kit
as a dependency in your pubspec.yaml file.
Usage
Generate mnemonic:
final mnemonic = Mnemonic.generate();
From mnemonic to seed:
final seed = Mnemonic.toSeed(mnemonic);
Create hd wallet from seed:
final hdWallet = HDWallet.fromSeed(seed: seed);
Key derivation:
final key = hdWallet.deriveChildKeyByPath("m/0");
final bip44Key = hdWallet.deriveChildKey(purpose: Purpose.BIP44, coinType: 0, account: 0, change: 0, index: 0);
Key serialization:
final key = hdWallet.deriveChildKey(purpose: Purpose.BIP44, coinType: 0, account: 0, change: 0, index: 0);
final accountExtendedPubKey = key.serializePublic(HDExtendedKeyVersion.xpub);
final accountExtendedPrivKey = key.serializePublic(HDExtendedKeyVersion.xprv);
Encode address:
final key = hdWallet.deriveChildKey(purpose: Purpose.BIP44, coinType: 0, account: 0, change: 0, index: 0);
final address = key.encodeAddress();