mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-11 05:14:46 +00:00
Merge pull request #673 from cake-tech/set-default-values-for-transaction-priority
Validate bitcoin saved transaction priority
This commit is contained in:
commit
3d3c22c259
3 changed files with 17 additions and 17 deletions
|
@ -21,22 +21,6 @@ class MoneroTransactionPriority extends TransactionPriority {
|
||||||
static const fastest = MoneroTransactionPriority(title: 'Fastest', raw: 4);
|
static const fastest = MoneroTransactionPriority(title: 'Fastest', raw: 4);
|
||||||
static const standard = slow;
|
static const standard = slow;
|
||||||
|
|
||||||
|
|
||||||
static List<MoneroTransactionPriority> 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}) {
|
static MoneroTransactionPriority deserialize({required int raw}) {
|
||||||
switch (raw) {
|
switch (raw) {
|
||||||
case 0:
|
case 0:
|
||||||
|
|
|
@ -139,6 +139,10 @@ Future defaultSettingsMigration(
|
||||||
await addOnionNode(nodes);
|
await addOnionNode(nodes);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 19:
|
||||||
|
await validateBitcoinSavedTransactionPriority(sharedPreferences);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -154,6 +158,18 @@ Future defaultSettingsMigration(
|
||||||
PreferencesKey.currentDefaultSettingsMigrationVersion, version);
|
PreferencesKey.currentDefaultSettingsMigrationVersion, version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> validateBitcoinSavedTransactionPriority(SharedPreferences sharedPreferences) async {
|
||||||
|
if (bitcoin == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final int? savedBitcoinPriority =
|
||||||
|
sharedPreferences.getInt(PreferencesKey.bitcoinTransactionPriority);
|
||||||
|
if (!bitcoin!.getTransactionPriorities().any((element) => element.raw == savedBitcoinPriority)) {
|
||||||
|
await sharedPreferences.setInt(
|
||||||
|
PreferencesKey.bitcoinTransactionPriority, bitcoin!.getMediumTransactionPriority().serialize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Future<void> addOnionNode(Box<Node> nodes) async {
|
Future<void> addOnionNode(Box<Node> nodes) async {
|
||||||
final onionNodeUri = "cakexmrl7bonq7ovjka5kuwuyd3f7qnkz6z6s6dmsy3uckwra7bvggyd.onion:18081";
|
final onionNodeUri = "cakexmrl7bonq7ovjka5kuwuyd3f7qnkz6z6s6dmsy3uckwra7bvggyd.onion:18081";
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ Future<void> main() async {
|
||||||
exchangeTemplates: exchangeTemplates,
|
exchangeTemplates: exchangeTemplates,
|
||||||
transactionDescriptions: transactionDescriptions,
|
transactionDescriptions: transactionDescriptions,
|
||||||
secureStorage: secureStorage,
|
secureStorage: secureStorage,
|
||||||
initialMigrationVersion: 18);
|
initialMigrationVersion: 19);
|
||||||
runApp(App());
|
runApp(App());
|
||||||
} catch (e, stacktrace) {
|
} catch (e, stacktrace) {
|
||||||
runApp(MaterialApp(
|
runApp(MaterialApp(
|
||||||
|
|
Loading…
Reference in a new issue