diff --git a/cw_bitcoin/lib/bitcoin_transaction_priority.dart b/cw_bitcoin/lib/bitcoin_transaction_priority.dart index 6f7164ec3..0573624ea 100644 --- a/cw_bitcoin/lib/bitcoin_transaction_priority.dart +++ b/cw_bitcoin/lib/bitcoin_transaction_priority.dart @@ -13,6 +13,8 @@ class BitcoinTransactionPriority extends TransactionPriority { static const BitcoinTransactionPriority fast = BitcoinTransactionPriority(title: 'Fast', raw: 2); + static const BitcoinTransactionPriority defaultPriority = medium; + static BitcoinTransactionPriority deserialize({required int raw}) { switch (raw) { case 0: @@ -22,7 +24,7 @@ class BitcoinTransactionPriority extends TransactionPriority { case 2: return fast; default: - return medium; + throw Exception('Unexpected token: $raw for BitcoinTransactionPriority deserialize'); } } @@ -73,7 +75,7 @@ class LitecoinTransactionPriority extends BitcoinTransactionPriority { case 2: return fast; default: - return medium; + throw Exception('Unexpected token: $raw for LitecoinTransactionPriority deserialize'); } } diff --git a/cw_core/lib/monero_transaction_priority.dart b/cw_core/lib/monero_transaction_priority.dart index 5219014c5..f5c00ecc7 100644 --- a/cw_core/lib/monero_transaction_priority.dart +++ b/cw_core/lib/monero_transaction_priority.dart @@ -21,22 +21,6 @@ class MoneroTransactionPriority extends TransactionPriority { static const fastest = MoneroTransactionPriority(title: 'Fastest', raw: 4); static const standard = slow; - - static List forWalletType(WalletType type) { - switch (type) { - case WalletType.monero: - return MoneroTransactionPriority.all; - case WalletType.bitcoin: - return [ - MoneroTransactionPriority.slow, - MoneroTransactionPriority.automatic, - MoneroTransactionPriority.fast - ]; - default: - return []; - } - } - static MoneroTransactionPriority deserialize({required int raw}) { switch (raw) { case 0: @@ -50,7 +34,7 @@ class MoneroTransactionPriority extends TransactionPriority { case 4: return fastest; default: - return automatic; + throw Exception('Unexpected token: $raw for MoneroTransactionPriority deserialize'); } } diff --git a/lib/entities/default_settings_migration.dart b/lib/entities/default_settings_migration.dart index 9aff05500..42b49c2ec 100644 --- a/lib/entities/default_settings_migration.dart +++ b/lib/entities/default_settings_migration.dart @@ -1,10 +1,12 @@ import 'dart:io' show File, Platform; import 'package:cake_wallet/bitcoin/bitcoin.dart'; +import 'package:cw_bitcoin/bitcoin_transaction_priority.dart'; import 'package:cw_core/pathForWallet.dart'; import 'package:cake_wallet/entities/secret_store_key.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; import 'package:hive/hive.dart'; +import 'package:share_plus/share_plus.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:cake_wallet/entities/preferences_key.dart'; import 'package:cw_core/wallet_type.dart'; @@ -139,6 +141,10 @@ Future defaultSettingsMigration( await addOnionNode(nodes); break; + case 19: + await validateBitcoinSavedTransactionPriority(sharedPreferences); + break; + default: break; } @@ -154,6 +160,14 @@ Future defaultSettingsMigration( PreferencesKey.currentDefaultSettingsMigrationVersion, version); } +Future validateBitcoinSavedTransactionPriority(SharedPreferences sharedPreferences) async { + int? savedBitcoinPriority = sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority); + if (!BitcoinTransactionPriority.all.any((element) => element.raw == savedBitcoinPriority)) { + await sharedPreferences.setInt( + PreferencesKey.bitcoinTransactionPriority, BitcoinTransactionPriority.defaultPriority.raw); + } +} + Future addOnionNode(Box nodes) async { final onionNodeUri = "cakexmrl7bonq7ovjka5kuwuyd3f7qnkz6z6s6dmsy3uckwra7bvggyd.onion:18081"; diff --git a/lib/main.dart b/lib/main.dart index eaabb8339..19f89feb3 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -129,7 +129,7 @@ Future main() async { exchangeTemplates: exchangeTemplates, transactionDescriptions: transactionDescriptions, secureStorage: secureStorage, - initialMigrationVersion: 18); + initialMigrationVersion: 19); runApp(App()); } catch (e, stacktrace) { runApp(MaterialApp(