changePassword method
change password of account
Implementation
Future<EthWalletData?> changePassword(
KeyringEVM keyring, String passOld, passNew) async {
final acc = keyring.current;
// 1. check old password
final res = await checkPassword(acc, passOld);
if (!res) {
return null;
}
final wallet = Wallet.fromJson(jsonEncode(acc.toJson()), passOld);
final walletNew = Wallet.createNew(
wallet.privateKey, passNew, Random.secure(),
scryptN: crypt_n);
final walletJson = jsonDecode(walletNew.toJson());
final accNew = EthWalletData()
..address = acc.address
..name = acc.name
..memo = acc.memo
..observation = acc.observation
..id = walletJson['id']
..version = walletJson['version']
..crypto = walletJson['crypto'];
// 2. then update encrypted seed in local storage.
keyring.store.updateEncryptedSeed(acc.address, passOld, passNew);
// 3. update keyPair data in storage
keyring.store.updateAccount(accNew.toJson());
return accNew;
}