-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add ability for change password for wallets classes. * Update generateWalletPassword * Add WalletLoadingService * Add update monero password after wallet loading. * Update version for Cake Wallet to 4.4.2 (103) * Changed version for Cake Wallet to 4.4.3 (104). * Changed version for Cake Wallet android * Changed version for Monero.com ios and android.
- Loading branch information
Showing
25 changed files
with
214 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,6 @@ | ||
import 'package:uuid/uuid.dart'; | ||
import 'package:cw_core/key.dart'; | ||
import 'package:cw_core/wallet_type.dart'; | ||
|
||
String generateWalletPassword(WalletType type) { | ||
switch (type) { | ||
case WalletType.monero: | ||
return Uuid().v4(); | ||
default: | ||
return generateKey(); | ||
} | ||
String generateWalletPassword() { | ||
return generateKey(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import 'package:cake_wallet/core/generate_wallet_password.dart'; | ||
import 'package:cake_wallet/core/key_service.dart'; | ||
import 'package:cake_wallet/entities/preferences_key.dart'; | ||
import 'package:cw_core/wallet_base.dart'; | ||
import 'package:cw_core/wallet_service.dart'; | ||
import 'package:cw_core/wallet_type.dart'; | ||
import 'package:shared_preferences/shared_preferences.dart'; | ||
|
||
class WalletLoadingService { | ||
WalletLoadingService( | ||
this.sharedPreferences, | ||
this.keyService, | ||
this.walletServiceFactory); | ||
|
||
final SharedPreferences sharedPreferences; | ||
final KeyService keyService; | ||
final WalletService Function(WalletType type) walletServiceFactory; | ||
|
||
Future<WalletBase> load(WalletType type, String name) async { | ||
if (walletServiceFactory == null) { | ||
throw Exception('WalletLoadingService.walletServiceFactory is not set'); | ||
} | ||
final walletService = walletServiceFactory?.call(type); | ||
final password = await keyService.getWalletPassword(walletName: name); | ||
final wallet = await walletService.openWallet(name, password); | ||
|
||
if (type == WalletType.monero) { | ||
await upateMoneroWalletPassword(wallet); | ||
} | ||
|
||
return wallet; | ||
} | ||
|
||
Future<void> upateMoneroWalletPassword(WalletBase wallet) async { | ||
final key = PreferencesKey.moneroWalletUpdateV1Key(wallet.name); | ||
var isPasswordUpdated = sharedPreferences.getBool(key) ?? false; | ||
|
||
if (isPasswordUpdated) { | ||
return; | ||
} | ||
|
||
final password = generateWalletPassword(); | ||
// Save new generated password with backup key for case | ||
// if wallet will change password, but it will faild to updated in secure storage | ||
final bakWalletName = '#__${wallet.name}_bak__#'; | ||
await keyService.saveWalletPassword(walletName: bakWalletName, password: password); | ||
await wallet.changePassword(password); | ||
await keyService.saveWalletPassword(walletName: wallet.name, password: password); | ||
isPasswordUpdated = true; | ||
await sharedPreferences.setBool(key, isPasswordUpdated); | ||
} | ||
} |
Oops, something went wrong.