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 StateError('Keystore file is not found.');
      }
    }
    final phrase = await decodePhrase(jsonDecode(_keystore!), passphrase);
    final newIcp = await ICPAccount.fromPhrase(
      phrase,
      index: 0,
      curveType: curveType,
    );
    _phrase = phrase;
    _ecKeys = newIcp._ecKeys;
    _identity = newIcp._identity;
    _ecIdentity = newIcp._ecIdentity;
    newIcp._ecKeys = null;
    newIcp._identity = null;
  } finally {
    isLocked = false;
  }
}