mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-24 11:36:21 +00:00
feat: refactor restore process to streamline decryption and remove isEncrypted field
This commit is contained in:
parent
62d0d1a574
commit
17ba365463
2 changed files with 10 additions and 17 deletions
|
@ -54,22 +54,19 @@ class RestoreFromKeystonePrivateModePage extends BasePage {
|
|||
|
||||
final restoreJson = json.decode(code);
|
||||
|
||||
final cipherPrimaryAddress = Uint8List.fromList(
|
||||
Hex.HEX.decode(restoreJson['primaryAddress'] as String));
|
||||
restoreJson['primaryAddress'] = await _decryptData(
|
||||
Uint8List.fromList(
|
||||
Hex.HEX.decode(restoreJson['primaryAddress'] as String)),
|
||||
secretKey);
|
||||
|
||||
restoreJson['primaryAddress'] =
|
||||
await _decryptData(cipherPrimaryAddress, secretKey);
|
||||
|
||||
final cipherPrivateViewKey = Uint8List.fromList(
|
||||
Hex.HEX.decode(restoreJson['privateViewKey'] as String));
|
||||
|
||||
restoreJson['privateViewKey'] =
|
||||
await _decryptData(cipherPrivateViewKey, secretKey);
|
||||
restoreJson['privateViewKey'] = await _decryptData(
|
||||
Uint8List.fromList(
|
||||
Hex.HEX.decode(restoreJson['privateViewKey'] as String)),
|
||||
secretKey);
|
||||
|
||||
final res = json.encode(restoreJson);
|
||||
print(res);
|
||||
Navigator.of(context).pop(res);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
pinCodeStateKey.currentState?.reset();
|
||||
showBar<void>(
|
||||
context,
|
||||
|
|
|
@ -18,8 +18,7 @@ class RestoredWallet {
|
|||
this.recipientName,
|
||||
this.height,
|
||||
this.privateKey,
|
||||
this.source,
|
||||
this.isEncrypted = false});
|
||||
this.source});
|
||||
|
||||
final WalletRestoreMode restoreMode;
|
||||
final WalletType type;
|
||||
|
@ -35,7 +34,6 @@ class RestoredWallet {
|
|||
final int? height;
|
||||
final String? privateKey;
|
||||
final String? source;
|
||||
final bool? isEncrypted;
|
||||
|
||||
factory RestoredWallet.fromKey(Map<String, dynamic> json) {
|
||||
try {
|
||||
|
@ -45,7 +43,6 @@ class RestoredWallet {
|
|||
json['view_key'] = codeParsed["privateViewKey"];
|
||||
json['height'] = codeParsed["restoreHeight"].toString();
|
||||
json['source'] = codeParsed["source"] ?? '';
|
||||
json['encrypted'] = codeParsed["encrypted"] ?? false;
|
||||
}
|
||||
} catch (e) {
|
||||
// fine, we don't care, it is only for monero anyway
|
||||
|
@ -60,7 +57,6 @@ class RestoredWallet {
|
|||
height: height != null ? int.tryParse(height)??0 : 0,
|
||||
privateKey: json['private_key'] as String?,
|
||||
source: json['source'] as String?,
|
||||
isEncrypted: json['encrypted'] as bool? ?? false,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue