mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-09 12:29:31 +00:00
Fix restore from backup using 6 digit-pin
This commit is contained in:
parent
3d836d5dce
commit
7874009854
2 changed files with 8 additions and 2 deletions
|
@ -1,6 +1,7 @@
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
import 'dart:typed_data';
|
import 'dart:typed_data';
|
||||||
|
import 'package:cake_wallet/store/settings_store.dart';
|
||||||
import 'package:cw_core/wallet_type.dart';
|
import 'package:cw_core/wallet_type.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:hive/hive.dart';
|
import 'package:hive/hive.dart';
|
||||||
|
@ -20,7 +21,7 @@ import 'package:cake_backup/backup.dart' as cake_backup;
|
||||||
|
|
||||||
class BackupService {
|
class BackupService {
|
||||||
BackupService(this._flutterSecureStorage, this._walletInfoSource,
|
BackupService(this._flutterSecureStorage, this._walletInfoSource,
|
||||||
this._keyService, this._sharedPreferences)
|
this._keyService, this._sharedPreferences, this._settingsStore)
|
||||||
: _cipher = Cryptography.instance.chacha20Poly1305Aead(),
|
: _cipher = Cryptography.instance.chacha20Poly1305Aead(),
|
||||||
_correctWallets = <WalletInfo>[];
|
_correctWallets = <WalletInfo>[];
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ class BackupService {
|
||||||
final FlutterSecureStorage _flutterSecureStorage;
|
final FlutterSecureStorage _flutterSecureStorage;
|
||||||
final SharedPreferences _sharedPreferences;
|
final SharedPreferences _sharedPreferences;
|
||||||
final Box<WalletInfo> _walletInfoSource;
|
final Box<WalletInfo> _walletInfoSource;
|
||||||
|
final SettingsStore _settingsStore;
|
||||||
final KeyService _keyService;
|
final KeyService _keyService;
|
||||||
List<WalletInfo> _correctWallets;
|
List<WalletInfo> _correctWallets;
|
||||||
|
|
||||||
|
@ -301,6 +303,7 @@ class BackupService {
|
||||||
as Map<String, dynamic>;
|
as Map<String, dynamic>;
|
||||||
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
||||||
final decodedPin = keychainJSON['pin'] as String;
|
final decodedPin = keychainJSON['pin'] as String;
|
||||||
|
_settingsStore.pinCodeLength = decodedPin.length;
|
||||||
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||||
final backupPasswordKey =
|
final backupPasswordKey =
|
||||||
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||||
|
@ -331,6 +334,7 @@ class BackupService {
|
||||||
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
final keychainWalletsInfo = keychainJSON['wallets'] as List;
|
||||||
final decodedPin = keychainJSON['pin'] as String;
|
final decodedPin = keychainJSON['pin'] as String;
|
||||||
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
final pinCodeKey = generateStoreKeyFor(key: SecretStoreKey.pinCodePassword);
|
||||||
|
_settingsStore.pinCodeLength = decodedPin.length;
|
||||||
final backupPasswordKey =
|
final backupPasswordKey =
|
||||||
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
generateStoreKeyFor(key: SecretStoreKey.backupPassword);
|
||||||
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
final backupPassword = keychainJSON[backupPasswordKey] as String;
|
||||||
|
|
|
@ -586,7 +586,9 @@ Future setup(
|
||||||
getIt.get<FlutterSecureStorage>(),
|
getIt.get<FlutterSecureStorage>(),
|
||||||
_walletInfoSource,
|
_walletInfoSource,
|
||||||
getIt.get<KeyService>(),
|
getIt.get<KeyService>(),
|
||||||
getIt.get<SharedPreferences>()));
|
getIt.get<SharedPreferences>(),
|
||||||
|
getIt.get<SettingsStore>(),
|
||||||
|
));
|
||||||
|
|
||||||
getIt.registerFactory(() => BackupViewModel(getIt.get<FlutterSecureStorage>(),
|
getIt.registerFactory(() => BackupViewModel(getIt.get<FlutterSecureStorage>(),
|
||||||
getIt.get<SecretStore>(), getIt.get<BackupService>()));
|
getIt.get<SecretStore>(), getIt.get<BackupService>()));
|
||||||
|
|
Loading…
Reference in a new issue