fromPrivateKey static method

Future<Account> fromPrivateKey(
  1. String privateKey, {
  2. String? name,
  3. AccountType accountType = AccountType.single,
})

Load an existing account from a private key. Private key is a hexadecimal representation of the seed.

Throws UnsupportedError if seeds are unsupported.

Implementation

static Future<Account> fromPrivateKey(
  String privateKey, {
  String? name,
  AccountType accountType = AccountType.single,
}) async {
  // TODO Derive the seed from the private key
  final keyPair = await Ed25519().newKeyPairFromSeed(hex.decode(privateKey));
  final publicKey = await keyPair.extractPublicKey();
  final account = Account._create(
    publicKey: publicKey,
    keyPair: keyPair,
    name: name,
    accountType: accountType,
  );

  return account;
}