24
import 'package:cake_wallet/wallet_types.g.dart';
25
import 'package:cake_backup/backup.dart' as cake_backup;
26
27
-class BackupService {
28
- BackupService(this._secureStorage, this._walletInfoSource, this._transactionDescriptionBox,
29
- this._keyService, this._sharedPreferences)
30
- : _cipher = Cryptography.instance.chacha20Poly1305Aead(),
31
- _correctWallets = <WalletInfo>[];
27
+class $BackupService {
28
+ $BackupService(this._secureStorage, this.walletInfoSource, this.transactionDescriptionBox,
29
+ this.keyService, this.sharedPreferences)
30
+ : cipher = Cryptography.instance.chacha20Poly1305Aead(),
31
+ correctWallets = <WalletInfo>[];
32
33
- static const currentVersion = _v2;
33
+ static const currentVersion = _v3;
34
35
- static const _v1 = 1;
35
static const _v2 = 2;
36
+ static const _v3 = 3;
37
38
- final Cipher _cipher;
38
+ final Cipher cipher;
39
final SecureStorage _secureStorage;
40
- final SharedPreferences _sharedPreferences;
41
- final Box<WalletInfo> _walletInfoSource;
42
- final Box<TransactionDescription> _transactionDescriptionBox;
43
- final KeyService _keyService;
44
- List<WalletInfo> _correctWallets;
45
-
46
- Future<void> importBackup(Uint8List data, String password,
47
- {String nonce = secrets.backupSalt}) async {
48
- final version = getVersion(data);
49
-
50
- switch (version) {
51
- case _v1:
52
- final backupBytes = data.toList()..removeAt(0);
53
- final backupData = Uint8List.fromList(backupBytes);
54
- await _importBackupV1(backupData, password, nonce: nonce);
55
- break;
56
- case _v2:
57
- await _importBackupV2(data, password);
58
- break;
59
- default:
60
- break;
61
- }
62
- }
63
-
64
- Future<Uint8List> exportBackup(String password,
65
- {String nonce = secrets.backupSalt, int version = currentVersion}) async {
66
- switch (version) {
67
- case _v1:
68
- return await _exportBackupV1(password, nonce: nonce);
69
- case _v2:
70
- return await _exportBackupV2(password);
71
- default:
72
- throw Exception('Incorrect version: $version for exportBackup');
73
- }
74
- }
40
+ final SharedPreferences sharedPreferences;
41
+ final Box<WalletInfo> walletInfoSource;
42
+ final Box<TransactionDescription> transactionDescriptionBox;
43
+ final KeyService keyService;
44
+ List<WalletInfo> correctWallets;
45
76
- @Deprecated('Use v2 instead')
77
- Future<Uint8List> _exportBackupV1(String password, {String nonce = secrets.backupSalt}) async =>
78
- throw Exception('Deprecated. Export for backups v1 is deprecated. Please use export v2.');
46
80
- Future<Uint8List> _exportBackupV2(String password) async {
81
- final zipEncoder = ZipFileEncoder();
82
- final appDir = await getAppDir();
83
- final now = DateTime.now();
84
- final tmpDir = Directory('${appDir.path}/~_BACKUP_TMP');
85
- final archivePath = '${tmpDir.path}/backup_${now.toString()}.zip';
86
- final fileEntities = appDir.listSync(recursive: false);
87
- final keychainDump = await _exportKeychainDumpV2(password);
88
- final preferencesDump = await _exportPreferencesJSON();
89
- final preferencesDumpFile = File('${tmpDir.path}/~_preferences_dump_TMP');
90
- final keychainDumpFile = File('${tmpDir.path}/~_keychain_dump_TMP');
91
- final transactionDescriptionDumpFile =
92
- File('${tmpDir.path}/~_transaction_descriptions_dump_TMP');
93
-
94
- final transactionDescriptionData = _transactionDescriptionBox
95
- .toMap()
96
- .map((key, value) => MapEntry(key.toString(), value.toJson()));
97
- final transactionDescriptionDump = jsonEncode(transactionDescriptionData);
98
-
99
- if (tmpDir.existsSync()) {
100
- tmpDir.deleteSync(recursive: true);
101
- }
102
-
103
- tmpDir.createSync();
104
- zipEncoder.create(archivePath);
105
-
106
- fileEntities.forEach((entity) {
107
- if (entity.path == archivePath || entity.path == tmpDir.path) {
108
- return;
109
- }
110
- final filename = entity.absolute;
111
- for (var ignore in ignoreFiles) {
112
- final filename = entity.absolute.path;
113
- if (filename.endsWith(ignore) && !filename.contains("wallets/")) {
114
- printV("ignoring backup file: $filename");
115
- return;
116
- }
117
- }
118
- printV("restoring: $filename");
119
- if (entity.statSync().type == FileSystemEntityType.directory) {
120
- zipEncoder.addDirectory(Directory(entity.path));
121
- } else {
122
- zipEncoder.addFile(File(entity.path));
123
- }
124
- });
125
- await keychainDumpFile.writeAsBytes(keychainDump.toList());
126
- await preferencesDumpFile.writeAsString(preferencesDump);
127
- await transactionDescriptionDumpFile.writeAsString(transactionDescriptionDump);
128
- await zipEncoder.addFile(preferencesDumpFile, '~_preferences_dump');
129
- await zipEncoder.addFile(keychainDumpFile, '~_keychain_dump');
130
- await zipEncoder.addFile(transactionDescriptionDumpFile, '~_transaction_descriptions_dump');
131
- zipEncoder.close();
132
-
133
- final content = File(archivePath).readAsBytesSync();
134
- tmpDir.deleteSync(recursive: true);
135
- return await _encryptV2(content, password);
136
- }
137
-
138
- Future<void> _importBackupV1(Uint8List data, String password, {required String nonce}) async {
47
+ Future<void> importBackupV1(Uint8List data, String password, {required String nonce}) async {
48
final appDir = await getAppDir();
49
final decryptedData = await _decryptV1(data, password, nonce);
50
final zip = ZipDecoder().decodeBytes(decryptedData);
62
}
63
};
64
156
- await _verifyWallets();
65
+ await verifyWallets();
66
await _importKeychainDumpV1(password, nonce: nonce);
158
- await _importPreferencesDump();
67
+ await importPreferencesDump();
68
}
69
70
// checked with .endsWith - so this should be the last part of the filename
72
"flutter_assets/kernel_blob.bin",
73
"flutter_assets/vm_snapshot_data",
74
"flutter_assets/isolate_snapshot_data",
75
+ "README.txt",
76
".lock",
77
];
78
169
- Future<void> _importBackupV2(Uint8List data, String password) async {
79
+ Future<void> importBackupV2(Uint8List data, String password) async {
80
final appDir = await getAppDir();
171
- final decryptedData = await _decryptV2(data, password);
81
+ final decryptedData = await decryptV2(data, password);
82
final zip = ZipDecoder().decodeBytes(decryptedData);
83
84
outer:
97
..createSync(recursive: true)
98
..writeAsBytesSync(content, flush: true);
99
} else {
190
- Directory('${appDir.path}/' + filename)..create(recursive: true);
100
+ final dir = Directory('${appDir.path}/' + filename);
101
+ if (!dir.existsSync()) {
102
+ dir.createSync(recursive: true);
103
+ }
104
}
105
};
106
194
- await _verifyWallets();
195
- await _importKeychainDumpV2(password);
196
- await _importPreferencesDump();
197
- await _importTransactionDescriptionDump(); // HiveError: Box has already been closed
107
+ await verifyWallets();
108
+ await importKeychainDumpV2(password);
109
+ await importPreferencesDump();
110
+ await importTransactionDescriptionDump(); // HiveError: Box has already been closed
111
}
112
200
- Future<void> _verifyWallets() async {
113
+ Future<void> verifyWallets() async {
114
final walletInfoSource = await _reloadHiveWalletInfoBox();
202
- _correctWallets =
115
+ correctWallets =
116
walletInfoSource.values.where((info) => availableWalletTypes.contains(info.type)).toList();
117
205
- if (_correctWallets.isEmpty) {
118
+ if (correctWallets.isEmpty) {
119
throw Exception('Correct wallets not detected');
120
}
121
}
132
return await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
133
}
134
222
- Future<void> _importTransactionDescriptionDump() async {
135
+ Future<void> importTransactionDescriptionDump() async {
136
final appDir = await getAppDir();
137
final transactionDescriptionFile = File('${appDir.path}/~_transaction_descriptions_dump');
138
144
json.decode(transactionDescriptionFile.readAsStringSync()) as Map<String, dynamic>;
145
final descriptionsMap = jsonData.map((key, value) =>
146
MapEntry(key, TransactionDescription.fromJson(value as Map<String, dynamic>)));
234
- var box = _transactionDescriptionBox;
147
+ var box = transactionDescriptionBox;
148
if (!box.isOpen) {
149
final transactionDescriptionsBoxKey =
150
await getEncryptionKey(secureStorage: _secureStorage, forKey: TransactionDescription.boxKey);
155
await box.putAll(descriptionsMap);
156
}
157
245
- Future<void> _importPreferencesDump() async {
158
+ Future<void> importPreferencesDump() async {
159
final appDir = await getAppDir();
160
final preferencesFile = File('${appDir.path}/~_preferences_dump');
161
167
String currentWalletName = data[PreferencesKey.currentWalletName] as String;
168
int currentWalletType = data[PreferencesKey.currentWalletType] as int;
169
257
- final isCorrentCurrentWallet = _correctWallets
170
+ final isCorrentCurrentWallet = correctWallets
171
.any((info) => info.name == currentWalletName && info.type.index == currentWalletType);
172
173
if (!isCorrentCurrentWallet) {
261
- currentWalletName = _correctWallets.first.name;
262
- currentWalletType = serializeToInt(_correctWallets.first.type);
174
+ currentWalletName = correctWallets.first.name;
175
+ currentWalletType = serializeToInt(correctWallets.first.type);
176
}
177
178
final currentNodeId = data[PreferencesKey.currentNodeIdKey] as int?;
211
final autoGenerateSubaddressStatus =
212
data[PreferencesKey.autoGenerateSubaddressStatusKey] as int?;
213
301
- await _sharedPreferences.setString(PreferencesKey.currentWalletName, currentWalletName);
214
+ await sharedPreferences.setString(PreferencesKey.currentWalletName, currentWalletName);
215
216
if (currentNodeId != null)
304
- await _sharedPreferences.setInt(PreferencesKey.currentNodeIdKey, currentNodeId);
217
+ await sharedPreferences.setInt(PreferencesKey.currentNodeIdKey, currentNodeId);
218
219
if (currentBalanceDisplayMode != null)
307
- await _sharedPreferences.setInt(
220
+ await sharedPreferences.setInt(
221
PreferencesKey.currentBalanceDisplayModeKey, currentBalanceDisplayMode);
222
310
- await _sharedPreferences.setInt(PreferencesKey.currentWalletType, currentWalletType);
223
+ await sharedPreferences.setInt(PreferencesKey.currentWalletType, currentWalletType);
224
225
if (currentFiatCurrency != null)
313
- await _sharedPreferences.setString(
226
+ await sharedPreferences.setString(
227
PreferencesKey.currentFiatCurrencyKey, currentFiatCurrency);
228
229
if (shouldSaveRecipientAddress != null)
317
- await _sharedPreferences.setBool(
230
+ await sharedPreferences.setBool(
231
PreferencesKey.shouldSaveRecipientAddressKey, shouldSaveRecipientAddress);
232
233
if (isAppSecure != null)
321
- await _sharedPreferences.setBool(PreferencesKey.isAppSecureKey, isAppSecure);
234
+ await sharedPreferences.setBool(PreferencesKey.isAppSecureKey, isAppSecure);
235
236
if (disableTradeOption != null)
324
- await _sharedPreferences.setBool(PreferencesKey.disableTradeOption, disableTradeOption);
237
+ await sharedPreferences.setBool(PreferencesKey.disableTradeOption, disableTradeOption);
238
239
if (currentTransactionPriorityKeyLegacy != null)
327
- await _sharedPreferences.setInt(
240
+ await sharedPreferences.setInt(
241
PreferencesKey.currentTransactionPriorityKeyLegacy, currentTransactionPriorityKeyLegacy);
242
243
if (currentBitcoinElectrumSererId != null)
331
- await _sharedPreferences.setInt(
244
+ await sharedPreferences.setInt(
245
PreferencesKey.currentBitcoinElectrumSererIdKey, currentBitcoinElectrumSererId);
246
247
if (currentLanguageCode != null)
335
- await _sharedPreferences.setString(PreferencesKey.currentLanguageCode, currentLanguageCode);
248
+ await sharedPreferences.setString(PreferencesKey.currentLanguageCode, currentLanguageCode);
249
250
if (displayActionListMode != null)
338
- await _sharedPreferences.setInt(
251
+ await sharedPreferences.setInt(
252
PreferencesKey.displayActionListModeKey, displayActionListMode);
253
254
if (fiatApiMode != null)
342
- await _sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, fiatApiMode);
255
+ await sharedPreferences.setInt(PreferencesKey.currentFiatApiModeKey, fiatApiMode);
256
if (autoGenerateSubaddressStatus != null)
344
- await _sharedPreferences.setInt(
257
+ await sharedPreferences.setInt(
258
PreferencesKey.autoGenerateSubaddressStatusKey, autoGenerateSubaddressStatus);
259
260
if (currentTheme != null && DeviceInfo.instance.isMobile) {
348
- await _sharedPreferences.setInt(PreferencesKey.currentTheme, currentTheme);
261
+ await sharedPreferences.setInt(PreferencesKey.currentTheme, currentTheme);
262
// enforce dark theme on desktop platforms until the design is ready:
263
} else if (DeviceInfo.instance.isDesktop) {
351
- await _sharedPreferences.setInt(PreferencesKey.currentTheme, ThemeList.darkTheme.raw);
264
+ await sharedPreferences.setInt(PreferencesKey.currentTheme, ThemeList.darkTheme.raw);
265
}
266
267
if (exchangeStatus != null)
355
- await _sharedPreferences.setInt(PreferencesKey.exchangeStatusKey, exchangeStatus);
268
+ await sharedPreferences.setInt(PreferencesKey.exchangeStatusKey, exchangeStatus);
269
270
if (currentDefaultSettingsMigrationVersion != null)
358
- await _sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion,
271
+ await sharedPreferences.setInt(PreferencesKey.currentDefaultSettingsMigrationVersion,
272
currentDefaultSettingsMigrationVersion);
273
274
if (moneroTransactionPriority != null)
362
- await _sharedPreferences.setInt(
275
+ await sharedPreferences.setInt(
276
PreferencesKey.moneroTransactionPriority, moneroTransactionPriority);
277
278
if (bitcoinTransactionPriority != null)
366
- await _sharedPreferences.setInt(
279
+ await sharedPreferences.setInt(
280
PreferencesKey.bitcoinTransactionPriority, bitcoinTransactionPriority);
281
282
if (sortBalanceTokensBy != null)
370
- await _sharedPreferences.setInt(PreferencesKey.sortBalanceBy, sortBalanceTokensBy);
283
+ await sharedPreferences.setInt(PreferencesKey.sortBalanceBy, sortBalanceTokensBy);
284
285
if (pinNativeTokenAtTop != null)
373
- await _sharedPreferences.setBool(PreferencesKey.pinNativeTokenAtTop, pinNativeTokenAtTop);
286
+ await sharedPreferences.setBool(PreferencesKey.pinNativeTokenAtTop, pinNativeTokenAtTop);
287
288
if (useEtherscan != null)
376
- await _sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan);
289
+ await sharedPreferences.setBool(PreferencesKey.useEtherscan, useEtherscan);
290
291
if (defaultNanoRep != null)
379
- await _sharedPreferences.setString(PreferencesKey.defaultNanoRep, defaultNanoRep);
292
+ await sharedPreferences.setString(PreferencesKey.defaultNanoRep, defaultNanoRep);
293
294
if (defaultBananoRep != null)
382
- await _sharedPreferences.setString(PreferencesKey.defaultBananoRep, defaultBananoRep);
295
+ await sharedPreferences.setString(PreferencesKey.defaultBananoRep, defaultBananoRep);
296
384
- if (syncAll != null) await _sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
297
+ if (syncAll != null) await sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
298
if (lookupsTwitter != null)
386
- await _sharedPreferences.setBool(PreferencesKey.lookupsTwitter, lookupsTwitter);
299
+ await sharedPreferences.setBool(PreferencesKey.lookupsTwitter, lookupsTwitter);
300
301
if (lookupsMastodon != null)
389
- await _sharedPreferences.setBool(PreferencesKey.lookupsMastodon, lookupsMastodon);
302
+ await sharedPreferences.setBool(PreferencesKey.lookupsMastodon, lookupsMastodon);
303
304
if (lookupsYatService != null)
392
- await _sharedPreferences.setBool(PreferencesKey.lookupsYatService, lookupsYatService);
305
+ await sharedPreferences.setBool(PreferencesKey.lookupsYatService, lookupsYatService);
306
307
if (lookupsUnstoppableDomains != null)
395
- await _sharedPreferences.setBool(
308
+ await sharedPreferences.setBool(
309
PreferencesKey.lookupsUnstoppableDomains, lookupsUnstoppableDomains);
310
311
if (lookupsOpenAlias != null)
399
- await _sharedPreferences.setBool(PreferencesKey.lookupsOpenAlias, lookupsOpenAlias);
312
+ await sharedPreferences.setBool(PreferencesKey.lookupsOpenAlias, lookupsOpenAlias);
313
401
- if (lookupsENS != null) await _sharedPreferences.setBool(PreferencesKey.lookupsENS, lookupsENS);
314
+ if (lookupsENS != null) await sharedPreferences.setBool(PreferencesKey.lookupsENS, lookupsENS);
315
316
if (lookupsWellKnown != null)
404
- await _sharedPreferences.setBool(PreferencesKey.lookupsWellKnown, lookupsWellKnown);
317
+ await sharedPreferences.setBool(PreferencesKey.lookupsWellKnown, lookupsWellKnown);
318
406
- if (syncAll != null) await _sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
319
+ if (syncAll != null) await sharedPreferences.setBool(PreferencesKey.syncAllKey, syncAll);
320
408
- if (syncMode != null) await _sharedPreferences.setInt(PreferencesKey.syncModeKey, syncMode);
321
+ if (syncMode != null) await sharedPreferences.setInt(PreferencesKey.syncModeKey, syncMode);
322
323
await preferencesFile.delete();
324
}
349
keychainDumpFile.deleteSync();
350
}
351
439
- Future<void> _importKeychainDumpV2(String password,
352
+ Future<void> importKeychainDumpV2(String password,
353
{String keychainSalt = secrets.backupKeychainSalt}) async {
354
final appDir = await getAppDir();
355
final keychainDumpFile = File('${appDir.path}/~_keychain_dump');
356
final decryptedKeychainDumpFileData =
444
- await _decryptV2(keychainDumpFile.readAsBytesSync(), '$keychainSalt$password');
357
+ await decryptV2(keychainDumpFile.readAsBytesSync(), '$keychainSalt$password');
358
final keychainJSON =
359
json.decode(utf8.decode(decryptedKeychainDumpFileData)) as Map<String, dynamic>;
360
final keychainWalletsInfo = keychainJSON['wallets'] as List;
375
final name = info['name'] as String;
376
final password = info['password'] as String;
377
465
- await _keyService.saveWalletPassword(walletName: name, password: password);
378
+ await keyService.saveWalletPassword(walletName: name, password: password);
379
}
380
381
@Deprecated('Use v2 instead')
383
{required String nonce, String keychainSalt = secrets.backupKeychainSalt}) async =>
384
throw Exception('Deprecated');
385
473
- Future<Uint8List> _exportKeychainDumpV2(String password,
386
+ Future<Uint8List> exportKeychainDumpV2(String password,
387
{String keychainSalt = secrets.backupKeychainSalt}) async {
388
final key = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
476
- final wallets = await Future.wait(_walletInfoSource.values.map((walletInfo) async {
389
+ final wallets = await Future.wait(walletInfoSource.values.map((walletInfo) async {
390
return {
391
'name': walletInfo.name,
392
'type': walletInfo.type.toString(),
480
- 'password': await _keyService.getWalletPassword(walletName: walletInfo.name)
393
+ 'password': await keyService.getWalletPassword(walletName: walletInfo.name)
394
};
395
}));
396
final backupPasswordKey = generateStoreKeyFor(key: SecretStoreKey.backupPassword);
402
return encrypted;
403
}
404
492
- Future<String> _exportPreferencesJSON() async {
405
+ Future<String> exportPreferencesJSON() async {
406
final preferences = <String, dynamic>{
407
PreferencesKey.currentWalletName:
495
- _sharedPreferences.getString(PreferencesKey.currentWalletName),
496
- PreferencesKey.currentNodeIdKey: _sharedPreferences.getInt(PreferencesKey.currentNodeIdKey),
408
+ sharedPreferences.getString(PreferencesKey.currentWalletName),
409
+ PreferencesKey.currentNodeIdKey: sharedPreferences.getInt(PreferencesKey.currentNodeIdKey),
410
PreferencesKey.currentBalanceDisplayModeKey:
498
- _sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey),
499
- PreferencesKey.currentWalletType: _sharedPreferences.getInt(PreferencesKey.currentWalletType),
411
+ sharedPreferences.getInt(PreferencesKey.currentBalanceDisplayModeKey),
412
+ PreferencesKey.currentWalletType: sharedPreferences.getInt(PreferencesKey.currentWalletType),
413
PreferencesKey.currentFiatCurrencyKey:
501
- _sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey),
414
+ sharedPreferences.getString(PreferencesKey.currentFiatCurrencyKey),
415
PreferencesKey.shouldSaveRecipientAddressKey:
503
- _sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey),
504
- PreferencesKey.disableTradeOption: _sharedPreferences.getBool(PreferencesKey.disableTradeOption),
416
+ sharedPreferences.getBool(PreferencesKey.shouldSaveRecipientAddressKey),
417
+ PreferencesKey.disableTradeOption: sharedPreferences.getBool(PreferencesKey.disableTradeOption),
418
PreferencesKey.currentTransactionPriorityKeyLegacy:
506
- _sharedPreferences.getInt(PreferencesKey.currentTransactionPriorityKeyLegacy),
419
+ sharedPreferences.getInt(PreferencesKey.currentTransactionPriorityKeyLegacy),
420
PreferencesKey.currentBitcoinElectrumSererIdKey:
508
- _sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey),
421
+ sharedPreferences.getInt(PreferencesKey.currentBitcoinElectrumSererIdKey),
422
PreferencesKey.currentLanguageCode:
510
- _sharedPreferences.getString(PreferencesKey.currentLanguageCode),
423
+ sharedPreferences.getString(PreferencesKey.currentLanguageCode),
424
PreferencesKey.displayActionListModeKey:
512
- _sharedPreferences.getInt(PreferencesKey.displayActionListModeKey),
513
- PreferencesKey.currentTheme: _sharedPreferences.getInt(PreferencesKey.currentTheme),
514
- PreferencesKey.exchangeStatusKey: _sharedPreferences.getInt(PreferencesKey.exchangeStatusKey),
425
+ sharedPreferences.getInt(PreferencesKey.displayActionListModeKey),
426
+ PreferencesKey.currentTheme: sharedPreferences.getInt(PreferencesKey.currentTheme),
427
+ PreferencesKey.exchangeStatusKey: sharedPreferences.getInt(PreferencesKey.exchangeStatusKey),
428
PreferencesKey.currentDefaultSettingsMigrationVersion:
516
- _sharedPreferences.getInt(PreferencesKey.currentDefaultSettingsMigrationVersion),
429
+ sharedPreferences.getInt(PreferencesKey.currentDefaultSettingsMigrationVersion),
430
PreferencesKey.bitcoinTransactionPriority:
518
- _sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority),
431
+ sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority),
432
PreferencesKey.moneroTransactionPriority:
520
- _sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority),
433
+ sharedPreferences.getInt(PreferencesKey.moneroTransactionPriority),
434
PreferencesKey.currentFiatApiModeKey:
522
- _sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey),
523
- PreferencesKey.sortBalanceBy: _sharedPreferences.getInt(PreferencesKey.sortBalanceBy),
435
+ sharedPreferences.getInt(PreferencesKey.currentFiatApiModeKey),
436
+ PreferencesKey.sortBalanceBy: sharedPreferences.getInt(PreferencesKey.sortBalanceBy),
437
PreferencesKey.pinNativeTokenAtTop:
525
- _sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop),
526
- PreferencesKey.useEtherscan: _sharedPreferences.getBool(PreferencesKey.useEtherscan),
527
- PreferencesKey.defaultNanoRep: _sharedPreferences.getString(PreferencesKey.defaultNanoRep),
438
+ sharedPreferences.getBool(PreferencesKey.pinNativeTokenAtTop),
439
+ PreferencesKey.useEtherscan: sharedPreferences.getBool(PreferencesKey.useEtherscan),
440
+ PreferencesKey.defaultNanoRep: sharedPreferences.getString(PreferencesKey.defaultNanoRep),
441
PreferencesKey.defaultBananoRep:
529
- _sharedPreferences.getString(PreferencesKey.defaultBananoRep),
530
- PreferencesKey.lookupsTwitter: _sharedPreferences.getBool(PreferencesKey.lookupsTwitter),
531
- PreferencesKey.lookupsMastodon: _sharedPreferences.getBool(PreferencesKey.lookupsMastodon),
442
+ sharedPreferences.getString(PreferencesKey.defaultBananoRep),
443
+ PreferencesKey.lookupsTwitter: sharedPreferences.getBool(PreferencesKey.lookupsTwitter),
444
+ PreferencesKey.lookupsMastodon: sharedPreferences.getBool(PreferencesKey.lookupsMastodon),
445
PreferencesKey.lookupsYatService:
533
- _sharedPreferences.getBool(PreferencesKey.lookupsYatService),
446
+ sharedPreferences.getBool(PreferencesKey.lookupsYatService),
447
PreferencesKey.lookupsUnstoppableDomains:
535
- _sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains),
536
- PreferencesKey.lookupsOpenAlias: _sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias),
537
- PreferencesKey.lookupsENS: _sharedPreferences.getBool(PreferencesKey.lookupsENS),
448
+ sharedPreferences.getBool(PreferencesKey.lookupsUnstoppableDomains),
449
+ PreferencesKey.lookupsOpenAlias: sharedPreferences.getBool(PreferencesKey.lookupsOpenAlias),
450
+ PreferencesKey.lookupsENS: sharedPreferences.getBool(PreferencesKey.lookupsENS),
451
PreferencesKey.lookupsWellKnown:
539
- _sharedPreferences.getBool(PreferencesKey.lookupsWellKnown),
540
- PreferencesKey.syncModeKey: _sharedPreferences.getInt(PreferencesKey.syncModeKey),
541
- PreferencesKey.syncAllKey: _sharedPreferences.getBool(PreferencesKey.syncAllKey),
452
+ sharedPreferences.getBool(PreferencesKey.lookupsWellKnown),
453
+ PreferencesKey.syncModeKey: sharedPreferences.getInt(PreferencesKey.syncModeKey),
454
+ PreferencesKey.syncAllKey: sharedPreferences.getBool(PreferencesKey.syncAllKey),
455
PreferencesKey.autoGenerateSubaddressStatusKey:
543
- _sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey),
456
+ sharedPreferences.getInt(PreferencesKey.autoGenerateSubaddressStatusKey),
457
};
458
459
return json.encode(preferences);
477
final nonce = base64.decode(nonceBase64).toList();
478
final box = SecretBox(Uint8List.sublistView(data, 0, data.lengthInBytes - macLength).toList(),
479
nonce: nonce, mac: Mac(Uint8List.sublistView(data, data.lengthInBytes - macLength)));
567
- final plainData = await _cipher.decrypt(box, secretKey: secretKey);
480
+ final plainData = await cipher.decrypt(box, secretKey: secretKey);
481
return Uint8List.fromList(plainData);
482
}
483
484
Future<Uint8List> _encryptV2(Uint8List data, String passphrase) async =>
485
cake_backup.encrypt(passphrase, data, version: _v2);
486
574
- Future<Uint8List> _decryptV2(Uint8List data, String passphrase) async =>
487
+ Future<Uint8List> decryptV2(Uint8List data, String passphrase) async =>
488
cake_backup.decrypt(passphrase, data);
489
}