Generic enhancements (#1456)

* minor enhancement

* show camera consent at least once, even if camera permission is granted already

* minor enhancement [skip ci]

* Add taproot derivation path to electrum_derivations.dart

* remove unused import [skip ci]

* Initialize Ledger only when necessary

* Update app versions
This commit is contained in:
Omar Hatem 2024-05-22 04:18:04 +03:00 committed by GitHub
parent f846f91e5f
commit 7b5204fdaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 98 additions and 67 deletions

View file

@ -329,6 +329,8 @@ abstract class DashboardViewModelBase with Store {
.toList();
}
bool get hasBuyProviders => ProvidersHelper.getAvailableBuyProviderTypes(wallet.type).isNotEmpty;
List<BuyProvider> get availableSellProviders {
final providerTypes = ProvidersHelper.getAvailableSellProviderTypes(wallet.type);
return providerTypes
@ -338,6 +340,8 @@ abstract class DashboardViewModelBase with Store {
.toList();
}
bool get hasSellProviders => ProvidersHelper.getAvailableSellProviderTypes(wallet.type).isNotEmpty;
bool get shouldShowYatPopup => settingsStore.shouldShowYatPopup;
@action
@ -350,13 +354,13 @@ abstract class DashboardViewModelBase with Store {
bool hasExchangeAction;
@computed
bool get isEnabledBuyAction => !settingsStore.disableBuy && availableBuyProviders.isNotEmpty;
bool get isEnabledBuyAction => !settingsStore.disableBuy && hasBuyProviders;
@observable
bool hasBuyAction;
@computed
bool get isEnabledSellAction => !settingsStore.disableSell && availableSellProviders.isNotEmpty;
bool get isEnabledSellAction => !settingsStore.disableSell && hasSellProviders;
@observable
bool hasSellAction;
@ -495,34 +499,38 @@ abstract class DashboardViewModelBase with Store {
void setSyncAll(bool value) => settingsStore.currentSyncAll = value;
Future<List<String>> checkAffectedWallets() async {
// await load file
final vulnerableSeedsString = await rootBundle
.loadString('assets/text/cakewallet_weak_bitcoin_seeds_hashed_sorted_version1.txt');
final vulnerableSeeds = vulnerableSeedsString.split("\n");
try {
// await load file
final vulnerableSeedsString = await rootBundle
.loadString('assets/text/cakewallet_weak_bitcoin_seeds_hashed_sorted_version1.txt');
final vulnerableSeeds = vulnerableSeedsString.split("\n");
final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
final walletInfoSource = await CakeHive.openBox<WalletInfo>(WalletInfo.boxName);
List<String> affectedWallets = [];
for (var walletInfo in walletInfoSource.values) {
if (walletInfo.type == WalletType.bitcoin) {
final password = await keyService.getWalletPassword(walletName: walletInfo.name);
final path = await pathForWallet(name: walletInfo.name, type: walletInfo.type);
final jsonSource = await read(path: path, password: password);
final data = json.decode(jsonSource) as Map;
final mnemonic = data['mnemonic'] as String?;
List<String> affectedWallets = [];
for (var walletInfo in walletInfoSource.values) {
if (walletInfo.type == WalletType.bitcoin) {
final password = await keyService.getWalletPassword(walletName: walletInfo.name);
final path = await pathForWallet(name: walletInfo.name, type: walletInfo.type);
final jsonSource = await read(path: path, password: password);
final data = json.decode(jsonSource) as Map;
final mnemonic = data['mnemonic'] as String?;
if (mnemonic == null) continue;
if (mnemonic == null) continue;
final hash = await Cryptography.instance.sha256().hash(utf8.encode(mnemonic));
final seedSha = bytesToHex(hash.bytes);
final hash = await Cryptography.instance.sha256().hash(utf8.encode(mnemonic));
final seedSha = bytesToHex(hash.bytes);
if (vulnerableSeeds.contains(seedSha)) {
affectedWallets.add(walletInfo.name);
if (vulnerableSeeds.contains(seedSha)) {
affectedWallets.add(walletInfo.name);
}
}
}
}
return affectedWallets;
return affectedWallets;
} catch (_) {
return [];
}
}
Future<ServicesResponse> getServicesStatus() async {