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 restoreJson = json.decode(code);
|
||||||
|
|
||||||
final cipherPrimaryAddress = Uint8List.fromList(
|
restoreJson['primaryAddress'] = await _decryptData(
|
||||||
Hex.HEX.decode(restoreJson['primaryAddress'] as String));
|
Uint8List.fromList(
|
||||||
|
Hex.HEX.decode(restoreJson['primaryAddress'] as String)),
|
||||||
|
secretKey);
|
||||||
|
|
||||||
restoreJson['primaryAddress'] =
|
restoreJson['privateViewKey'] = await _decryptData(
|
||||||
await _decryptData(cipherPrimaryAddress, secretKey);
|
Uint8List.fromList(
|
||||||
|
Hex.HEX.decode(restoreJson['privateViewKey'] as String)),
|
||||||
final cipherPrivateViewKey = Uint8List.fromList(
|
secretKey);
|
||||||
Hex.HEX.decode(restoreJson['privateViewKey'] as String));
|
|
||||||
|
|
||||||
restoreJson['privateViewKey'] =
|
|
||||||
await _decryptData(cipherPrivateViewKey, secretKey);
|
|
||||||
|
|
||||||
final res = json.encode(restoreJson);
|
final res = json.encode(restoreJson);
|
||||||
print(res);
|
|
||||||
Navigator.of(context).pop(res);
|
Navigator.of(context).pop(res);
|
||||||
} catch (e) {
|
} catch (_) {
|
||||||
pinCodeStateKey.currentState?.reset();
|
pinCodeStateKey.currentState?.reset();
|
||||||
showBar<void>(
|
showBar<void>(
|
||||||
context,
|
context,
|
||||||
|
|
|
@ -18,8 +18,7 @@ class RestoredWallet {
|
||||||
this.recipientName,
|
this.recipientName,
|
||||||
this.height,
|
this.height,
|
||||||
this.privateKey,
|
this.privateKey,
|
||||||
this.source,
|
this.source});
|
||||||
this.isEncrypted = false});
|
|
||||||
|
|
||||||
final WalletRestoreMode restoreMode;
|
final WalletRestoreMode restoreMode;
|
||||||
final WalletType type;
|
final WalletType type;
|
||||||
|
@ -35,7 +34,6 @@ class RestoredWallet {
|
||||||
final int? height;
|
final int? height;
|
||||||
final String? privateKey;
|
final String? privateKey;
|
||||||
final String? source;
|
final String? source;
|
||||||
final bool? isEncrypted;
|
|
||||||
|
|
||||||
factory RestoredWallet.fromKey(Map<String, dynamic> json) {
|
factory RestoredWallet.fromKey(Map<String, dynamic> json) {
|
||||||
try {
|
try {
|
||||||
|
@ -45,7 +43,6 @@ class RestoredWallet {
|
||||||
json['view_key'] = codeParsed["privateViewKey"];
|
json['view_key'] = codeParsed["privateViewKey"];
|
||||||
json['height'] = codeParsed["restoreHeight"].toString();
|
json['height'] = codeParsed["restoreHeight"].toString();
|
||||||
json['source'] = codeParsed["source"] ?? '';
|
json['source'] = codeParsed["source"] ?? '';
|
||||||
json['encrypted'] = codeParsed["encrypted"] ?? false;
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// fine, we don't care, it is only for monero anyway
|
// 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,
|
height: height != null ? int.tryParse(height)??0 : 0,
|
||||||
privateKey: json['private_key'] as String?,
|
privateKey: json['private_key'] as String?,
|
||||||
source: json['source'] as String?,
|
source: json['source'] as String?,
|
||||||
isEncrypted: json['encrypted'] as bool? ?? false,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue