getDecryptedSeed method

Future<Map<String, dynamic>?> getDecryptedSeed(
  1. String? address,
  2. dynamic password
)

Implementation

Future<Map<String, dynamic>?> getDecryptedSeed(
    String? address, password) async {
  final key = Encrypt.passwordToEncryptKey(password);
  final mnemonic = _storage.encryptedMnemonics.val[address];
  if (mnemonic != null) {
    final Map<String, dynamic> res = {
      'type': EVMKeyType.mnemonic.toString().split('.')[1]
    };
    try {
      res['seed'] = await FlutterAesEcbPkcs5.decryptString(mnemonic, key);
    } catch (err) {
      print(err);
    }
    return res;
  }
  final privateKey = _storage.encryptedPrivateKeys.val[address];
  if (privateKey != null) {
    final Map<String, dynamic> res = {
      'type': EVMKeyType.privateKey.toString().split('.')[1]
    };
    try {
      res['seed'] = await FlutterAesEcbPkcs5.decryptString(privateKey, key);
    } catch (err) {
      print(err);
    }
    return res;
  }
  return null;
}