unlock method

Future<void> unlock(
  1. String passphrase, {
  2. String? keystore,
})

Implementation

Future<void> unlock(String passphrase, {String? keystore}) async {
  try {
    if ((_keystore == null)) {
      if (keystore != null) {
        _keystore = keystore;
      } else {
        throw "keystore file is not found";
      }
    }
    final phrase = await decodePhrase(
      jsonDecode(_keystore!),
      passphrase,
    );
    var newIcp = ICPAccount.fromPhrase(
      phrase,
      index: 0,
      icPath: IC_BASE_PATH,
      curveType: _curveType,
    );
    _phrase = phrase;
    _ecKeys = newIcp._ecKeys;
    _identity = newIcp._identity;
    _ecIdentity = newIcp._ecIdentity;
    newIcp._ecKeys = null;
    newIcp._identity = null;
    isLocked = false;
  } catch (e) {
    throw "Cannot unlock account with password $passphrase "
        "and keystore $_keystore";
  }
}