cake_wallet/lib/core/key_service.dart
Rafael Saes d4969633b0
Cw 426 replace trash and swipe with edit icons (#974)
* feat: Replace trash and swipe with edit icons on node list item

- replaces yellow Test button with red Delete node button with confirmation on the edit node page

* feat: make node indicator icons bigger (figma comment)

* feat: Replace trash and swipe with edit icons on wallet list page and create wallet_edit_page.dart

* fix: make delete buttons red

* fix: make wallet name wrap when it is too long

* refactor: improve logic & fix observer not refreshing

* fix: add string

* feat: remove the confirmation pop-up for switching between wallets

- which was another item on the jira issue

* fix: remove slideable widgets from node list

* feat: add edit button to currently selected node & disable deleting if selected

* fix: rename wallet also renames to new wallet files

* feat: make sure edits can't overlap existing names

* fix: improve rename flow, fix electrum transactions refresh & add delete old logic

* fix: also fix rename for monero & haven

* refactor: fix identations

* refactor: dont declare the current wallet twice

* refactor: missing newWalletInfo.id

* fix: dont unnecessarily load the current wallet

* fix: remove unnecessary reaction

* feat: make save button disabled until the text is changed

* feat: make walletEditViewModel and make state useful for pending actions

* fix: add back reaction for desktop flow

* - Remove un-necessary code
- Format Edit page

---------

Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2023-07-13 02:20:11 +03:00

31 lines
1.2 KiB
Dart

import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cake_wallet/entities/encrypt.dart';
class KeyService {
KeyService(this._secureStorage);
final FlutterSecureStorage _secureStorage;
Future<String> getWalletPassword({required String walletName}) async {
final key = generateStoreKeyFor(
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
final encodedPassword = await _secureStorage.read(key: key);
return decodeWalletPassword(password: encodedPassword!);
}
Future<void> saveWalletPassword({required String walletName, required String password}) async {
final key = generateStoreKeyFor(
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
final encodedPassword = encodeWalletPassword(password: password);
await _secureStorage.write(key: key, value: encodedPassword);
}
Future<void> deleteWalletPassword({required String walletName}) async {
final key = generateStoreKeyFor(
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
await _secureStorage.delete(key: key);
}
}