getPrivateKeyFromMnemonic static method

String getPrivateKeyFromMnemonic(
  1. String mnemonic
)

Implementation

static String getPrivateKeyFromMnemonic(String mnemonic) {
  String seed = bip39.mnemonicToSeedHex(mnemonic);
  bip32_bip44.Chain chain = bip32_bip44.Chain.seed(seed);

  bip32_bip44.ExtendedPrivateKey key =
      chain.forPath("m/44'/1237'/0'/0") as bip32_bip44.ExtendedPrivateKey;

  bip32_bip44.ExtendedPrivateKey? childKey =
      bip32_bip44.deriveExtendedPrivateChildKey(key, 0);

  String hexChildKey = "";

  if (childKey.key != null) {
    hexChildKey = childKey.key!.toRadixString(16);
  }

  return hexChildKey;
}