importAccountFromMnemonic method

Account? importAccountFromMnemonic(
  1. String phrase,
  2. int index
)

Implementation

Account? importAccountFromMnemonic(String phrase, int index) {
  if (!this.isValidMnemonic(phrase)) {
    throw 'Invalid mnemonic phrase: ${phrase}';
  }
  final seed = bip39.mnemonicToSeed(phrase);
  final hdKey = bip32.BIP32.fromSeed(seed);
  final rootString = "m/44'/313'/0'/0/$index";
  final childKey = hdKey.derivePath(rootString);
  String prvKeys = numbers.bytesToHex(childKey.privateKey!);
  var account = Account(prvKeys);
  return this.add(account);
}