From d8dad7f0b3fc9e82857f10caabcbe17f399dfb38 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 29 May 2025 10:29:56 -0600 Subject: [PATCH 1/7] equality check fix --- lib/db/migrate_wallets_to_isar.dart | 108 ++++++++++++++-------------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/lib/db/migrate_wallets_to_isar.dart b/lib/db/migrate_wallets_to_isar.dart index cd54a4063..1b5e98b5a 100644 --- a/lib/db/migrate_wallets_to_isar.dart +++ b/lib/db/migrate_wallets_to_isar.dart @@ -20,14 +20,17 @@ Future migrateWalletsToIsar({ await MainDB.instance.initMainDB(); // ensure fresh - await MainDB.instance.isar - .writeTxn(() async => await MainDB.instance.isar.transactionV2s.clear()); + await MainDB.instance.isar.writeTxn( + () async => await MainDB.instance.isar.transactionV2s.clear(), + ); - final allWalletsBox = - await DB.instance.hive.openBox(DB.boxNameAllWalletsData); + final allWalletsBox = await DB.instance.hive.openBox( + DB.boxNameAllWalletsData, + ); - final names = DB.instance - .get(boxName: DB.boxNameAllWalletsData, key: 'names') as Map?; + final names = + DB.instance.get(boxName: DB.boxNameAllWalletsData, key: 'names') + as Map?; if (names == null) { // no wallets to migrate @@ -37,27 +40,23 @@ Future migrateWalletsToIsar({ // // Parse the old data from the Hive map into a nice list // - final List< - ({ - String coinIdentifier, - String name, - String walletId, - })> oldInfo = Map.from(names).values.map((e) { - final map = e as Map; - return ( - coinIdentifier: map["coin"] as String, - walletId: map["id"] as String, - name: map["name"] as String, - ); - }).toList(); + final List<({String coinIdentifier, String name, String walletId})> oldInfo = + Map.from(names).values.map((e) { + final map = e as Map; + return ( + coinIdentifier: map["coin"] as String, + walletId: map["id"] as String, + name: map["name"] as String, + ); + }).toList(); // // Get current ordered list of favourite wallet Ids // final List favourites = - (await DB.instance.hive.openBox(DB.boxNameFavoriteWallets)) - .values - .toList(); + (await DB.instance.hive.openBox( + DB.boxNameFavoriteWallets, + )).values.toList(); final List<(WalletInfo, WalletInfoMeta)> newInfo = []; final List tokenInfo = []; @@ -72,10 +71,11 @@ Future migrateWalletsToIsar({ // // First handle transaction notes // - final newNoteCount = await MainDB.instance.isar.transactionNotes - .where() - .walletIdEqualTo(old.walletId) - .count(); + final newNoteCount = + await MainDB.instance.isar.transactionNotes + .where() + .walletIdEqualTo(old.walletId) + .count(); if (newNoteCount == 0) { final map = walletBox.get('notes') as Map?; @@ -108,18 +108,18 @@ Future migrateWalletsToIsar({ // final Map otherData = {}; - final List? tokenContractAddresses = walletBox.get( - "ethTokenContracts", - ) as List?; + final List? tokenContractAddresses = + walletBox.get("ethTokenContracts") as List?; if (tokenContractAddresses?.isNotEmpty == true) { otherData[WalletInfoKeys.tokenContractAddresses] = tokenContractAddresses; for (final address in tokenContractAddresses!) { - final contract = await MainDB.instance.isar.ethContracts - .where() - .addressEqualTo(address) - .findFirst(); + final contract = + await MainDB.instance.isar.ethContracts + .where() + .addressEqualTo(address) + .findFirst(); if (contract != null) { tokenInfo.add( TokenWalletInfo( @@ -133,7 +133,7 @@ Future migrateWalletsToIsar({ } // epiccash specifics - if (old.coinIdentifier == Epiccash(CryptoCurrencyNetwork.main)) { + if (old.coinIdentifier == Epiccash(CryptoCurrencyNetwork.main).identifier) { final epicWalletInfo = ExtraEpiccashWalletInfo.fromMap({ "receivingIndex": walletBox.get("receivingIndex") as int? ?? 0, "changeIndex": walletBox.get("changeIndex") as int? ?? 0, @@ -149,8 +149,9 @@ Future migrateWalletsToIsar({ } else if (old.coinIdentifier == Firo(CryptoCurrencyNetwork.main).identifier || old.coinIdentifier == Firo(CryptoCurrencyNetwork.test).identifier) { - otherData[WalletInfoKeys.lelantusCoinIsarRescanRequired] = walletBox - .get(WalletInfoKeys.lelantusCoinIsarRescanRequired) as bool? ?? + otherData[WalletInfoKeys.lelantusCoinIsarRescanRequired] = + walletBox.get(WalletInfoKeys.lelantusCoinIsarRescanRequired) + as bool? ?? true; } @@ -161,8 +162,9 @@ Future migrateWalletsToIsar({ final infoMeta = WalletInfoMeta( walletId: old.walletId, - isMnemonicVerified: allWalletsBox - .get("${old.walletId}_mnemonicHasBeenVerified") as bool? ?? + isMnemonicVerified: + allWalletsBox.get("${old.walletId}_mnemonicHasBeenVerified") + as bool? ?? false, ); @@ -170,19 +172,15 @@ Future migrateWalletsToIsar({ coinName: old.coinIdentifier, walletId: old.walletId, name: old.name, - mainAddressType: AppConfig.getCryptoCurrencyFor(old.coinIdentifier)! - .defaultAddressType, + mainAddressType: + AppConfig.getCryptoCurrencyFor( + old.coinIdentifier, + )!.defaultAddressType, favouriteOrderIndex: favourites.indexOf(old.walletId), - cachedChainHeight: walletBox.get( - DBKeys.storedChainHeight, - ) as int? ?? - 0, - cachedBalanceString: walletBox.get( - DBKeys.cachedBalance, - ) as String?, - cachedBalanceSecondaryString: walletBox.get( - DBKeys.cachedBalanceSecondary, - ) as String?, + cachedChainHeight: walletBox.get(DBKeys.storedChainHeight) as int? ?? 0, + cachedBalanceString: walletBox.get(DBKeys.cachedBalance) as String?, + cachedBalanceSecondaryString: + walletBox.get(DBKeys.cachedBalanceSecondary) as String?, otherDataJsonString: jsonEncode(otherData), ); @@ -197,10 +195,12 @@ Future migrateWalletsToIsar({ if (newInfo.isNotEmpty) { await MainDB.instance.isar.writeTxn(() async { - await MainDB.instance.isar.walletInfo - .putAll(newInfo.map((e) => e.$1).toList()); - await MainDB.instance.isar.walletInfoMeta - .putAll(newInfo.map((e) => e.$2).toList()); + await MainDB.instance.isar.walletInfo.putAll( + newInfo.map((e) => e.$1).toList(), + ); + await MainDB.instance.isar.walletInfoMeta.putAll( + newInfo.map((e) => e.$2).toList(), + ); if (tokenInfo.isNotEmpty) { await MainDB.instance.isar.tokenWalletInfo.putAll(tokenInfo); From 292b494f092ba25ace2a5656a4e1df529503eefa Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 29 May 2025 11:14:16 -0600 Subject: [PATCH 2/7] remove lelantus --- .github/workflows/test.yaml | 8 - .gitignore | 1 - .gitmodules | 3 - crypto_plugins/flutter_liblelantus | 1 - docs/building.md | 1 - ios/Podfile.lock | 6 - lib/db/db_version_migration.dart | 288 +-- lib/db/isar/main_db.dart | 180 +- lib/db/migrate_wallets_to_isar.dart | 7 - .../cached_electrumx_client.dart | 163 +- .../models/firo_specific/lelantus_coin.dart | 81 - .../models/firo_specific/lelantus_coin.g.dart | 1629 ----------------- lib/models/isar/models/isar_models.dart | 1 - lib/models/lelantus_fee_data.dart | 21 - lib/models/models.dart | 1 - ...w_wallet_recovery_phrase_warning_view.dart | 7 +- .../restore_options_view.dart | 25 +- .../restore_view_only_wallet_view.dart | 9 - .../restore_wallet_view.dart | 8 - .../verify_recovery_phrase_view.dart | 6 - .../send_view/confirm_transaction_view.dart | 9 - lib/pages/send_view/send_view.dart | 99 +- .../firo_balance_selection_sheet.dart | 201 +- .../transaction_fee_selection_sheet.dart | 12 - .../global_settings_view/about_view.dart | 84 +- .../helpers/restore_create_backup.dart | 11 +- .../lelantus_settings_view.dart | 214 --- .../wallet_settings_wallet_settings_view.dart | 39 +- .../wallet_balance_toggle_sheet.dart | 160 +- .../sub_widgets/wallet_summary_info.dart | 5 - lib/pages/wallet_view/wallet_view.dart | 138 +- .../lelantus_coins/lelantus_coins_view.dart | 134 -- .../desktop_balance_toggle_button.dart | 40 +- .../wallet_view/sub_widgets/desktop_send.dart | 79 +- .../sub_widgets/desktop_send_fee_form.dart | 46 +- .../sub_widgets/desktop_wallet_features.dart | 24 +- .../sub_widgets/desktop_wallet_summary.dart | 5 - .../firo_desktop_wallet_summary.dart | 18 +- .../more_features/more_features_dialog.dart | 176 -- .../settings_menu/desktop_about_view.dart | 373 ++-- .../ui/preview_tx_button_state_provider.dart | 43 +- ...public_private_balance_state_provider.dart | 11 +- lib/route_generator.dart | 27 +- lib/utilities/git_status.dart | 73 +- lib/utilities/prefs.dart | 2 +- lib/utilities/wallet_tools.dart | 24 +- lib/wallets/api/lelantus_ffi_wrapper.dart | 551 ------ lib/wallets/isar/models/wallet_info.dart | 3 - lib/wallets/models/tx_data.dart | 28 +- lib/wallets/wallet/impl/firo_wallet.dart | 75 +- lib/wallets/wallet/wallet.dart | 8 - .../lelantus_interface.dart | 1215 ------------ .../spark_interface.dart | 3 +- lib/widgets/desktop/desktop_fee_dialog.dart | 34 - macos/Flutter/GeneratedPluginRegistrant.swift | 2 - macos/Podfile.lock | 6 - pubspec.lock | 7 - scripts/android/build_all.sh | 2 - scripts/android/build_all_campfire.sh | 2 - scripts/android/build_all_duo.sh | 2 - .../ios/Runner.xcodeproj/project.pbxproj | 28 - .../app_config/templates/linux/CMakeLists.txt | 3 - .../macos/Runner.xcodeproj/project.pbxproj | 12 - scripts/app_config/templates/pubspec.template | 3 - .../templates/windows/CMakeLists.txt | 3 - scripts/ios/build_all.sh | 2 - scripts/ios/build_all_campfire.sh | 2 - scripts/ios/build_all_duo.sh | 2 - scripts/linux/build_all.sh | 1 - scripts/linux/build_all_campfire.sh | 1 - scripts/linux/build_all_duo.sh | 3 +- scripts/macos/build_all.sh | 1 - scripts/macos/build_all_campfire.sh | 1 - scripts/macos/build_all_duo.sh | 1 - scripts/windows/build_all.sh | 1 - scripts/windows/build_all_campfire.sh | 1 - scripts/windows/build_all_duo.sh | 1 - scripts/windows/deps.sh | 2 - test/models/lelantus_fee_data_test.dart | 10 - 79 files changed, 520 insertions(+), 5989 deletions(-) delete mode 160000 crypto_plugins/flutter_liblelantus delete mode 100644 lib/models/isar/models/firo_specific/lelantus_coin.dart delete mode 100644 lib/models/isar/models/firo_specific/lelantus_coin.g.dart delete mode 100644 lib/models/lelantus_fee_data.dart delete mode 100644 lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart delete mode 100644 lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart delete mode 100644 lib/wallets/api/lelantus_ffi_wrapper.dart delete mode 100644 lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart delete mode 100644 test/models/lelantus_fee_data_test.dart diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 702940c60..e46a16c6c 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,14 +25,6 @@ jobs: sudo apt clean sudo apt update sudo apt install -y unzip automake build-essential file pkg-config git python libtool libtinfo5 cmake openjdk-8-jre-headless libgit2-dev clang libncurses5-dev libncursesw5-dev zlib1g-dev llvm debhelper libclang-dev opencl-headers libssl-dev ocl-icd-opencl-dev libc6-dev-i386 - - name: Build Lelantus - run: | - cd crypto_plugins/flutter_liblelantus/scripts/linux/ - ./build_all.sh - - name: Build Monero - run: | - cd crypto_plugins/flutter_libmonero/scripts/linux/ - ./build_monero_all.sh - name: Build Epic Cash run: | cd crypto_plugins/flutter_libepiccash/scripts/linux/ diff --git a/.gitignore b/.gitignore index 7b550e43e..30fb5a6e1 100644 --- a/.gitignore +++ b/.gitignore @@ -63,7 +63,6 @@ scripts/**/build /lib/external_api_keys.dart libepic_cash_wallet.dll -libmobileliblelantus.dll libtor_ffi.dll flutter_libsparkmobile.dll secp256k1.dll diff --git a/.gitmodules b/.gitmodules index 2186826df..d9a561cc1 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "crypto_plugins/flutter_libepiccash"] path = crypto_plugins/flutter_libepiccash url = https://github.com/cypherstack/flutter_libepiccash.git -[submodule "crypto_plugins/flutter_liblelantus"] - path = crypto_plugins/flutter_liblelantus - url = https://github.com/cypherstack/flutter_liblelantus.git [submodule "crypto_plugins/frostdart"] path = crypto_plugins/frostdart url = https://github.com/cypherstack/frostdart diff --git a/crypto_plugins/flutter_liblelantus b/crypto_plugins/flutter_liblelantus deleted file mode 160000 index 081ae89d8..000000000 --- a/crypto_plugins/flutter_liblelantus +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 081ae89d8f47f5575a19dc03663727cf0d271f2c diff --git a/docs/building.md b/docs/building.md index 1475a7d6d..3ee68cf98 100644 --- a/docs/building.md +++ b/docs/building.md @@ -283,7 +283,6 @@ The WSL2 host may optionally be navigated to the `stack_wallet` repository on th If the DLLs were built on the WSL filesystem instead of on Windows, copy the resulting `dll`s to their respective positions on the Windows host: - `stack_wallet/crypto_plugins/flutter_libepiccash/scripts/windows/build/libepic_cash_wallet.dll` -- `stack_wallet/crypto_plugins/flutter_liblelantus/scripts/windows/build/libmobileliblelantus.dll` diff --git a/ios/Podfile.lock b/ios/Podfile.lock index add8f4224..13a199bd8 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -65,8 +65,6 @@ PODS: - Flutter - isar_flutter_libs (1.0.0): - Flutter - - lelantus (0.0.1): - - Flutter - local_auth_darwin (0.0.1): - Flutter - FlutterMacOS @@ -129,7 +127,6 @@ DEPENDENCIES: - frostdart (from `.symlinks/plugins/frostdart/ios`) - integration_test (from `.symlinks/plugins/integration_test/ios`) - isar_flutter_libs (from `.symlinks/plugins/isar_flutter_libs/ios`) - - lelantus (from `.symlinks/plugins/lelantus/ios`) - local_auth_darwin (from `.symlinks/plugins/local_auth_darwin/darwin`) - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`) @@ -186,8 +183,6 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/integration_test/ios" isar_flutter_libs: :path: ".symlinks/plugins/isar_flutter_libs/ios" - lelantus: - :path: ".symlinks/plugins/lelantus/ios" local_auth_darwin: :path: ".symlinks/plugins/local_auth_darwin/darwin" package_info_plus: @@ -230,7 +225,6 @@ SPEC CHECKSUMS: frostdart: 4c72b69ccac2f13ede744107db046a125acce597 integration_test: 252f60fa39af5e17c3aa9899d35d908a0721b573 isar_flutter_libs: fdf730ca925d05687f36d7f1d355e482529ed097 - lelantus: 417f0221260013dfc052cae9cf4b741b6479edba local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb package_info_plus: c0502532a26c7662a62a356cebe2692ec5fe4ec4 diff --git a/lib/db/db_version_migration.dart b/lib/db/db_version_migration.dart index e18c4b720..8ef1f2bb5 100644 --- a/lib/db/db_version_migration.dart +++ b/lib/db/db_version_migration.dart @@ -12,7 +12,6 @@ import 'package:isar/isar.dart'; import 'package:tuple/tuple.dart'; import '../app_config.dart'; -import '../electrumx_rpc/electrumx_client.dart'; import '../models/contact.dart'; import '../models/exchange/change_now/exchange_transaction.dart'; import '../models/exchange/response_objects/trade.dart'; @@ -20,9 +19,7 @@ import '../models/isar/models/blockchain_data/address.dart'; import '../models/isar/models/contact_entry.dart' as isar_contact; import '../models/isar/models/isar_models.dart' as isar_models; import '../models/models.dart'; -import '../models/node_model.dart'; import '../services/mixins/wallet_db.dart'; -import '../services/node_service.dart'; import '../services/wallets_service.dart'; import '../utilities/amount/amount.dart'; import '../utilities/constants.dart'; @@ -50,107 +47,11 @@ class DbVersionMigrator with WalletDB { case 0: await DB.instance.hive.openBox(DB.boxNameAllWalletsData); await DB.instance.hive.openBox(DB.boxNamePrefs); - final walletsService = WalletsService(); - final nodeService = NodeService(secureStorageInterface: secureStore); final prefs = Prefs.instance; - final walletInfoList = await walletsService.walletNames; await prefs.init(); - ElectrumXClient? client; - int? latestSetId; - - final firo = Firo(CryptoCurrencyNetwork.main); - // only instantiate client if there are firo wallets - if (walletInfoList.values - .any((element) => element.coinIdentifier == firo.identifier)) { - await DB.instance.hive.openBox(DB.boxNameNodeModels); - await DB.instance.hive.openBox(DB.boxNamePrimaryNodes); - final node = - nodeService.getPrimaryNodeFor(currency: firo) ?? firo.defaultNode; - final List failovers = nodeService - .failoverNodesFor(currency: firo) - .map( - (e) => ElectrumXNode( - address: e.host, - port: e.port, - name: e.name, - id: e.id, - useSSL: e.useSSL, - torEnabled: e.torEnabled, - clearnetEnabled: e.clearnetEnabled, - ), - ) - .toList(); - - client = ElectrumXClient.from( - node: ElectrumXNode( - address: node.host, - port: node.port, - name: node.name, - id: node.id, - useSSL: node.useSSL, - torEnabled: node.torEnabled, - clearnetEnabled: node.clearnetEnabled, - ), - prefs: prefs, - failovers: failovers, - cryptoCurrency: Firo(CryptoCurrencyNetwork.main), - ); - - try { - latestSetId = await client.getLelantusLatestCoinId(); - } catch (e, s) { - // default to 2 for now - latestSetId = 2; - Logging.instance.w( - "Failed to fetch latest coin id during firo db migrate: $e \nUsing a default value of 2", - error: e, - stackTrace: s, - ); - } - } - - for (final walletInfo in walletInfoList.values) { - // migrate each firo wallet's lelantus coins - if (walletInfo.coinIdentifier == firo.identifier) { - await DB.instance.hive.openBox(walletInfo.walletId); - final _lelantusCoins = DB.instance.get( - boxName: walletInfo.walletId, - key: '_lelantus_coins', - ) as List?; - final List> lelantusCoins = []; - for (final lCoin in _lelantusCoins ?? []) { - lelantusCoins - .add({lCoin.keys.first: lCoin.values.first as LelantusCoin}); - } - - final List> coins = []; - for (final element in lelantusCoins) { - final LelantusCoin coin = element.values.first; - int anonSetId = coin.anonymitySetId; - if (coin.anonymitySetId == 1 && - (coin.publicCoin == '' || - coin.publicCoin == "jmintData.publicCoin")) { - anonSetId = latestSetId!; - } - coins.add({ - element.keys.first: LelantusCoin( - coin.index, - coin.value, - coin.publicCoin, - coin.txId, - anonSetId, - coin.isUsed, - ), - }); - } - await DB.instance.put( - boxName: walletInfo.walletId, - key: '_lelantus_coins', - value: coins, - ); - } - } + // nothing happens here anymore. + // Kept for legacy reasons after removing old lelantus // update version await DB.instance.put( @@ -165,8 +66,9 @@ class DbVersionMigrator with WalletDB { case 1: await DB.instance.hive.openBox(DB.boxNameTrades); await DB.instance.hive.openBox(DB.boxNameTradesV2); - final trades = - DB.instance.values(boxName: DB.boxNameTrades); + final trades = DB.instance.values( + boxName: DB.boxNameTrades, + ); for (final old in trades) { if (old.statusObject != null) { @@ -208,9 +110,7 @@ class DbVersionMigrator with WalletDB { case 3: // clear possible broken firo cache await DB.instance.clearSharedTransactionCache( - currency: Firo( - CryptoCurrencyNetwork.test, - ), + currency: Firo(CryptoCurrencyNetwork.test), ); // update version @@ -244,8 +144,8 @@ class DbVersionMigrator with WalletDB { final themeName = DB.instance.get(boxName: "theme", key: "colorScheme") - as String? ?? - "light"; + as String? ?? + "light"; await DB.instance.put( boxName: DB.boxNamePrefs, @@ -269,11 +169,12 @@ class DbVersionMigrator with WalletDB { final count = await MainDB.instance.isar.addresses.count(); // add change/receiving tags to address labels for (var i = 0; i < count; i += 50) { - final addresses = await MainDB.instance.isar.addresses - .where() - .offset(i) - .limit(50) - .findAll(); + final addresses = + await MainDB.instance.isar.addresses + .where() + .offset(i) + .limit(50) + .findAll(); final List labels = []; for (final address in addresses) { @@ -301,11 +202,14 @@ class DbVersionMigrator with WalletDB { // update/create label if tags is not empty if (tags != null) { - isar_models.AddressLabel? label = await MainDB - .instance.isar.addressLabels - .where() - .addressStringWalletIdEqualTo(address.value, address.walletId) - .findFirst(); + isar_models.AddressLabel? label = + await MainDB.instance.isar.addressLabels + .where() + .addressStringWalletIdEqualTo( + address.value, + address.walletId, + ) + .findFirst(); if (label == null) { label = isar_models.AddressLabel( walletId: address.walletId, @@ -363,12 +267,13 @@ class DbVersionMigrator with WalletDB { Bitcoincash(CryptoCurrencyNetwork.main).identifier || info.coinIdentifier == Bitcoincash(CryptoCurrencyNetwork.test).identifier) { - final ids = await MainDB.instance - .getAddresses(walletId) - .filter() - .typeEqualTo(isar_models.AddressType.p2sh) - .idProperty() - .findAll(); + final ids = + await MainDB.instance + .getAddresses(walletId) + .filter() + .typeEqualTo(isar_models.AddressType.p2sh) + .idProperty() + .findAll(); await MainDB.instance.isar.writeTxn(() async { await MainDB.instance.isar.addresses.deleteAll(ids); @@ -490,7 +395,7 @@ class DbVersionMigrator with WalletDB { const rcvIndex = 0; final List> - transactionsData = []; + transactionsData = []; if (txnData != null) { final txns = txnData.getAllTransactions(); @@ -501,15 +406,17 @@ class DbVersionMigrator with WalletDB { walletId: walletId, txid: tx.txid, timestamp: tx.timestamp, - type: isIncoming - ? isar_models.TransactionType.incoming - : isar_models.TransactionType.outgoing, + type: + isIncoming + ? isar_models.TransactionType.incoming + : isar_models.TransactionType.outgoing, subType: isar_models.TransactionSubType.none, amount: tx.amount, - amountString: Amount( - rawValue: BigInt.from(tx.amount), - fractionDigits: epic.fractionDigits, - ).toJsonString(), + amountString: + Amount( + rawValue: BigInt.from(tx.amount), + fractionDigits: epic.fractionDigits, + ).toJsonString(), fee: tx.fees, height: tx.height, isCancelled: tx.isCancelled, @@ -531,12 +438,14 @@ class DbVersionMigrator with WalletDB { publicKey: [], derivationIndex: isIncoming ? rcvIndex : -1, derivationPath: null, - type: isIncoming - ? isar_models.AddressType.mimbleWimble - : isar_models.AddressType.unknown, - subType: isIncoming - ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.unknown, + type: + isIncoming + ? isar_models.AddressType.mimbleWimble + : isar_models.AddressType.unknown, + subType: + isIncoming + ? isar_models.AddressSubType.receiving + : isar_models.AddressSubType.unknown, ); transactionsData.add(Tuple2(iTx, address)); } @@ -594,25 +503,28 @@ class DbVersionMigrator with WalletDB { final crypto = AppConfig.getCryptoCurrencyFor(info.coinIdentifier)!; for (var i = 0; i < count; i += 50) { - final txns = await MainDB.instance - .getTransactions(walletId) - .offset(i) - .limit(50) - .findAll(); + final txns = + await MainDB.instance + .getTransactions(walletId) + .offset(i) + .limit(50) + .findAll(); // migrate amount to serialized amount string - final txnsData = txns - .map( - (tx) => Tuple2( - tx - ..amountString = Amount( - rawValue: BigInt.from(tx.amount), - fractionDigits: crypto.fractionDigits, - ).toJsonString(), - tx.address.value, - ), - ) - .toList(); + final txnsData = + txns + .map( + (tx) => Tuple2( + tx + ..amountString = + Amount( + rawValue: BigInt.from(tx.amount), + fractionDigits: crypto.fractionDigits, + ).toJsonString(), + tx.address.value, + ), + ) + .toList(); // update db records await MainDB.instance.addNewTransactionData(txnsData, walletId); @@ -621,17 +533,16 @@ class DbVersionMigrator with WalletDB { } Future _v9() async { - final addressBookBox = - await DB.instance.hive.openBox(DB.boxNameAddressBook); + final addressBookBox = await DB.instance.hive.openBox( + DB.boxNameAddressBook, + ); await MainDB.instance.initMainDB(); final keys = List.from(addressBookBox.keys); final contacts = keys .map( (id) => Contact.fromJson( - Map.from( - addressBookBox.get(id) as Map, - ), + Map.from(addressBookBox.get(id) as Map), ), ) .toList(growable: false); @@ -672,65 +583,12 @@ class DbVersionMigrator with WalletDB { Future _v10(SecureStorageInterface secureStore) async { await DB.instance.hive.openBox(DB.boxNameAllWalletsData); await DB.instance.hive.openBox(DB.boxNamePrefs); - final walletsService = WalletsService(); final prefs = Prefs.instance; - final walletInfoList = await walletsService.walletNames; await prefs.init(); await MainDB.instance.initMainDB(); - final firo = Firo(CryptoCurrencyNetwork.main); - - for (final walletId in walletInfoList.keys) { - final info = walletInfoList[walletId]!; - assert(info.walletId == walletId); - - if (info.coinIdentifier == firo.identifier && - MainDB.instance.isar.lelantusCoins - .where() - .walletIdEqualTo(walletId) - .countSync() == - 0) { - final walletBox = await DB.instance.hive.openBox(walletId); - - final hiveLCoins = DB.instance.get( - boxName: walletId, - key: "_lelantus_coins", - ) as List? ?? - []; - - final jindexes = (DB.instance - .get(boxName: walletId, key: "jindex") as List? ?? - []) - .cast(); - - final List coins = []; - for (final e in hiveLCoins) { - final map = e as Map; - final lcoin = map.values.first as LelantusCoin; - - final isJMint = jindexes.contains(lcoin.index); - - final coin = isar_models.LelantusCoin( - walletId: walletId, - txid: lcoin.txId, - value: lcoin.value.toString(), - mintIndex: lcoin.index, - anonymitySetId: lcoin.anonymitySetId, - isUsed: lcoin.isUsed, - isJMint: isJMint, - otherData: null, - ); - - coins.add(coin); - } - - if (coins.isNotEmpty) { - await MainDB.instance.isar.writeTxn(() async { - await MainDB.instance.isar.lelantusCoins.putAll(coins); - }); - } - } - } + // nothing happens here anymore. + // Kept for legacy reasons after removing old lelantus } Future _v11(SecureStorageInterface secureStore) async { diff --git a/lib/db/isar/main_db.dart b/lib/db/isar/main_db.dart index a16fb2b9a..cb0163503 100644 --- a/lib/db/isar/main_db.dart +++ b/lib/db/isar/main_db.dart @@ -63,7 +63,6 @@ class MainDB { StackThemeSchema, ContactEntrySchema, OrdinalSchema, - LelantusCoinSchema, WalletInfoSchema, TransactionV2Schema, SparkCoinSchema, @@ -93,13 +92,16 @@ class MainDB { Future updateWalletInfo(WalletInfo walletInfo) async { try { await isar.writeTxn(() async { - final info = await isar.walletInfo - .where() - .walletIdEqualTo(walletInfo.walletId) - .findFirst(); + final info = + await isar.walletInfo + .where() + .walletIdEqualTo(walletInfo.walletId) + .findFirst(); if (info == null) { - throw Exception("updateWalletInfo() called with new WalletInfo." - " Use putWalletInfo()"); + throw Exception( + "updateWalletInfo() called with new WalletInfo." + " Use putWalletInfo()", + ); } await isar.walletInfo.deleteByWalletId(walletInfo.walletId); @@ -174,8 +176,7 @@ class MainDB { // addresses QueryBuilder getAddresses( String walletId, - ) => - isar.addresses.where().walletIdEqualTo(walletId); + ) => isar.addresses.where().walletIdEqualTo(walletId); Future putAddress(Address address) async { try { @@ -202,8 +203,10 @@ class MainDB { final List ids = []; await isar.writeTxn(() async { for (final address in addresses) { - final storedAddress = await isar.addresses - .getByValueWalletId(address.value, address.walletId); + final storedAddress = await isar.addresses.getByValueWalletId( + address.value, + address.walletId, + ); int id; if (storedAddress == null) { @@ -253,8 +256,7 @@ class MainDB { // transactions QueryBuilder getTransactions( String walletId, - ) => - isar.transactions.where().walletIdEqualTo(walletId); + ) => isar.transactions.where().walletIdEqualTo(walletId); Future putTransaction(Transaction transaction) async { try { @@ -294,20 +296,19 @@ class MainDB { QueryBuilder getUTXOsByAddress( String walletId, String address, - ) => - isar.utxos - .where() - .walletIdEqualTo(walletId) - .filter() - .addressEqualTo(address); + ) => isar.utxos + .where() + .walletIdEqualTo(walletId) + .filter() + .addressEqualTo(address); Future putUTXO(UTXO utxo) => isar.writeTxn(() async { - await isar.utxos.put(utxo); - }); + await isar.utxos.put(utxo); + }); Future putUTXOs(List utxos) => isar.writeTxn(() async { - await isar.utxos.putAll(utxos); - }); + await isar.utxos.putAll(utxos); + }); Future updateUTXOs(String walletId, List utxos) async { bool newUTXO = false; @@ -315,10 +316,11 @@ class MainDB { final set = utxos.toSet(); for (final utxo in utxos) { // check if utxo exists in db and update accordingly - final storedUtxo = await isar.utxos - .where() - .txidWalletIdVoutEqualTo(utxo.txid, utxo.walletId, utxo.vout) - .findFirst(); + final storedUtxo = + await isar.utxos + .where() + .txidWalletIdVoutEqualTo(utxo.txid, utxo.walletId, utxo.vout) + .findFirst(); if (storedUtxo != null) { // update @@ -344,17 +346,14 @@ class MainDB { return newUTXO; } - Stream watchUTXO({ - required Id id, - bool fireImmediately = false, - }) { + Stream watchUTXO({required Id id, bool fireImmediately = false}) { return isar.utxos.watchObject(id, fireImmediately: fireImmediately); } // transaction notes QueryBuilder - getTransactionNotes(String walletId) => - isar.transactionNotes.where().walletIdEqualTo(walletId); + getTransactionNotes(String walletId) => + isar.transactionNotes.where().walletIdEqualTo(walletId); Future putTransactionNote(TransactionNote transactionNote) => isar.writeTxn(() async { @@ -370,25 +369,23 @@ class MainDB { String walletId, String txid, ) async { - return isar.transactionNotes.getByTxidWalletId( - txid, - walletId, - ); + return isar.transactionNotes.getByTxidWalletId(txid, walletId); } Stream watchTransactionNote({ required Id id, bool fireImmediately = false, }) { - return isar.transactionNotes - .watchObject(id, fireImmediately: fireImmediately); + return isar.transactionNotes.watchObject( + id, + fireImmediately: fireImmediately, + ); } // address labels QueryBuilder getAddressLabels( String walletId, - ) => - isar.addressLabels.where().walletIdEqualTo(walletId); + ) => isar.addressLabels.where().walletIdEqualTo(walletId); Future putAddressLabel(AddressLabel addressLabel) => isar.writeTxn(() async { @@ -396,8 +393,8 @@ class MainDB { }); int putAddressLabelSync(AddressLabel addressLabel) => isar.writeTxnSync(() { - return isar.addressLabels.putSync(addressLabel); - }); + return isar.addressLabels.putSync(addressLabel); + }); Future putAddressLabels(List addressLabels) => isar.writeTxn(() async { @@ -453,59 +450,44 @@ class MainDB { // transactions for (int i = 0; i < transactionCount; i += paginateLimit) { - final txnIds = await getTransactions(walletId) - .offset(i) - .limit(paginateLimit) - .idProperty() - .findAll(); + final txnIds = + await getTransactions( + walletId, + ).offset(i).limit(paginateLimit).idProperty().findAll(); await isar.transactions.deleteAll(txnIds); } // transactions V2 for (int i = 0; i < transactionCountV2; i += paginateLimit) { - final txnIds = await isar.transactionV2s - .where() - .walletIdEqualTo(walletId) - .offset(i) - .limit(paginateLimit) - .idProperty() - .findAll(); + final txnIds = + await isar.transactionV2s + .where() + .walletIdEqualTo(walletId) + .offset(i) + .limit(paginateLimit) + .idProperty() + .findAll(); await isar.transactionV2s.deleteAll(txnIds); } // addresses for (int i = 0; i < addressCount; i += paginateLimit) { - final addressIds = await getAddresses(walletId) - .offset(i) - .limit(paginateLimit) - .idProperty() - .findAll(); + final addressIds = + await getAddresses( + walletId, + ).offset(i).limit(paginateLimit).idProperty().findAll(); await isar.addresses.deleteAll(addressIds); } // utxos for (int i = 0; i < utxoCount; i += paginateLimit) { - final utxoIds = await getUTXOs(walletId) - .offset(i) - .limit(paginateLimit) - .idProperty() - .findAll(); + final utxoIds = + await getUTXOs( + walletId, + ).offset(i).limit(paginateLimit).idProperty().findAll(); await isar.utxos.deleteAll(utxoIds); } - // lelantusCoins - await isar.lelantusCoins.where().walletIdEqualTo(walletId).deleteAll(); - // for (int i = 0; i < lelantusCoinCount; i += paginateLimit) { - // final lelantusCoinIds = await isar.lelantusCoins - // .where() - // .walletIdEqualTo(walletId) - // .offset(i) - // .limit(paginateLimit) - // .idProperty() - // .findAll(); - // await isar.lelantusCoins.deleteAll(lelantusCoinIds); - // } - // spark coins await isar.sparkCoins .where() @@ -519,11 +501,10 @@ class MainDB { await isar.writeTxn(() async { const paginateLimit = 50; for (int i = 0; i < addressLabelCount; i += paginateLimit) { - final labelIds = await getAddressLabels(walletId) - .offset(i) - .limit(paginateLimit) - .idProperty() - .findAll(); + final labelIds = + await getAddressLabels( + walletId, + ).offset(i).limit(paginateLimit).idProperty().findAll(); await isar.addressLabels.deleteAll(labelIds); } }); @@ -534,11 +515,10 @@ class MainDB { await isar.writeTxn(() async { const paginateLimit = 50; for (int i = 0; i < noteCount; i += paginateLimit) { - final labelIds = await getTransactionNotes(walletId) - .offset(i) - .limit(paginateLimit) - .idProperty() - .findAll(); + final labelIds = + await getTransactionNotes( + walletId, + ).offset(i).limit(paginateLimit).idProperty().findAll(); await isar.transactionNotes.deleteAll(labelIds); } }); @@ -591,10 +571,11 @@ class MainDB { final List ids = []; await isar.writeTxn(() async { for (final tx in transactions) { - final storedTx = await isar.transactionV2s - .where() - .txidWalletIdEqualTo(tx.txid, tx.walletId) - .findFirst(); + final storedTx = + await isar.transactionV2s + .where() + .txidWalletIdEqualTo(tx.txid, tx.walletId) + .findFirst(); Id id; if (storedTx == null) { @@ -630,22 +611,11 @@ class MainDB { isar.ethContracts.where().addressEqualTo(contractAddress).findFirstSync(); Future putEthContract(EthContract contract) => isar.writeTxn(() async { - return await isar.ethContracts.put(contract); - }); + return await isar.ethContracts.put(contract); + }); Future putEthContracts(List contracts) => isar.writeTxn(() async { await isar.ethContracts.putAll(contracts); }); - - // ========== Lelantus ======================================================= - - Future getHighestUsedMintIndex({required String walletId}) async { - return await isar.lelantusCoins - .where() - .walletIdEqualTo(walletId) - .sortByMintIndexDesc() - .mintIndexProperty() - .findFirst(); - } } diff --git a/lib/db/migrate_wallets_to_isar.dart b/lib/db/migrate_wallets_to_isar.dart index 1b5e98b5a..6433799f2 100644 --- a/lib/db/migrate_wallets_to_isar.dart +++ b/lib/db/migrate_wallets_to_isar.dart @@ -146,13 +146,6 @@ Future migrateWalletsToIsar({ otherData[WalletInfoKeys.epiccashData] = jsonEncode( epicWalletInfo.toMap(), ); - } else if (old.coinIdentifier == - Firo(CryptoCurrencyNetwork.main).identifier || - old.coinIdentifier == Firo(CryptoCurrencyNetwork.test).identifier) { - otherData[WalletInfoKeys.lelantusCoinIsarRescanRequired] = - walletBox.get(WalletInfoKeys.lelantusCoinIsarRescanRequired) - as bool? ?? - true; } // diff --git a/lib/electrumx_rpc/cached_electrumx_client.dart b/lib/electrumx_rpc/cached_electrumx_client.dart index c3b8ab56a..7c23af401 100644 --- a/lib/electrumx_rpc/cached_electrumx_client.dart +++ b/lib/electrumx_rpc/cached_electrumx_client.dart @@ -9,9 +9,6 @@ */ import 'dart:convert'; -import 'dart:math'; - -import 'package:string_validator/string_validator.dart'; import '../db/hive/db.dart'; import '../utilities/logger.dart'; @@ -27,105 +24,17 @@ class CachedElectrumXClient { factory CachedElectrumXClient.from({ required ElectrumXClient electrumXClient, - }) => - CachedElectrumXClient( - electrumXClient: electrumXClient, - ); - - Future> getAnonymitySet({ - required String groupId, - String blockhash = "", - required CryptoCurrency cryptoCurrency, - }) async { - try { - final box = - await DB.instance.getAnonymitySetCacheBox(currency: cryptoCurrency); - final cachedSet = box.get(groupId) as Map?; - - Map set; - - // null check to see if there is a cached set - if (cachedSet == null) { - set = { - "setId": groupId, - "blockHash": blockhash, - "setHash": "", - "coins": [], - }; - } else { - set = Map.from(cachedSet); - } - - final newSet = await electrumXClient.getLelantusAnonymitySet( - groupId: groupId, - blockhash: set["blockHash"] as String, - ); - - // update set with new data - if (newSet["setHash"] != "" && set["setHash"] != newSet["setHash"]) { - set["setHash"] = !isHexadecimal(newSet["setHash"] as String) - ? base64ToHex(newSet["setHash"] as String) - : newSet["setHash"]; - set["blockHash"] = !isHexadecimal(newSet["blockHash"] as String) - ? base64ToReverseHex(newSet["blockHash"] as String) - : newSet["blockHash"]; - for (int i = (newSet["coins"] as List).length - 1; i >= 0; i--) { - final dynamic newCoin = newSet["coins"][i]; - final List translatedCoin = []; - translatedCoin.add( - !isHexadecimal(newCoin[0] as String) - ? base64ToHex(newCoin[0] as String) - : newCoin[0], - ); - translatedCoin.add( - !isHexadecimal(newCoin[1] as String) - ? base64ToReverseHex(newCoin[1] as String) - : newCoin[1], - ); - try { - translatedCoin.add( - !isHexadecimal(newCoin[2] as String) - ? base64ToHex(newCoin[2] as String) - : newCoin[2], - ); - } catch (e) { - translatedCoin.add(newCoin[2]); - } - translatedCoin.add( - !isHexadecimal(newCoin[3] as String) - ? base64ToReverseHex(newCoin[3] as String) - : newCoin[3], - ); - set["coins"].insert(0, translatedCoin); - } - // save set to db - await box.put(groupId, set); - Logging.instance.d( - "Updated current anonymity set for ${cryptoCurrency.identifier} with group ID $groupId", - ); - } - - return set; - } catch (e, s) { - Logging.instance.e( - "Failed to process CachedElectrumX.getAnonymitySet(): ", - error: e, - stackTrace: s, - ); - rethrow; - } - } + }) => CachedElectrumXClient(electrumXClient: electrumXClient); String base64ToHex(String source) => - base64Decode(LineSplitter.split(source).join()) - .map((e) => e.toRadixString(16).padLeft(2, '0')) - .join(); + base64Decode( + LineSplitter.split(source).join(), + ).map((e) => e.toRadixString(16).padLeft(2, '0')).join(); String base64ToReverseHex(String source) => - base64Decode(LineSplitter.split(source).join()) - .reversed - .map((e) => e.toRadixString(16).padLeft(2, '0')) - .join(); + base64Decode( + LineSplitter.split(source).join(), + ).reversed.map((e) => e.toRadixString(16).padLeft(2, '0')).join(); /// Call electrumx getTransaction on a per coin basis, storing the result in local db if not already there. /// @@ -140,11 +49,8 @@ class CachedElectrumXClient { final cachedTx = box.get(txHash) as Map?; if (cachedTx == null) { - final Map result = - await electrumXClient.getTransaction( - txHash: txHash, - verbose: verbose, - ); + final Map result = await electrumXClient + .getTransaction(txHash: txHash, verbose: verbose); result.remove("hex"); result.remove("lelantusData"); @@ -171,57 +77,6 @@ class CachedElectrumXClient { } } - Future> getUsedCoinSerials({ - required CryptoCurrency cryptoCurrency, - int startNumber = 0, - }) async { - try { - final box = - await DB.instance.getUsedSerialsCacheBox(currency: cryptoCurrency); - - final _list = box.get("serials") as List?; - - final Set cachedSerials = - _list == null ? {} : List.from(_list).toSet(); - - startNumber = max( - max(0, startNumber), - cachedSerials.length - 100, // 100 being some arbitrary buffer - ); - - final serials = await electrumXClient.getLelantusUsedCoinSerials( - startNumber: startNumber, - ); - - final newSerials = List.from(serials["serials"] as List) - .map((e) => !isHexadecimal(e) ? base64ToHex(e) : e) - .toSet(); - - // ensure we are getting some overlap so we know we are not missing any - if (cachedSerials.isNotEmpty && newSerials.isNotEmpty) { - assert(cachedSerials.intersection(newSerials).isNotEmpty); - } - - cachedSerials.addAll(newSerials); - - final resultingList = cachedSerials.toList(); - - await box.put( - "serials", - resultingList, - ); - - return resultingList; - } catch (e, s) { - Logging.instance.e( - "Failed to process CachedElectrumX.getUsedCoinSerials(): ", - error: e, - stackTrace: s, - ); - rethrow; - } - } - /// Clear all cached transactions for the specified coin Future clearSharedTransactionCache({ required CryptoCurrency cryptoCurrency, diff --git a/lib/models/isar/models/firo_specific/lelantus_coin.dart b/lib/models/isar/models/firo_specific/lelantus_coin.dart deleted file mode 100644 index ca4c11919..000000000 --- a/lib/models/isar/models/firo_specific/lelantus_coin.dart +++ /dev/null @@ -1,81 +0,0 @@ -import 'package:isar/isar.dart'; - -part 'lelantus_coin.g.dart'; - -@collection -class LelantusCoin { - Id id = Isar.autoIncrement; - - @Index() - final String walletId; - - final String txid; - - final String value; // can't use BigInt in isar :shrug: - - @Index( - unique: true, - replace: false, - composite: [ - CompositeIndex("walletId"), - ], - ) - final int mintIndex; - - final int anonymitySetId; - - final bool isUsed; - - final bool isJMint; - - final String? otherData; - - LelantusCoin({ - required this.walletId, - required this.txid, - required this.value, - required this.mintIndex, - required this.anonymitySetId, - required this.isUsed, - required this.isJMint, - required this.otherData, - }); - - LelantusCoin copyWith({ - String? walletId, - String? publicCoin, - String? txid, - String? value, - int? mintIndex, - int? anonymitySetId, - bool? isUsed, - bool? isJMint, - String? otherData, - }) { - return LelantusCoin( - walletId: walletId ?? this.walletId, - txid: txid ?? this.txid, - value: value ?? this.value, - mintIndex: mintIndex ?? this.mintIndex, - anonymitySetId: anonymitySetId ?? this.anonymitySetId, - isUsed: isUsed ?? this.isUsed, - isJMint: isJMint ?? this.isJMint, - otherData: otherData ?? this.otherData, - ); - } - - @override - String toString() { - return 'LelantusCoin{' - 'id: $id, ' - 'walletId: $walletId, ' - 'txid: $txid, ' - 'value: $value, ' - 'mintIndex: $mintIndex, ' - 'anonymitySetId: $anonymitySetId, ' - 'otherData: $otherData, ' - 'isJMint: $isJMint, ' - 'isUsed: $isUsed' - '}'; - } -} diff --git a/lib/models/isar/models/firo_specific/lelantus_coin.g.dart b/lib/models/isar/models/firo_specific/lelantus_coin.g.dart deleted file mode 100644 index 1c0f4d405..000000000 --- a/lib/models/isar/models/firo_specific/lelantus_coin.g.dart +++ /dev/null @@ -1,1629 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'lelantus_coin.dart'; - -// ************************************************************************** -// IsarCollectionGenerator -// ************************************************************************** - -// coverage:ignore-file -// ignore_for_file: duplicate_ignore, non_constant_identifier_names, constant_identifier_names, invalid_use_of_protected_member, unnecessary_cast, prefer_const_constructors, lines_longer_than_80_chars, require_trailing_commas, inference_failure_on_function_invocation, unnecessary_parenthesis, unnecessary_raw_strings, unnecessary_null_checks, join_return_with_assignment, prefer_final_locals, avoid_js_rounded_ints, avoid_positional_boolean_parameters, always_specify_types - -extension GetLelantusCoinCollection on Isar { - IsarCollection get lelantusCoins => this.collection(); -} - -const LelantusCoinSchema = CollectionSchema( - name: r'LelantusCoin', - id: -6795633185033299066, - properties: { - r'anonymitySetId': PropertySchema( - id: 0, - name: r'anonymitySetId', - type: IsarType.long, - ), - r'isJMint': PropertySchema( - id: 1, - name: r'isJMint', - type: IsarType.bool, - ), - r'isUsed': PropertySchema( - id: 2, - name: r'isUsed', - type: IsarType.bool, - ), - r'mintIndex': PropertySchema( - id: 3, - name: r'mintIndex', - type: IsarType.long, - ), - r'otherData': PropertySchema( - id: 4, - name: r'otherData', - type: IsarType.string, - ), - r'txid': PropertySchema( - id: 5, - name: r'txid', - type: IsarType.string, - ), - r'value': PropertySchema( - id: 6, - name: r'value', - type: IsarType.string, - ), - r'walletId': PropertySchema( - id: 7, - name: r'walletId', - type: IsarType.string, - ) - }, - estimateSize: _lelantusCoinEstimateSize, - serialize: _lelantusCoinSerialize, - deserialize: _lelantusCoinDeserialize, - deserializeProp: _lelantusCoinDeserializeProp, - idName: r'id', - indexes: { - r'walletId': IndexSchema( - id: -1783113319798776304, - name: r'walletId', - unique: false, - replace: false, - properties: [ - IndexPropertySchema( - name: r'walletId', - type: IndexType.hash, - caseSensitive: true, - ) - ], - ), - r'mintIndex_walletId': IndexSchema( - id: -9147309777276196770, - name: r'mintIndex_walletId', - unique: true, - replace: false, - properties: [ - IndexPropertySchema( - name: r'mintIndex', - type: IndexType.value, - caseSensitive: false, - ), - IndexPropertySchema( - name: r'walletId', - type: IndexType.hash, - caseSensitive: true, - ) - ], - ) - }, - links: {}, - embeddedSchemas: {}, - getId: _lelantusCoinGetId, - getLinks: _lelantusCoinGetLinks, - attach: _lelantusCoinAttach, - version: '3.1.8', -); - -int _lelantusCoinEstimateSize( - LelantusCoin object, - List offsets, - Map> allOffsets, -) { - var bytesCount = offsets.last; - { - final value = object.otherData; - if (value != null) { - bytesCount += 3 + value.length * 3; - } - } - bytesCount += 3 + object.txid.length * 3; - bytesCount += 3 + object.value.length * 3; - bytesCount += 3 + object.walletId.length * 3; - return bytesCount; -} - -void _lelantusCoinSerialize( - LelantusCoin object, - IsarWriter writer, - List offsets, - Map> allOffsets, -) { - writer.writeLong(offsets[0], object.anonymitySetId); - writer.writeBool(offsets[1], object.isJMint); - writer.writeBool(offsets[2], object.isUsed); - writer.writeLong(offsets[3], object.mintIndex); - writer.writeString(offsets[4], object.otherData); - writer.writeString(offsets[5], object.txid); - writer.writeString(offsets[6], object.value); - writer.writeString(offsets[7], object.walletId); -} - -LelantusCoin _lelantusCoinDeserialize( - Id id, - IsarReader reader, - List offsets, - Map> allOffsets, -) { - final object = LelantusCoin( - anonymitySetId: reader.readLong(offsets[0]), - isJMint: reader.readBool(offsets[1]), - isUsed: reader.readBool(offsets[2]), - mintIndex: reader.readLong(offsets[3]), - otherData: reader.readStringOrNull(offsets[4]), - txid: reader.readString(offsets[5]), - value: reader.readString(offsets[6]), - walletId: reader.readString(offsets[7]), - ); - object.id = id; - return object; -} - -P _lelantusCoinDeserializeProp

( - IsarReader reader, - int propertyId, - int offset, - Map> allOffsets, -) { - switch (propertyId) { - case 0: - return (reader.readLong(offset)) as P; - case 1: - return (reader.readBool(offset)) as P; - case 2: - return (reader.readBool(offset)) as P; - case 3: - return (reader.readLong(offset)) as P; - case 4: - return (reader.readStringOrNull(offset)) as P; - case 5: - return (reader.readString(offset)) as P; - case 6: - return (reader.readString(offset)) as P; - case 7: - return (reader.readString(offset)) as P; - default: - throw IsarError('Unknown property with id $propertyId'); - } -} - -Id _lelantusCoinGetId(LelantusCoin object) { - return object.id; -} - -List> _lelantusCoinGetLinks(LelantusCoin object) { - return []; -} - -void _lelantusCoinAttach( - IsarCollection col, Id id, LelantusCoin object) { - object.id = id; -} - -extension LelantusCoinByIndex on IsarCollection { - Future getByMintIndexWalletId(int mintIndex, String walletId) { - return getByIndex(r'mintIndex_walletId', [mintIndex, walletId]); - } - - LelantusCoin? getByMintIndexWalletIdSync(int mintIndex, String walletId) { - return getByIndexSync(r'mintIndex_walletId', [mintIndex, walletId]); - } - - Future deleteByMintIndexWalletId(int mintIndex, String walletId) { - return deleteByIndex(r'mintIndex_walletId', [mintIndex, walletId]); - } - - bool deleteByMintIndexWalletIdSync(int mintIndex, String walletId) { - return deleteByIndexSync(r'mintIndex_walletId', [mintIndex, walletId]); - } - - Future> getAllByMintIndexWalletId( - List mintIndexValues, List walletIdValues) { - final len = mintIndexValues.length; - assert(walletIdValues.length == len, - 'All index values must have the same length'); - final values = >[]; - for (var i = 0; i < len; i++) { - values.add([mintIndexValues[i], walletIdValues[i]]); - } - - return getAllByIndex(r'mintIndex_walletId', values); - } - - List getAllByMintIndexWalletIdSync( - List mintIndexValues, List walletIdValues) { - final len = mintIndexValues.length; - assert(walletIdValues.length == len, - 'All index values must have the same length'); - final values = >[]; - for (var i = 0; i < len; i++) { - values.add([mintIndexValues[i], walletIdValues[i]]); - } - - return getAllByIndexSync(r'mintIndex_walletId', values); - } - - Future deleteAllByMintIndexWalletId( - List mintIndexValues, List walletIdValues) { - final len = mintIndexValues.length; - assert(walletIdValues.length == len, - 'All index values must have the same length'); - final values = >[]; - for (var i = 0; i < len; i++) { - values.add([mintIndexValues[i], walletIdValues[i]]); - } - - return deleteAllByIndex(r'mintIndex_walletId', values); - } - - int deleteAllByMintIndexWalletIdSync( - List mintIndexValues, List walletIdValues) { - final len = mintIndexValues.length; - assert(walletIdValues.length == len, - 'All index values must have the same length'); - final values = >[]; - for (var i = 0; i < len; i++) { - values.add([mintIndexValues[i], walletIdValues[i]]); - } - - return deleteAllByIndexSync(r'mintIndex_walletId', values); - } - - Future putByMintIndexWalletId(LelantusCoin object) { - return putByIndex(r'mintIndex_walletId', object); - } - - Id putByMintIndexWalletIdSync(LelantusCoin object, {bool saveLinks = true}) { - return putByIndexSync(r'mintIndex_walletId', object, saveLinks: saveLinks); - } - - Future> putAllByMintIndexWalletId(List objects) { - return putAllByIndex(r'mintIndex_walletId', objects); - } - - List putAllByMintIndexWalletIdSync(List objects, - {bool saveLinks = true}) { - return putAllByIndexSync(r'mintIndex_walletId', objects, - saveLinks: saveLinks); - } -} - -extension LelantusCoinQueryWhereSort - on QueryBuilder { - QueryBuilder anyId() { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(const IdWhereClause.any()); - }); - } -} - -extension LelantusCoinQueryWhere - on QueryBuilder { - QueryBuilder idEqualTo(Id id) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IdWhereClause.between( - lower: id, - upper: id, - )); - }); - } - - QueryBuilder idNotEqualTo( - Id id) { - return QueryBuilder.apply(this, (query) { - if (query.whereSort == Sort.asc) { - return query - .addWhereClause( - IdWhereClause.lessThan(upper: id, includeUpper: false), - ) - .addWhereClause( - IdWhereClause.greaterThan(lower: id, includeLower: false), - ); - } else { - return query - .addWhereClause( - IdWhereClause.greaterThan(lower: id, includeLower: false), - ) - .addWhereClause( - IdWhereClause.lessThan(upper: id, includeUpper: false), - ); - } - }); - } - - QueryBuilder idGreaterThan( - Id id, - {bool include = false}) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause( - IdWhereClause.greaterThan(lower: id, includeLower: include), - ); - }); - } - - QueryBuilder idLessThan(Id id, - {bool include = false}) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause( - IdWhereClause.lessThan(upper: id, includeUpper: include), - ); - }); - } - - QueryBuilder idBetween( - Id lowerId, - Id upperId, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IdWhereClause.between( - lower: lowerId, - includeLower: includeLower, - upper: upperId, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder walletIdEqualTo( - String walletId) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IndexWhereClause.equalTo( - indexName: r'walletId', - value: [walletId], - )); - }); - } - - QueryBuilder - walletIdNotEqualTo(String walletId) { - return QueryBuilder.apply(this, (query) { - if (query.whereSort == Sort.asc) { - return query - .addWhereClause(IndexWhereClause.between( - indexName: r'walletId', - lower: [], - upper: [walletId], - includeUpper: false, - )) - .addWhereClause(IndexWhereClause.between( - indexName: r'walletId', - lower: [walletId], - includeLower: false, - upper: [], - )); - } else { - return query - .addWhereClause(IndexWhereClause.between( - indexName: r'walletId', - lower: [walletId], - includeLower: false, - upper: [], - )) - .addWhereClause(IndexWhereClause.between( - indexName: r'walletId', - lower: [], - upper: [walletId], - includeUpper: false, - )); - } - }); - } - - QueryBuilder - mintIndexEqualToAnyWalletId(int mintIndex) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IndexWhereClause.equalTo( - indexName: r'mintIndex_walletId', - value: [mintIndex], - )); - }); - } - - QueryBuilder - mintIndexNotEqualToAnyWalletId(int mintIndex) { - return QueryBuilder.apply(this, (query) { - if (query.whereSort == Sort.asc) { - return query - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [], - upper: [mintIndex], - includeUpper: false, - )) - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [mintIndex], - includeLower: false, - upper: [], - )); - } else { - return query - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [mintIndex], - includeLower: false, - upper: [], - )) - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [], - upper: [mintIndex], - includeUpper: false, - )); - } - }); - } - - QueryBuilder - mintIndexGreaterThanAnyWalletId( - int mintIndex, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [mintIndex], - includeLower: include, - upper: [], - )); - }); - } - - QueryBuilder - mintIndexLessThanAnyWalletId( - int mintIndex, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [], - upper: [mintIndex], - includeUpper: include, - )); - }); - } - - QueryBuilder - mintIndexBetweenAnyWalletId( - int lowerMintIndex, - int upperMintIndex, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [lowerMintIndex], - includeLower: includeLower, - upper: [upperMintIndex], - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder - mintIndexWalletIdEqualTo(int mintIndex, String walletId) { - return QueryBuilder.apply(this, (query) { - return query.addWhereClause(IndexWhereClause.equalTo( - indexName: r'mintIndex_walletId', - value: [mintIndex, walletId], - )); - }); - } - - QueryBuilder - mintIndexEqualToWalletIdNotEqualTo(int mintIndex, String walletId) { - return QueryBuilder.apply(this, (query) { - if (query.whereSort == Sort.asc) { - return query - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [mintIndex], - upper: [mintIndex, walletId], - includeUpper: false, - )) - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [mintIndex, walletId], - includeLower: false, - upper: [mintIndex], - )); - } else { - return query - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [mintIndex, walletId], - includeLower: false, - upper: [mintIndex], - )) - .addWhereClause(IndexWhereClause.between( - indexName: r'mintIndex_walletId', - lower: [mintIndex], - upper: [mintIndex, walletId], - includeUpper: false, - )); - } - }); - } -} - -extension LelantusCoinQueryFilter - on QueryBuilder { - QueryBuilder - anonymitySetIdEqualTo(int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'anonymitySetId', - value: value, - )); - }); - } - - QueryBuilder - anonymitySetIdGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'anonymitySetId', - value: value, - )); - }); - } - - QueryBuilder - anonymitySetIdLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'anonymitySetId', - value: value, - )); - }); - } - - QueryBuilder - anonymitySetIdBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'anonymitySetId', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder idEqualTo( - Id value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'id', - value: value, - )); - }); - } - - QueryBuilder idGreaterThan( - Id value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'id', - value: value, - )); - }); - } - - QueryBuilder idLessThan( - Id value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'id', - value: value, - )); - }); - } - - QueryBuilder idBetween( - Id lower, - Id upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'id', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder - isJMintEqualTo(bool value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'isJMint', - value: value, - )); - }); - } - - QueryBuilder isUsedEqualTo( - bool value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'isUsed', - value: value, - )); - }); - } - - QueryBuilder - mintIndexEqualTo(int value) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'mintIndex', - value: value, - )); - }); - } - - QueryBuilder - mintIndexGreaterThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'mintIndex', - value: value, - )); - }); - } - - QueryBuilder - mintIndexLessThan( - int value, { - bool include = false, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'mintIndex', - value: value, - )); - }); - } - - QueryBuilder - mintIndexBetween( - int lower, - int upper, { - bool includeLower = true, - bool includeUpper = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'mintIndex', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - )); - }); - } - - QueryBuilder - otherDataIsNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNull( - property: r'otherData', - )); - }); - } - - QueryBuilder - otherDataIsNotNull() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(const FilterCondition.isNotNull( - property: r'otherData', - )); - }); - } - - QueryBuilder - otherDataEqualTo( - String? value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataGreaterThan( - String? value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataLessThan( - String? value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataBetween( - String? lower, - String? upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'otherData', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataContains(String value, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'otherData', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataMatches(String pattern, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'otherData', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - otherDataIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'otherData', - value: '', - )); - }); - } - - QueryBuilder - otherDataIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'otherData', - value: '', - )); - }); - } - - QueryBuilder txidEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'txid', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - txidGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'txid', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder txidLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'txid', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder txidBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'txid', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - txidStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'txid', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder txidEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'txid', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder txidContains( - String value, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'txid', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder txidMatches( - String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'txid', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - txidIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'txid', - value: '', - )); - }); - } - - QueryBuilder - txidIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'txid', - value: '', - )); - }); - } - - QueryBuilder valueEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'value', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - valueGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'value', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder valueLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'value', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder valueBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'value', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - valueStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'value', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder valueEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'value', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder valueContains( - String value, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'value', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder valueMatches( - String pattern, - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'value', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - valueIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'value', - value: '', - )); - }); - } - - QueryBuilder - valueIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'value', - value: '', - )); - }); - } - - QueryBuilder - walletIdEqualTo( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'walletId', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdGreaterThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - include: include, - property: r'walletId', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdLessThan( - String value, { - bool include = false, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.lessThan( - include: include, - property: r'walletId', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdBetween( - String lower, - String upper, { - bool includeLower = true, - bool includeUpper = true, - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.between( - property: r'walletId', - lower: lower, - includeLower: includeLower, - upper: upper, - includeUpper: includeUpper, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdStartsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.startsWith( - property: r'walletId', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdEndsWith( - String value, { - bool caseSensitive = true, - }) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.endsWith( - property: r'walletId', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdContains(String value, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.contains( - property: r'walletId', - value: value, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdMatches(String pattern, {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.matches( - property: r'walletId', - wildcard: pattern, - caseSensitive: caseSensitive, - )); - }); - } - - QueryBuilder - walletIdIsEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.equalTo( - property: r'walletId', - value: '', - )); - }); - } - - QueryBuilder - walletIdIsNotEmpty() { - return QueryBuilder.apply(this, (query) { - return query.addFilterCondition(FilterCondition.greaterThan( - property: r'walletId', - value: '', - )); - }); - } -} - -extension LelantusCoinQueryObject - on QueryBuilder {} - -extension LelantusCoinQueryLinks - on QueryBuilder {} - -extension LelantusCoinQuerySortBy - on QueryBuilder { - QueryBuilder - sortByAnonymitySetId() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'anonymitySetId', Sort.asc); - }); - } - - QueryBuilder - sortByAnonymitySetIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'anonymitySetId', Sort.desc); - }); - } - - QueryBuilder sortByIsJMint() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isJMint', Sort.asc); - }); - } - - QueryBuilder sortByIsJMintDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isJMint', Sort.desc); - }); - } - - QueryBuilder sortByIsUsed() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isUsed', Sort.asc); - }); - } - - QueryBuilder sortByIsUsedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isUsed', Sort.desc); - }); - } - - QueryBuilder sortByMintIndex() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'mintIndex', Sort.asc); - }); - } - - QueryBuilder sortByMintIndexDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'mintIndex', Sort.desc); - }); - } - - QueryBuilder sortByOtherData() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.asc); - }); - } - - QueryBuilder sortByOtherDataDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.desc); - }); - } - - QueryBuilder sortByTxid() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txid', Sort.asc); - }); - } - - QueryBuilder sortByTxidDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txid', Sort.desc); - }); - } - - QueryBuilder sortByValue() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'value', Sort.asc); - }); - } - - QueryBuilder sortByValueDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'value', Sort.desc); - }); - } - - QueryBuilder sortByWalletId() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'walletId', Sort.asc); - }); - } - - QueryBuilder sortByWalletIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'walletId', Sort.desc); - }); - } -} - -extension LelantusCoinQuerySortThenBy - on QueryBuilder { - QueryBuilder - thenByAnonymitySetId() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'anonymitySetId', Sort.asc); - }); - } - - QueryBuilder - thenByAnonymitySetIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'anonymitySetId', Sort.desc); - }); - } - - QueryBuilder thenById() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'id', Sort.asc); - }); - } - - QueryBuilder thenByIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'id', Sort.desc); - }); - } - - QueryBuilder thenByIsJMint() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isJMint', Sort.asc); - }); - } - - QueryBuilder thenByIsJMintDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isJMint', Sort.desc); - }); - } - - QueryBuilder thenByIsUsed() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isUsed', Sort.asc); - }); - } - - QueryBuilder thenByIsUsedDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'isUsed', Sort.desc); - }); - } - - QueryBuilder thenByMintIndex() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'mintIndex', Sort.asc); - }); - } - - QueryBuilder thenByMintIndexDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'mintIndex', Sort.desc); - }); - } - - QueryBuilder thenByOtherData() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.asc); - }); - } - - QueryBuilder thenByOtherDataDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'otherData', Sort.desc); - }); - } - - QueryBuilder thenByTxid() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txid', Sort.asc); - }); - } - - QueryBuilder thenByTxidDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'txid', Sort.desc); - }); - } - - QueryBuilder thenByValue() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'value', Sort.asc); - }); - } - - QueryBuilder thenByValueDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'value', Sort.desc); - }); - } - - QueryBuilder thenByWalletId() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'walletId', Sort.asc); - }); - } - - QueryBuilder thenByWalletIdDesc() { - return QueryBuilder.apply(this, (query) { - return query.addSortBy(r'walletId', Sort.desc); - }); - } -} - -extension LelantusCoinQueryWhereDistinct - on QueryBuilder { - QueryBuilder - distinctByAnonymitySetId() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'anonymitySetId'); - }); - } - - QueryBuilder distinctByIsJMint() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'isJMint'); - }); - } - - QueryBuilder distinctByIsUsed() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'isUsed'); - }); - } - - QueryBuilder distinctByMintIndex() { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'mintIndex'); - }); - } - - QueryBuilder distinctByOtherData( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'otherData', caseSensitive: caseSensitive); - }); - } - - QueryBuilder distinctByTxid( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'txid', caseSensitive: caseSensitive); - }); - } - - QueryBuilder distinctByValue( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'value', caseSensitive: caseSensitive); - }); - } - - QueryBuilder distinctByWalletId( - {bool caseSensitive = true}) { - return QueryBuilder.apply(this, (query) { - return query.addDistinctBy(r'walletId', caseSensitive: caseSensitive); - }); - } -} - -extension LelantusCoinQueryProperty - on QueryBuilder { - QueryBuilder idProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'id'); - }); - } - - QueryBuilder anonymitySetIdProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'anonymitySetId'); - }); - } - - QueryBuilder isJMintProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'isJMint'); - }); - } - - QueryBuilder isUsedProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'isUsed'); - }); - } - - QueryBuilder mintIndexProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'mintIndex'); - }); - } - - QueryBuilder otherDataProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'otherData'); - }); - } - - QueryBuilder txidProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'txid'); - }); - } - - QueryBuilder valueProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'value'); - }); - } - - QueryBuilder walletIdProperty() { - return QueryBuilder.apply(this, (query) { - return query.addPropertyName(r'walletId'); - }); - } -} diff --git a/lib/models/isar/models/isar_models.dart b/lib/models/isar/models/isar_models.dart index 9de91fc84..ce7652a46 100644 --- a/lib/models/isar/models/isar_models.dart +++ b/lib/models/isar/models/isar_models.dart @@ -15,6 +15,5 @@ export 'blockchain_data/output.dart'; export 'blockchain_data/transaction.dart'; export 'blockchain_data/utxo.dart'; export 'ethereum/eth_contract.dart'; -export 'firo_specific/lelantus_coin.dart'; export 'log.dart'; export 'transaction_note.dart'; diff --git a/lib/models/lelantus_fee_data.dart b/lib/models/lelantus_fee_data.dart deleted file mode 100644 index 1ba930a29..000000000 --- a/lib/models/lelantus_fee_data.dart +++ /dev/null @@ -1,21 +0,0 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -class LelantusFeeData { - int changeToMint; - int fee; - List spendCoinIndexes; - LelantusFeeData(this.changeToMint, this.fee, this.spendCoinIndexes); - - @override - String toString() { - return "{changeToMint: $changeToMint, fee: $fee, spendCoinIndexes: $spendCoinIndexes}"; - } -} diff --git a/lib/models/models.dart b/lib/models/models.dart index 3f6aaa525..51282c824 100644 --- a/lib/models/models.dart +++ b/lib/models/models.dart @@ -9,7 +9,6 @@ */ export 'lelantus_coin.dart'; -export 'lelantus_fee_data.dart'; export 'paymint/fee_object_model.dart'; export 'paymint/transactions_model.dart'; export 'paymint/utxo_model.dart'; diff --git a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart index e16ab5b0c..970614542 100644 --- a/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart +++ b/lib/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart @@ -142,8 +142,6 @@ class _NewWalletRecoveryPhraseWarningViewState // ), // }, // ); - } else if (widget.coin is Firo) { - otherDataJson = {WalletInfoKeys.lelantusCoinIsarRescanRequired: false}; } if (ref.read(pDuress)) { @@ -184,7 +182,10 @@ class _NewWalletRecoveryPhraseWarningViewState // TODO: Refactor these to generate each coin in their respective classes // This code should not be in a random view page file - if (coin is Monero || coin is Wownero || coin is Xelis || coin is Salvium) { + if (coin is Monero || + coin is Wownero || + coin is Xelis || + coin is Salvium) { // currently a special case due to the // xmr/wow libraries handling their // own mnemonic generation diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart index e09882a7c..5cc90beba 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart @@ -33,7 +33,6 @@ import '../../../../wallets/crypto_currency/intermediate/cryptonote_currency.dar import '../../../../widgets/conditional_parent.dart'; import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; import '../../../../widgets/custom_buttons/blue_text_button.dart'; -import '../../../../widgets/custom_buttons/checkbox_text_button.dart'; import '../../../../widgets/date_picker/date_picker.dart'; import '../../../../widgets/desktop/desktop_app_bar.dart'; import '../../../../widgets/desktop/desktop_scaffold.dart'; @@ -86,9 +85,6 @@ class _RestoreOptionsViewState extends ConsumerState { DateTime? _restoreFromDate; bool hidePassword = true; - bool enableLelantusScanning = false; - bool get supportsLelantus => coin is Firo; - @override void initState() { super.initState(); @@ -149,13 +145,12 @@ class _RestoreOptionsViewState extends ConsumerState { if (!_showViewOnlyOption) { await Navigator.of(context).pushNamed( RestoreWalletView.routeName, - arguments: Tuple6( + arguments: Tuple5( walletName, coin, ref.read(mnemonicWordCountStateProvider.state).state, height, passwordController.text, - enableLelantusScanning, ), ); } else { @@ -165,7 +160,6 @@ class _RestoreOptionsViewState extends ConsumerState { walletName: walletName, coin: coin, restoreBlockHeight: height, - enableLelantusScanning: enableLelantusScanning, ), ); } @@ -353,9 +347,6 @@ class _RestoreOptionsViewState extends ConsumerState { dateChooserFunction: isDesktop ? chooseDesktopDate : chooseDate, chooseMnemonicLength: chooseMnemonicLength, - lelScanChanged: (value) { - enableLelantusScanning = value; - }, ), if (!isDesktop) const Spacer(flex: 3), SizedBox(height: isDesktop ? 32 : 12), @@ -386,7 +377,6 @@ class SeedRestoreOption extends ConsumerStatefulWidget { required this.pwFocusNode, required this.dateChooserFunction, required this.chooseMnemonicLength, - required this.lelScanChanged, }); final CryptoCurrency coin; @@ -398,7 +388,6 @@ class SeedRestoreOption extends ConsumerStatefulWidget { final Future Function() dateChooserFunction; final Future Function() chooseMnemonicLength; - final void Function(bool) lelScanChanged; @override ConsumerState createState() => _SeedRestoreOptionState(); @@ -407,7 +396,6 @@ class SeedRestoreOption extends ConsumerStatefulWidget { class _SeedRestoreOptionState extends ConsumerState { bool _hidePassword = true; bool _expandedAdvanced = false; - bool _enableLelantusScanning = false; bool _blockFieldEmpty = true; @override @@ -669,17 +657,6 @@ class _SeedRestoreOptionState extends ConsumerState { color: Colors.transparent, child: Column( children: [ - if (widget.coin is Firo) - CheckboxTextButton( - label: "Scan for Lelantus transactions", - onChanged: (newValue) { - setState(() { - _enableLelantusScanning = newValue ?? true; - }); - - widget.lelScanChanged(_enableLelantusScanning); - }, - ), if (widget.coin is Firo) const SizedBox(height: 8), ClipRRect( borderRadius: BorderRadius.circular( diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_view_only_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_view_only_wallet_view.dart index 2ad57cf02..606841139 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_view_only_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_view_only_wallet_view.dart @@ -48,8 +48,6 @@ class RestoreViewOnlyWalletView extends ConsumerStatefulWidget { required this.walletName, required this.coin, required this.restoreBlockHeight, - this.enableLelantusScanning = false, - this.clipboard = const ClipboardWrapper(), }); @@ -58,7 +56,6 @@ class RestoreViewOnlyWalletView extends ConsumerStatefulWidget { final String walletName; final CryptoCurrency coin; final int restoreBlockHeight; - final bool enableLelantusScanning; final ClipboardInterface clipboard; @override @@ -111,12 +108,6 @@ class _RestoreViewOnlyWalletViewState final ViewOnlyWalletType viewOnlyWalletType; if (widget.coin is Bip39HDCurrency) { - if (widget.coin is Firo) { - otherDataJson.addAll({ - WalletInfoKeys.lelantusCoinIsarRescanRequired: false, - WalletInfoKeys.enableLelantusScanning: widget.enableLelantusScanning, - }); - } viewOnlyWalletType = _addressOnly ? ViewOnlyWalletType.addressOnly diff --git a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart index d56a69a8c..b4aeb3693 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/restore_wallet_view.dart @@ -77,8 +77,6 @@ class RestoreWalletView extends ConsumerStatefulWidget { required this.seedWordsLength, required this.mnemonicPassphrase, required this.restoreBlockHeight, - this.enableLelantusScanning = false, - this.clipboard = const ClipboardWrapper(), }); @@ -89,7 +87,6 @@ class RestoreWalletView extends ConsumerStatefulWidget { final String mnemonicPassphrase; final int seedWordsLength; final int restoreBlockHeight; - final bool enableLelantusScanning; final ClipboardInterface clipboard; @@ -245,11 +242,6 @@ class _RestoreWalletViewState extends ConsumerState { ).toMap(), ), }); - } else if (widget.coin is Firo) { - otherDataJsonString = jsonEncode({ - WalletInfoKeys.lelantusCoinIsarRescanRequired: false, - WalletInfoKeys.enableLelantusScanning: widget.enableLelantusScanning, - }); } // TODO: do actual check to make sure it is a valid mnemonic for monero + xelis diff --git a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart index ef959aa22..c562ec88e 100644 --- a/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart +++ b/lib/pages/add_wallet_views/verify_recovery_phrase_view/verify_recovery_phrase_view.dart @@ -117,12 +117,6 @@ class _VerifyRecoveryPhraseViewState final ViewOnlyWalletType viewOnlyWalletType; if (widget.wallet is ExtendedKeysInterface) { - if (widget.wallet.cryptoCurrency is Firo) { - otherDataJson.addAll({ - WalletInfoKeys.lelantusCoinIsarRescanRequired: false, - WalletInfoKeys.enableLelantusScanning: false, - }); - } viewOnlyWalletType = ViewOnlyWalletType.xPub; } else if (widget.wallet is LibMoneroWallet || widget.wallet is LibSalviumWallet) { diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index ac6d9863c..d34306cf4 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -150,10 +150,6 @@ class _ConfirmTransactionViewState } break; - case FiroType.lelantus: - txDataFuture = wallet.confirmSendLelantus(txData: widget.txData); - break; - case FiroType.spark: txDataFuture = wallet.confirmSendSpark(txData: widget.txData); break; @@ -364,11 +360,6 @@ class _ConfirmTransactionViewState } break; - case FiroType.lelantus: - fee = widget.txData.fee; - amountWithoutChange = widget.txData.amountWithoutChange!; - break; - case FiroType.spark: fee = widget.txData.fee; amountWithoutChange = diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index d2806d513..54a2f2f8c 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -498,7 +498,6 @@ class _SendViewState extends ConsumerState { late Future _calculateFeesFuture; Map cachedFees = {}; - Map cachedFiroLelantusFees = {}; Map cachedFiroSparkFees = {}; Map cachedFiroPublicFees = {}; @@ -514,11 +513,6 @@ class _SendViewState extends ConsumerState { return cachedFiroPublicFees[amount]!; } break; - case FiroType.lelantus: - if (cachedFiroLelantusFees[amount] != null) { - return cachedFiroLelantusFees[amount]!; - } - break; case FiroType.spark: if (cachedFiroSparkFees[amount] != null) { return cachedFiroSparkFees[amount]!; @@ -585,12 +579,6 @@ class _SendViewState extends ConsumerState { .format(fee, withUnitName: true, indicatePrecisionLoss: false); return cachedFiroPublicFees[amount]!; - case FiroType.lelantus: - fee = await firoWallet.estimateFeeForLelantus(amount); - cachedFiroLelantusFees[amount] = ref - .read(pAmountFormatter(coin)) - .format(fee, withUnitName: true, indicatePrecisionLoss: false); - return cachedFiroLelantusFees[amount]!; case FiroType.spark: fee = await firoWallet.estimateFeeForSpark(amount); cachedFiroSparkFees[amount] = ref @@ -621,9 +609,6 @@ class _SendViewState extends ConsumerState { case FiroType.public: availableBalance = wallet.info.cachedBalance.spendable; break; - case FiroType.lelantus: - availableBalance = wallet.info.cachedBalanceSecondary.spendable; - break; case FiroType.spark: availableBalance = wallet.info.cachedBalanceTertiary.spendable; break; @@ -783,16 +768,6 @@ class _SendViewState extends ConsumerState { } break; - case FiroType.lelantus: - txDataFuture = wallet.prepareSendLelantus( - txData: TxData( - recipients: [ - (address: _address!, amount: amount, isChange: false), - ], - ), - ); - break; - case FiroType.spark: txDataFuture = wallet.prepareSendSpark( txData: TxData( @@ -953,9 +928,7 @@ class _SendViewState extends ConsumerState { case FiroType.public: amount = ref.read(pWalletBalance(walletId)).spendable; break; - case FiroType.lelantus: - amount = ref.read(pWalletBalanceSecondary(walletId)).spendable; - break; + case FiroType.spark: amount = ref.read(pWalletBalanceTertiary(walletId)).spendable; break; @@ -1358,16 +1331,7 @@ class _SendViewState extends ConsumerState { ) .spendable; break; - case FiroType.lelantus: - amount = - ref - .read( - pWalletBalanceSecondary( - walletId, - ), - ) - .spendable; - break; + case FiroType.spark: amount = ref @@ -1616,11 +1580,7 @@ class _SendViewState extends ConsumerState { ), const SizedBox(height: 10), if (isStellar || - (ref.watch(pValidSparkSendToAddress) && - ref.watch( - publicPrivateBalanceStateProvider, - ) != - FiroType.lelantus)) + ref.watch(pValidSparkSendToAddress)) ClipRRect( borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, @@ -1712,43 +1672,14 @@ class _SendViewState extends ConsumerState { if (_address == null || _address!.isEmpty) { error = null; } else if (isFiro) { - if (ref.watch( - publicPrivateBalanceStateProvider, - ) == - FiroType.lelantus) { - if (_data != null && - _data.contactLabel == _address) { - error = - SparkInterface.validateSparkAddress( - address: _data.address, - isTestNet: - coin.network == - CryptoCurrencyNetwork.test, - ) - ? "Unsupported" - : null; - } else if (ref.watch( - pValidSparkSendToAddress, - )) { - error = "Unsupported"; - } else { - error = - ref.watch(pValidSendToAddress) - ? null - : "Invalid address"; - } + if (_data != null && + _data.contactLabel == _address) { + error = null; + } else if (!ref.watch(pValidSendToAddress) && + !ref.watch(pValidSparkSendToAddress)) { + error = "Invalid address"; } else { - if (_data != null && - _data.contactLabel == _address) { - error = null; - } else if (!ref.watch( - pValidSendToAddress, - ) && - !ref.watch(pValidSparkSendToAddress)) { - error = "Invalid address"; - } else { - error = null; - } + error = null; } } else { if (_data != null && @@ -1868,16 +1799,6 @@ class _SendViewState extends ConsumerState { ) .spendable; break; - case FiroType.lelantus: - amount = - ref - .watch( - pWalletBalanceSecondary( - walletId, - ), - ) - .spendable; - break; case FiroType.spark: amount = ref diff --git a/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart b/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart index 912fad545..87c6da542 100644 --- a/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart +++ b/lib/pages/send_view/sub_widgets/firo_balance_selection_sheet.dart @@ -20,10 +20,7 @@ import '../../../utilities/text_styles.dart'; import '../../../wallets/wallet/impl/firo_wallet.dart'; class FiroBalanceSelectionSheet extends ConsumerStatefulWidget { - const FiroBalanceSelectionSheet({ - super.key, - required this.walletId, - }); + const FiroBalanceSelectionSheet({super.key, required this.walletId}); final String walletId; @@ -46,8 +43,9 @@ class _FiroBalanceSelectionSheetState Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); - final wallet = - ref.watch(pWallets.select((value) => value.getWallet(walletId))); + final wallet = ref.watch( + pWallets.select((value) => value.getWallet(walletId)), + ); final firoWallet = wallet as FiroWallet; final coin = wallet.info.coin; @@ -55,17 +53,10 @@ class _FiroBalanceSelectionSheetState return Container( decoration: BoxDecoration( color: Theme.of(context).extension()!.popupBG, - borderRadius: const BorderRadius.vertical( - top: Radius.circular(20), - ), + borderRadius: const BorderRadius.vertical(top: Radius.circular(20)), ), child: Padding( - padding: const EdgeInsets.only( - left: 24, - right: 24, - top: 10, - bottom: 0, - ), + padding: const EdgeInsets.only(left: 24, right: 24, top: 10, bottom: 0), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -73,9 +64,10 @@ class _FiroBalanceSelectionSheetState Center( child: Container( decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .textFieldDefaultBG, + color: + Theme.of( + context, + ).extension()!.textFieldDefaultBG, borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), @@ -84,9 +76,7 @@ class _FiroBalanceSelectionSheetState height: 4, ), ), - const SizedBox( - height: 36, - ), + const SizedBox(height: 36), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -95,9 +85,7 @@ class _FiroBalanceSelectionSheetState style: STextStyles.pageTitleH2(context), textAlign: TextAlign.left, ), - const SizedBox( - height: 16, - ), + const SizedBox(height: 16), GestureDetector( onTap: () { final state = @@ -120,15 +108,18 @@ class _FiroBalanceSelectionSheetState width: 20, height: 20, child: Radio( - activeColor: Theme.of(context) - .extension()! - .radioButtonIconEnabled, + activeColor: + Theme.of(context) + .extension()! + .radioButtonIconEnabled, value: FiroType.spark, - groupValue: ref - .watch( - publicPrivateBalanceStateProvider.state, - ) - .state, + groupValue: + ref + .watch( + publicPrivateBalanceStateProvider + .state, + ) + .state, onChanged: (x) { ref .read( @@ -142,9 +133,7 @@ class _FiroBalanceSelectionSheetState ), ], ), - const SizedBox( - width: 12, - ), + const SizedBox(width: 12), Flexible( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -156,13 +145,15 @@ class _FiroBalanceSelectionSheetState style: STextStyles.titleBold12(context), textAlign: TextAlign.left, ), - const SizedBox( - width: 2, - ), + const SizedBox(width: 2), Text( - ref.watch(pAmountFormatter(coin)).format( + ref + .watch(pAmountFormatter(coin)) + .format( firoWallet - .info.cachedBalanceTertiary.spendable, + .info + .cachedBalanceTertiary + .spendable, ), style: STextStyles.itemSubtitle(context), textAlign: TextAlign.left, @@ -176,97 +167,8 @@ class _FiroBalanceSelectionSheetState ), ), ), - if (firoWallet.info.cachedBalanceSecondary.spendable.raw > - BigInt.zero) - const SizedBox( - height: 16, - ), - if (firoWallet.info.cachedBalanceSecondary.spendable.raw > - BigInt.zero) - GestureDetector( - onTap: () { - final state = ref - .read(publicPrivateBalanceStateProvider.state) - .state; - if (state != FiroType.lelantus) { - ref - .read(publicPrivateBalanceStateProvider.state) - .state = FiroType.lelantus; - } - Navigator.of(context).pop(); - }, - child: Container( - color: Colors.transparent, - child: Row( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Column( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - SizedBox( - width: 20, - height: 20, - child: Radio( - activeColor: Theme.of(context) - .extension()! - .radioButtonIconEnabled, - value: FiroType.lelantus, - groupValue: ref - .watch( - publicPrivateBalanceStateProvider.state, - ) - .state, - onChanged: (x) { - ref - .read( - publicPrivateBalanceStateProvider - .state, - ) - .state = FiroType.lelantus; - Navigator.of(context).pop(); - }, - ), - ), - ], - ), - const SizedBox( - width: 12, - ), - Flexible( - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - // Row( - // children: [ - Text( - "Lelantus balance", - style: STextStyles.titleBold12(context), - textAlign: TextAlign.left, - ), - const SizedBox( - width: 2, - ), - Text( - ref.watch(pAmountFormatter(coin)).format( - firoWallet.info.cachedBalanceSecondary - .spendable, - ), - style: STextStyles.itemSubtitle(context), - textAlign: TextAlign.left, - ), - ], - ), - // ], - // ), - ), - ], - ), - ), - ), - const SizedBox( - height: 16, - ), + const SizedBox(height: 16), GestureDetector( onTap: () { final state = @@ -288,15 +190,18 @@ class _FiroBalanceSelectionSheetState width: 20, height: 20, child: Radio( - activeColor: Theme.of(context) - .extension()! - .radioButtonIconEnabled, + activeColor: + Theme.of(context) + .extension()! + .radioButtonIconEnabled, value: FiroType.public, - groupValue: ref - .watch( - publicPrivateBalanceStateProvider.state, - ) - .state, + groupValue: + ref + .watch( + publicPrivateBalanceStateProvider + .state, + ) + .state, onChanged: (x) { ref .read( @@ -309,9 +214,7 @@ class _FiroBalanceSelectionSheetState ), ], ), - const SizedBox( - width: 12, - ), + const SizedBox(width: 12), Flexible( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -323,11 +226,11 @@ class _FiroBalanceSelectionSheetState style: STextStyles.titleBold12(context), textAlign: TextAlign.left, ), - const SizedBox( - width: 2, - ), + const SizedBox(width: 2), Text( - ref.watch(pAmountFormatter(coin)).format( + ref + .watch(pAmountFormatter(coin)) + .format( firoWallet.info.cachedBalance.spendable, ), style: STextStyles.itemSubtitle(context), @@ -340,12 +243,8 @@ class _FiroBalanceSelectionSheetState ), ), ), - const SizedBox( - height: 16, - ), - const SizedBox( - height: 24, - ), + const SizedBox(height: 16), + const SizedBox(height: 24), ], ), ], diff --git a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart index 41cdac17e..2257af491 100644 --- a/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart +++ b/lib/pages/send_view/sub_widgets/transaction_fee_selection_sheet.dart @@ -101,10 +101,6 @@ class _TransactionFeeSelectionSheetState fee = await (wallet as FiroWallet).estimateFeeForSpark( amount, ); - case FiroType.lelantus: - fee = await (wallet as FiroWallet).estimateFeeForLelantus( - amount, - ); case FiroType.public: fee = await (wallet as FiroWallet).estimateFeeFor( amount, @@ -142,10 +138,6 @@ class _TransactionFeeSelectionSheetState fee = await (wallet as FiroWallet).estimateFeeForSpark( amount, ); - case FiroType.lelantus: - fee = await (wallet as FiroWallet).estimateFeeForLelantus( - amount, - ); case FiroType.public: fee = await (wallet as FiroWallet).estimateFeeFor( amount, @@ -182,10 +174,6 @@ class _TransactionFeeSelectionSheetState fee = await (wallet as FiroWallet).estimateFeeForSpark( amount, ); - case FiroType.lelantus: - fee = await (wallet as FiroWallet).estimateFeeForLelantus( - amount, - ); case FiroType.public: fee = await (wallet as FiroWallet).estimateFeeFor( amount, diff --git a/lib/pages/settings_views/global_settings_view/about_view.dart b/lib/pages/settings_views/global_settings_view/about_view.dart index 404490163..06c3774a4 100644 --- a/lib/pages/settings_views/global_settings_view/about_view.dart +++ b/lib/pages/settings_views/global_settings_view/about_view.dart @@ -177,45 +177,6 @@ class AboutView extends ConsumerWidget { ); }, ), - if (AppConfig.coins.whereType().isNotEmpty) - const SizedBox(height: 12), - if (AppConfig.coins.whereType().isNotEmpty) - FutureBuilder( - future: GitStatus.getFiroCommitStatus(), - builder: ( - context, - AsyncSnapshot snapshot, - ) { - CommitStatus stateOfCommit = - CommitStatus.notLoaded; - - if (snapshot.connectionState == - ConnectionState.done && - snapshot.hasData) { - stateOfCommit = snapshot.data!; - } - return RoundedWhiteContainer( - child: Column( - crossAxisAlignment: - CrossAxisAlignment.stretch, - children: [ - Text( - "Firo Build Commit", - style: STextStyles.titleBold12(context), - ), - const SizedBox(height: 4), - SelectableText( - GitStatus.firoCommit, - style: GitStatus.styleForStatus( - stateOfCommit, - context, - ), - ), - ], - ), - ); - }, - ), if (AppConfig.coins.whereType().isNotEmpty) const SizedBox(height: 12), if (AppConfig.coins.whereType().isNotEmpty) @@ -256,50 +217,7 @@ class AboutView extends ConsumerWidget { ); }, ), - if (AppConfig.coins.whereType().isNotEmpty) - const SizedBox(height: 12), - // if (AppConfig.coins.whereType().isNotEmpty) - // FutureBuilder( - // future: GitStatus.getMoneroCommitStatus(), - // builder: ( - // context, - // AsyncSnapshot snapshot, - // ) { - // CommitStatus stateOfCommit = - // CommitStatus.notLoaded; - // - // if (snapshot.connectionState == - // ConnectionState.done && - // snapshot.hasData) { - // stateOfCommit = snapshot.data!; - // } - // return RoundedWhiteContainer( - // child: Column( - // crossAxisAlignment: - // CrossAxisAlignment.stretch, - // children: [ - // Text( - // "Monero Build Commit", - // style: STextStyles.titleBold12(context), - // ), - // const SizedBox( - // height: 4, - // ), - // SelectableText( - // GitStatus.moneroCommit, - // style: GitStatus.styleForStatus( - // stateOfCommit, - // context, - // ), - // ), - // ], - // ), - // ); - // }, - // ), - // const SizedBox( - // height: 12, - // ), + const SizedBox(height: 12), RoundedWhiteContainer( child: Column( crossAxisAlignment: CrossAxisAlignment.start, diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart index 57643c43b..d0200b034 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/helpers/restore_create_backup.dart @@ -506,7 +506,9 @@ abstract class SWB { int restoreHeight = walletbackup['restoreHeight'] as int? ?? 0; if (restoreHeight <= 0) { - if (wallet is EpiccashWallet || wallet is LibMoneroWallet || wallet is LibSalviumWallet) { + if (wallet is EpiccashWallet || + wallet is LibMoneroWallet || + wallet is LibSalviumWallet) { restoreHeight = 0; } else { restoreHeight = walletbackup['storedChainHeight'] as int? ?? 0; @@ -791,13 +793,6 @@ abstract class SWB { ); } - if (coin is Firo) { - otherData ??= {}; - // swb will do a restore so this flag should be set to false so another - // rescan/restore isn't done when opening the wallet - otherData[WalletInfoKeys.lelantusCoinIsarRescanRequired] = false; - } - final info = WalletInfo( coinName: coin.identifier, walletId: walletId, diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart deleted file mode 100644 index accd91416..000000000 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart +++ /dev/null @@ -1,214 +0,0 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -import 'dart:io'; - -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:wakelock_plus/wakelock_plus.dart'; - -import '../../../../providers/db/main_db_provider.dart'; -import '../../../../providers/global/wallets_provider.dart'; -import '../../../../themes/stack_colors.dart'; -import '../../../../utilities/logger.dart'; -import '../../../../utilities/show_loading.dart'; -import '../../../../utilities/text_styles.dart'; -import '../../../../utilities/util.dart'; -import '../../../../wallets/isar/models/wallet_info.dart'; -import '../../../../wallets/isar/providers/wallet_info_provider.dart'; -import '../../../../widgets/background.dart'; -import '../../../../widgets/custom_buttons/app_bar_icon_button.dart'; -import '../../../../widgets/custom_buttons/draggable_switch_button.dart'; -import '../../../../widgets/desktop/primary_button.dart'; -import '../../../../widgets/desktop/secondary_button.dart'; -import '../../../../widgets/stack_dialog.dart'; - -class LelantusSettingsView extends ConsumerStatefulWidget { - const LelantusSettingsView({super.key, required this.walletId}); - - static const String routeName = "/lelantusSettings"; - - final String walletId; - - @override - ConsumerState createState() => - _LelantusSettingsViewState(); -} - -class _LelantusSettingsViewState extends ConsumerState { - bool _isUpdatingLelantusScanning = false; - - Future _switchToggled(bool newValue) async { - if (_isUpdatingLelantusScanning) return; - _isUpdatingLelantusScanning = true; // Lock mutex. - - try { - // Toggle enableLelantusScanning in wallet info. - await ref - .read(pWalletInfo(widget.walletId)) - .updateOtherData( - newEntries: {WalletInfoKeys.enableLelantusScanning: newValue}, - isar: ref.read(mainDBProvider).isar, - ); - if (newValue) { - await _doRescanMaybe(); - } - } finally { - // ensure _isUpdatingLelantusScanning is set to false no matter what - _isUpdatingLelantusScanning = false; - } - } - - Future _doRescanMaybe() async { - final shouldRescan = await showDialog( - context: context, - builder: (context) { - return StackDialog( - title: "Rescan may be required", - message: - "A blockchain rescan may be required to fully recover all " - "lelantus history. This may take a while.", - leftButton: SecondaryButton( - label: "Rescan now", - onPressed: () { - Navigator.of(context).pop(true); - }, - ), - rightButton: PrimaryButton( - label: "Later", - onPressed: () => Navigator.of(context).pop(false), - ), - ); - }, - ); - - if (mounted && shouldRescan == true) { - try { - if (!Platform.isLinux) await WakelockPlus.enable(); - - Exception? e; - if (mounted) { - await showLoading( - whileFuture: ref - .read(pWallets) - .getWallet(widget.walletId) - .recover(isRescan: true), - context: context, - message: "Rescanning blockchain", - subMessage: - "This may take a while." - "\nPlease do not exit this screen.", - rootNavigator: Util.isDesktop, - onException: (ex) => e = ex, - ); - - if (e != null) { - throw e!; - } - } - } catch (e, s) { - Logging.instance.e("$e\n$s", error: e, stackTrace: s); - if (mounted) { - // show error - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: - (context) => StackDialog( - title: "Rescan failed", - message: e.toString(), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getSecondaryEnabledButtonStyle(context), - child: Text( - "Ok", - style: STextStyles.itemSubtitle12(context), - ), - onPressed: () { - Navigator.of( - context, - rootNavigator: Util.isDesktop, - ).pop(); - }, - ), - ), - ); - } - } finally { - if (!Platform.isLinux) await WakelockPlus.disable(); - } - } - } - - @override - Widget build(BuildContext context) { - return Background( - child: Scaffold( - backgroundColor: Theme.of(context).extension()!.background, - appBar: AppBar( - leading: AppBarBackButton( - onPressed: () { - Navigator.of(context).pop(); - }, - ), - title: Text( - "Lelantus settings", - style: STextStyles.navBarTitle(context), - ), - ), - body: SafeArea( - child: Padding( - padding: const EdgeInsets.all(16), - child: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Row( - children: [ - SizedBox( - height: 20, - width: 40, - child: DraggableSwitchButton( - isOn: - ref.watch( - pWalletInfo( - widget.walletId, - ).select((value) => value.otherData), - )[WalletInfoKeys.enableLelantusScanning] - as bool? ?? - false, - onValueChanged: _switchToggled, - ), - ), - const SizedBox(width: 16), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Scan for Lelantus transactions", - style: STextStyles.smallMed12(context), - ), - // Text( - // detail, - // style: STextStyles.desktopTextExtraExtraSmall(context), - // ), - ], - ), - ], - ), - ], - ), - ), - ), - ), - ); - } -} diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart index 8cae6d217..a1f9f19dc 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart @@ -22,7 +22,6 @@ import '../../../../wallets/isar/models/wallet_info.dart'; import '../../../../wallets/isar/providers/wallet_info_provider.dart'; import '../../../../wallets/wallet/intermediate/lib_monero_wallet.dart'; import '../../../../wallets/wallet/intermediate/lib_salvium_wallet.dart'; -import '../../../../wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart'; import '../../../../wallets/wallet/wallet_mixin_interfaces/multi_address_interface.dart'; import '../../../../wallets/wallet/wallet_mixin_interfaces/rbf_interface.dart'; import '../../../../wallets/wallet/wallet_mixin_interfaces/spark_interface.dart'; @@ -35,7 +34,6 @@ import '../../../../widgets/stack_dialog.dart'; import '../../../pinpad_views/lock_screen_view.dart'; import 'delete_wallet_warning_view.dart'; import 'edit_refresh_height_view.dart'; -import 'lelantus_settings_view.dart'; import 'rbf_settings_view.dart'; import 'rename_wallet_view.dart'; import 'spark_info.dart'; @@ -356,40 +354,6 @@ class _WalletSettingsWalletSettingsViewState ), ), ), - if (wallet is LelantusInterface && !wallet.isViewOnly) - const SizedBox(height: 8), - if (wallet is LelantusInterface && !wallet.isViewOnly) - RoundedWhiteContainer( - padding: const EdgeInsets.all(0), - child: RawMaterialButton( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - onPressed: () { - Navigator.of(context).pushNamed( - LelantusSettingsView.routeName, - arguments: widget.walletId, - ); - }, - child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 12.0, - vertical: 20, - ), - child: Row( - children: [ - Text( - "Lelantus settings", - style: STextStyles.titleBold12(context), - ), - ], - ), - ), - ), - ), if (wallet is SparkInterface && !wallet.isViewOnly) const SizedBox(height: 8), if (wallet is SparkInterface && !wallet.isViewOnly) @@ -424,7 +388,8 @@ class _WalletSettingsWalletSettingsViewState ), ), ), - if (wallet is LibMoneroWallet || wallet is LibSalviumWallet) const SizedBox(height: 8), + if (wallet is LibMoneroWallet || wallet is LibSalviumWallet) + const SizedBox(height: 8), if (wallet is LibMoneroWallet || wallet is LibSalviumWallet) RoundedWhiteContainer( padding: const EdgeInsets.all(0), diff --git a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart index c2fc747ad..bbe90033e 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_balance_toggle_sheet.dart @@ -10,6 +10,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; + import '../../../models/balance.dart'; import '../../../providers/wallet/public_private_balance_state_provider.dart'; import '../../../providers/wallet/wallet_balance_toggle_state_provider.dart'; @@ -22,20 +23,10 @@ import '../../../utilities/text_styles.dart'; import '../../../wallets/crypto_currency/crypto_currency.dart'; import '../../../wallets/isar/providers/wallet_info_provider.dart'; -enum _BalanceType { - available, - full, - lelantusAvailable, - lelantusFull, - sparkAvailable, - sparkFull; -} +enum _BalanceType { available, full, sparkAvailable, sparkFull } class WalletBalanceToggleSheet extends ConsumerWidget { - const WalletBalanceToggleSheet({ - super.key, - required this.walletId, - }); + const WalletBalanceToggleSheet({super.key, required this.walletId}); final String walletId; @@ -54,42 +45,23 @@ class WalletBalanceToggleSheet extends ConsumerWidget { ? _BalanceType.available : _BalanceType.full; - Balance? balanceSecondary; Balance? balanceTertiary; if (isFiro) { - balanceSecondary = ref.watch(pWalletBalanceSecondary(walletId)); balanceTertiary = ref.watch(pWalletBalanceTertiary(walletId)); - switch (ref.watch(publicPrivateBalanceStateProvider.state).state) { - case FiroType.spark: - _bal = _bal == _BalanceType.available - ? _BalanceType.sparkAvailable - : _BalanceType.sparkFull; - break; - - case FiroType.lelantus: - _bal = _bal == _BalanceType.available - ? _BalanceType.lelantusAvailable - : _BalanceType.lelantusFull; - break; - - case FiroType.public: - // already set above - break; - } - - // hack to not show lelantus balance in ui if zero - if (balanceSecondary?.spendable.raw == BigInt.zero) { - balanceSecondary = null; + if (ref.watch(publicPrivateBalanceStateProvider.state).state == + FiroType.spark) { + _bal = + _bal == _BalanceType.available + ? _BalanceType.sparkAvailable + : _BalanceType.sparkFull; } } return Container( decoration: BoxDecoration( color: Theme.of(context).extension()!.popupBG, - borderRadius: const BorderRadius.vertical( - top: Radius.circular(20), - ), + borderRadius: const BorderRadius.vertical(top: Radius.circular(20)), ), child: LimitedBox( maxHeight: maxHeight, @@ -107,9 +79,10 @@ class WalletBalanceToggleSheet extends ConsumerWidget { Center( child: Container( decoration: BoxDecoration( - color: Theme.of(context) - .extension()! - .textFieldDefaultBG, + color: + Theme.of( + context, + ).extension()!.textFieldDefaultBG, borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, ), @@ -118,9 +91,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget { height: 4, ), ), - const SizedBox( - height: 36, - ), + const SizedBox(height: 36), Padding( padding: const EdgeInsets.only(left: 8.0), child: Text( @@ -129,9 +100,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget { textAlign: TextAlign.left, ), ), - const SizedBox( - height: 24, - ), + const SizedBox(height: 24), BalanceSelector( title: "Available${isFiro ? " public" : ""} balance", coin: coin, @@ -153,9 +122,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget { value: _BalanceType.available, groupValue: _bal, ), - const SizedBox( - height: 12, - ), + const SizedBox(height: 12), BalanceSelector( title: "Full${isFiro ? " public" : ""} balance", coin: coin, @@ -177,62 +144,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget { value: _BalanceType.full, groupValue: _bal, ), - if (balanceSecondary != null) - const SizedBox( - height: 12, - ), - if (balanceSecondary != null) - BalanceSelector( - title: "Available Lelantus balance", - coin: coin, - balance: balanceSecondary.spendable, - onPressed: () { - ref.read(walletBalanceToggleStateProvider.state).state = - WalletBalanceToggleState.available; - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.lelantus; - Navigator.of(context).pop(); - }, - onChanged: (_) { - ref.read(walletBalanceToggleStateProvider.state).state = - WalletBalanceToggleState.available; - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.lelantus; - Navigator.of(context).pop(); - }, - value: _BalanceType.lelantusAvailable, - groupValue: _bal, - ), - if (balanceSecondary != null) - const SizedBox( - height: 12, - ), - if (balanceSecondary != null) - BalanceSelector( - title: "Full Lelantus balance", - coin: coin, - balance: balanceSecondary.total, - onPressed: () { - ref.read(walletBalanceToggleStateProvider.state).state = - WalletBalanceToggleState.full; - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.lelantus; - Navigator.of(context).pop(); - }, - onChanged: (_) { - ref.read(walletBalanceToggleStateProvider.state).state = - WalletBalanceToggleState.full; - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.lelantus; - Navigator.of(context).pop(); - }, - value: _BalanceType.lelantusFull, - groupValue: _bal, - ), - if (balanceTertiary != null) - const SizedBox( - height: 12, - ), + if (balanceTertiary != null) const SizedBox(height: 12), if (balanceTertiary != null) BalanceSelector( title: "Available Spark balance", @@ -255,10 +167,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget { value: _BalanceType.sparkAvailable, groupValue: _bal, ), - if (balanceTertiary != null) - const SizedBox( - height: 12, - ), + if (balanceTertiary != null) const SizedBox(height: 12), if (balanceTertiary != null) BalanceSelector( title: "Full Spark balance", @@ -281,9 +190,7 @@ class WalletBalanceToggleSheet extends ConsumerWidget { value: _BalanceType.sparkFull, groupValue: _bal, ), - const SizedBox( - height: 40, - ), + const SizedBox(height: 40), ], ), ), @@ -331,33 +238,28 @@ class BalanceSelector extends ConsumerWidget { width: 20, height: 20, child: Radio( - activeColor: Theme.of(context) - .extension()! - .radioButtonIconEnabled, + activeColor: + Theme.of( + context, + ).extension()!.radioButtonIconEnabled, value: value, groupValue: groupValue, onChanged: onChanged, ), ), - const SizedBox( - width: 12, - ), + const SizedBox(width: 12), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text( - title, - style: STextStyles.titleBold12(context), - ), - const SizedBox( - height: 2, - ), + Text(title, style: STextStyles.titleBold12(context)), + const SizedBox(height: 2), Text( ref.watch(pAmountFormatter(coin)).format(balance), style: STextStyles.itemSubtitle12(context).copyWith( - color: Theme.of(context) - .extension()! - .textSubtitle1, + color: + Theme.of( + context, + ).extension()!.textSubtitle1, ), ), ], diff --git a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart index 1929a1ca4..7661bffdd 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_summary_info.dart @@ -109,11 +109,6 @@ class WalletSummaryInfo extends ConsumerWidget { balanceToShow = _showAvailable ? balance.spendable : balance.total; break; - case FiroType.lelantus: - final balance = ref.watch(pWalletBalanceSecondary(walletId)); - balanceToShow = _showAvailable ? balance.spendable : balance.total; - break; - case FiroType.public: final balance = ref.watch(pWalletBalance(walletId)); balanceToShow = _showAvailable ? balance.spendable : balance.total; diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 61bf31037..2c8c6a301 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -22,7 +22,6 @@ import '../../app_config.dart'; import '../../frost_route_generator.dart'; import '../../models/isar/exchange_cache/currency.dart'; import '../../notifications/show_flush_bar.dart'; -import '../../pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart'; import '../../pages_desktop_specific/spark_coins/spark_coins_view.dart'; import '../../providers/global/active_wallet_provider.dart'; import '../../providers/global/auto_swb_service_provider.dart'; @@ -100,7 +99,6 @@ import '../send_view/send_view.dart'; import '../settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart'; import '../settings_views/wallet_settings_view/wallet_settings_view.dart'; import '../spark_names/spark_names_home_view.dart'; -import '../special/firo_rescan_recovery_error_dialog.dart'; import '../token_view/my_tokens_view.dart'; import 'sub_widgets/transactions_list.dart'; import 'sub_widgets/wallet_summary.dart'; @@ -145,36 +143,6 @@ class _WalletViewState extends ConsumerState { late StreamSubscription _nodeStatusSubscription; bool _rescanningOnOpen = false; - bool _lelantusRescanRecovery = false; - - Future _firoRescanRecovery() async { - final success = - await (ref.read(pWallets).getWallet(walletId) as FiroWallet) - .firoRescanRecovery(); - - if (success) { - // go into wallet - WidgetsBinding.instance.addPostFrameCallback( - (_) => setState(() { - _rescanningOnOpen = false; - _lelantusRescanRecovery = false; - }), - ); - } else { - // show error message dialog w/ options - if (mounted) { - final shouldRetry = await Navigator.of( - context, - ).pushNamed(FiroRescanRecoveryErrorView.routeName, arguments: walletId); - - if (shouldRetry is bool && shouldRetry) { - await _firoRescanRecovery(); - } - } else { - return await _firoRescanRecovery(); - } - } - } @override void initState() { @@ -196,13 +164,7 @@ class _WalletViewState extends ConsumerState { isSparkWallet = wallet is SparkInterface; - if (coin is Firo && (wallet as FiroWallet).lelantusCoinIsarRescanRequired) { - _rescanningOnOpen = true; - _lelantusRescanRecovery = true; - _firoRescanRecovery(); - } else { - wallet.refresh(); - } + wallet.refresh(); if (wallet.refreshMutex.isLocked) { _currentSyncStatus = WalletSyncStatus.syncing; @@ -267,7 +229,7 @@ class _WalletViewState extends ConsumerState { // DateTime? _cachedTime; Future _onWillPop() async { - if (_rescanningOnOpen || _lelantusRescanRecovery) { + if (_rescanningOnOpen) { return false; } @@ -491,7 +453,6 @@ class _WalletViewState extends ConsumerState { } try { - // await firoWallet.anonymizeAllLelantus(); await firoWallet.anonymizeAllSpark(); shouldPop = true; if (mounted) { @@ -553,46 +514,41 @@ class _WalletViewState extends ConsumerState { eventBus: null, textColor: Theme.of(context).extension()!.textDark, - actionButton: - _lelantusRescanRecovery - ? null - : SecondaryButton( - label: "Cancel", - onPressed: () async { - await showDialog( - context: context, - builder: - (context) => StackDialog( - title: "Warning!", - message: - "Skipping this process can completely" - " break your wallet. It is only meant to be done in" - " emergency situations where the migration fails" - " and will not let you continue. Still skip?", - leftButton: SecondaryButton( - label: "Cancel", - onPressed: - Navigator.of( - context, - rootNavigator: true, - ).pop, - ), - rightButton: SecondaryButton( - label: "Ok", - onPressed: () { - Navigator.of( - context, - rootNavigator: true, - ).pop(); - setState( - () => _rescanningOnOpen = false, - ); - }, - ), - ), - ); - }, - ), + actionButton: SecondaryButton( + label: "Cancel", + onPressed: () async { + await showDialog( + context: context, + builder: + (context) => StackDialog( + title: "Warning!", + message: + "Skipping this process can completely" + " break your wallet. It is only meant to be done in" + " emergency situations where the migration fails" + " and will not let you continue. Still skip?", + leftButton: SecondaryButton( + label: "Cancel", + onPressed: + Navigator.of( + context, + rootNavigator: true, + ).pop, + ), + rightButton: SecondaryButton( + label: "Ok", + onPressed: () { + Navigator.of( + context, + rootNavigator: true, + ).pop(); + setState(() => _rescanningOnOpen = false); + }, + ), + ), + ); + }, + ), ), ), ], @@ -1161,22 +1117,6 @@ class _WalletViewState extends ConsumerState { ); }, ), - if (wallet is FiroWallet && - ref.watch( - prefsChangeNotifierProvider.select( - (value) => value.advancedFiroFeatures, - ), - )) - WalletNavigationBarItemData( - label: "Lelantus coins", - icon: const CoinControlNavIcon(), - onTap: () { - Navigator.of(context).pushNamed( - LelantusCoinsView.routeName, - arguments: widget.walletId, - ); - }, - ), if (wallet is FiroWallet && ref.watch( prefsChangeNotifierProvider.select( @@ -1296,7 +1236,9 @@ class _WalletViewState extends ConsumerState { ); }, ), - if ((wallet is LibMoneroWallet || wallet is LibSalviumWallet) && !viewOnly) + if ((wallet is LibMoneroWallet || + wallet is LibSalviumWallet) && + !viewOnly) WalletNavigationBarItemData( label: "Churn", icon: const ChurnNavIcon(), diff --git a/lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart b/lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart deleted file mode 100644 index c08891aef..000000000 --- a/lib/pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart +++ /dev/null @@ -1,134 +0,0 @@ -/* - * This file is part of Stack Wallet. - * - * Copyright (c) 2023 Cypher Stack - * All Rights Reserved. - * The code is distributed under GPLv3 license, see LICENSE file for details. - * Generated by Cypher Stack on 2023-05-26 - * - */ - -import 'package:flutter/material.dart'; -import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/svg.dart'; - -import '../../models/isar/models/isar_models.dart'; -import '../../providers/db/main_db_provider.dart'; -import '../../themes/stack_colors.dart'; -import '../../utilities/assets.dart'; -import '../../utilities/text_styles.dart'; -import '../../utilities/util.dart'; -import '../../widgets/background.dart'; -import '../../widgets/conditional_parent.dart'; -import '../../widgets/custom_buttons/app_bar_icon_button.dart'; -import '../../widgets/desktop/desktop_app_bar.dart'; -import '../../widgets/desktop/desktop_scaffold.dart'; -import '../../widgets/isar_collection_watcher_list.dart'; - -class LelantusCoinsView extends ConsumerWidget { - const LelantusCoinsView({ - super.key, - required this.walletId, - }); - - static const title = "Lelantus coins"; - static const String routeName = "/lelantusCoinsView"; - - final String walletId; - - @override - Widget build(BuildContext context, WidgetRef ref) { - return ConditionalParent( - condition: Util.isDesktop, - builder: (child) { - return DesktopScaffold( - appBar: DesktopAppBar( - background: Theme.of(context).extension()!.popupBG, - leading: Expanded( - child: Row( - children: [ - const SizedBox( - width: 32, - ), - AppBarIconButton( - size: 32, - color: Theme.of(context) - .extension()! - .textFieldDefaultBG, - shadows: const [], - icon: SvgPicture.asset( - Assets.svg.arrowLeft, - width: 18, - height: 18, - color: Theme.of(context) - .extension()! - .topNavIconPrimary, - ), - onPressed: Navigator.of(context).pop, - ), - const SizedBox( - width: 12, - ), - Text( - title, - style: STextStyles.desktopH3(context), - ), - const Spacer(), - ], - ), - ), - useSpacers: false, - isCompactHeight: true, - ), - body: Padding( - padding: const EdgeInsets.all(24), - child: child, - ), - ); - }, - child: ConditionalParent( - condition: !Util.isDesktop, - builder: (child) { - return Background( - child: Scaffold( - backgroundColor: - Theme.of(context).extension()!.background, - appBar: AppBar( - automaticallyImplyLeading: false, - leading: AppBarBackButton( - onPressed: () => Navigator.of(context).pop(), - ), - title: Text( - title, - style: STextStyles.navBarTitle(context), - ), - ), - body: SafeArea( - child: child, - ), - ), - ); - }, - child: IsarCollectionWatcherList( - itemName: title, - queryBuilder: () => ref - .read(mainDBProvider) - .isar - .lelantusCoins - .where() - .walletIdEqualTo(walletId) - .sortByMintIndexDesc(), - itemBuilder: (LelantusCoin? coin) { - return [ - ("TXID", coin?.txid ?? "", 9), - ("Value (sats)", coin?.value ?? "", 3), - ("Index", coin?.mintIndex.toString() ?? "", 2), - ("Is JMint", coin?.isJMint.toString() ?? "", 2), - ("Used", coin?.isUsed.toString() ?? "", 2), - ]; - }, - ), - ), - ); - } -} diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart index 5f4dcf574..73a6bd742 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_balance_toggle_button.dart @@ -17,13 +17,9 @@ import '../../../../themes/stack_colors.dart'; import '../../../../utilities/constants.dart'; import '../../../../utilities/enums/wallet_balance_toggle_state.dart'; import '../../../../utilities/text_styles.dart'; -import '../../../../wallets/isar/providers/wallet_info_provider.dart'; class DesktopBalanceToggleButton extends ConsumerWidget { - const DesktopBalanceToggleButton({ - super.key, - this.onPressed, - }); + const DesktopBalanceToggleButton({super.key, this.onPressed}); final VoidCallback? onPressed; @@ -86,10 +82,6 @@ class DesktopPrivateBalanceToggleButton extends ConsumerWidget { Widget build(BuildContext context, WidgetRef ref) { final currentType = ref.watch(publicPrivateBalanceStateProvider); - final showLelantus = - ref.watch(pWalletBalanceSecondary(walletId)).spendable.raw > - BigInt.zero; - return SizedBox( height: 22, width: 80, @@ -97,32 +89,14 @@ class DesktopPrivateBalanceToggleButton extends ConsumerWidget { color: Theme.of(context).extension()!.buttonBackSecondary, splashColor: Theme.of(context).extension()!.highlight, onPressed: () { - if (showLelantus) { - switch (currentType) { - case FiroType.public: - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.lelantus; - break; - - case FiroType.lelantus: - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.spark; - break; - - case FiroType.spark: - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.public; - break; - } + if (currentType != FiroType.spark) { + ref.read(publicPrivateBalanceStateProvider.state).state = + FiroType.spark; } else { - if (currentType != FiroType.spark) { - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.spark; - } else { - ref.read(publicPrivateBalanceStateProvider.state).state = - FiroType.public; - } + ref.read(publicPrivateBalanceStateProvider.state).state = + FiroType.public; } + onPressed?.call(); }, elevation: 0, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index 609f1d757..206e7ce6d 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -168,9 +168,6 @@ class _DesktopSendState extends ConsumerState { case FiroType.public: availableBalance = wallet.info.cachedBalance.spendable; break; - case FiroType.lelantus: - availableBalance = wallet.info.cachedBalanceSecondary.spendable; - break; case FiroType.spark: availableBalance = wallet.info.cachedBalanceTertiary.spendable; break; @@ -367,16 +364,6 @@ class _DesktopSendState extends ConsumerState { } break; - case FiroType.lelantus: - txDataFuture = wallet.prepareSendLelantus( - txData: TxData( - recipients: [ - (address: _address!, amount: amount, isChange: false), - ], - ), - ); - break; - case FiroType.spark: txDataFuture = wallet.prepareSendSpark( txData: TxData( @@ -849,9 +836,6 @@ class _DesktopSendState extends ConsumerState { case FiroType.public: amount = ref.read(pWalletBalance(walletId)).spendable; break; - case FiroType.lelantus: - amount = ref.read(pWalletBalanceSecondary(walletId)).spendable; - break; case FiroType.spark: amount = ref.read(pWalletBalanceTertiary(walletId)).spendable; break; @@ -1056,30 +1040,6 @@ class _DesktopSendState extends ConsumerState { ], ), ), - if (ref.watch(pWalletBalanceSecondary(walletId)).spendable.raw > - BigInt.zero) - DropdownMenuItem( - value: FiroType.lelantus, - child: Row( - children: [ - Text( - "Lelantus balance", - style: STextStyles.itemSubtitle12(context), - ), - const SizedBox(width: 10), - Text( - ref - .watch(pAmountFormatter(coin)) - .format( - ref - .watch(pWalletBalanceSecondary(walletId)) - .spendable, - ), - style: STextStyles.itemSubtitle(context), - ), - ], - ), - ), DropdownMenuItem( value: FiroType.public, child: Row( @@ -1531,32 +1491,13 @@ class _DesktopSendState extends ConsumerState { if (_address == null || _address!.isEmpty) { error = null; } else if (coin is Firo) { - if (firoType == FiroType.lelantus) { - if (_data != null && _data.contactLabel == _address) { - error = - SparkInterface.validateSparkAddress( - address: _data.address, - isTestNet: coin.network.isTestNet, - ) - ? "Lelantus to Spark not supported" - : null; - } else if (ref.watch(pValidSparkSendToAddress)) { - error = "Lelantus to Spark not supported"; - } else { - error = - ref.watch(pValidSendToAddress) - ? null - : "Invalid address"; - } + if (_data != null && _data.contactLabel == _address) { + error = null; + } else if (!ref.watch(pValidSendToAddress) && + !ref.watch(pValidSparkSendToAddress)) { + error = "Invalid address"; } else { - if (_data != null && _data.contactLabel == _address) { - error = null; - } else if (!ref.watch(pValidSendToAddress) && - !ref.watch(pValidSparkSendToAddress)) { - error = "Invalid address"; - } else { - error = null; - } + error = null; } } else { if (_data != null && _data.contactLabel == _address) { @@ -1590,13 +1531,9 @@ class _DesktopSendState extends ConsumerState { } }, ), - if (isStellar || - (ref.watch(pValidSparkSendToAddress) && - firoType != FiroType.lelantus)) + if (isStellar || ref.watch(pValidSparkSendToAddress)) const SizedBox(height: 10), - if (isStellar || - (ref.watch(pValidSparkSendToAddress) && - firoType != FiroType.lelantus)) + if (isStellar || ref.watch(pValidSparkSendToAddress)) ClipRRect( borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart index 154955148..1eb046484 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send_fee_form.dart @@ -8,7 +8,6 @@ import '../../../../providers/wallet/desktop_fee_providers.dart'; import '../../../../providers/wallet/public_private_balance_state_provider.dart'; import '../../../../themes/stack_colors.dart'; import '../../../../utilities/amount/amount.dart'; -import '../../../../utilities/amount/amount_formatter.dart'; import '../../../../utilities/enums/fee_rate_type_enum.dart'; import '../../../../utilities/eth_commons.dart'; import '../../../../utilities/text_styles.dart'; @@ -72,9 +71,7 @@ class _DesktopSendFeeFormState extends ConsumerState { (cryptoCurrency is ElectrumXCurrencyInterface && !(((cryptoCurrency is Firo) && (ref.watch(publicPrivateBalanceStateProvider.state).state == - FiroType.lelantus || - ref.watch(publicPrivateBalanceStateProvider.state).state == - FiroType.spark)))); + FiroType.spark)))); return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -195,17 +192,6 @@ class _DesktopSendFeeFormState extends ConsumerState { .state, ) .state == - FiroType.lelantus) { - ref - .read(feeSheetSessionCacheProvider) - .average[amount] = await firoWallet - .estimateFeeForLelantus(amount); - } else if (ref - .read( - publicPrivateBalanceStateProvider - .state, - ) - .state == FiroType.spark) { ref .read(feeSheetSessionCacheProvider) @@ -260,36 +246,6 @@ class _DesktopSendFeeFormState extends ConsumerState { } }, ) - : (cryptoCurrency is Firo) && - ref - .watch(publicPrivateBalanceStateProvider.state) - .state == - FiroType.lelantus - ? Builder( - builder: (context) { - final lelantusFee = ref - .watch(pAmountFormatter(cryptoCurrency)) - .format( - Amount( - rawValue: BigInt.parse("3794"), - fractionDigits: cryptoCurrency.fractionDigits, - ), - indicatePrecisionLoss: false, - ); - return Text( - "~$lelantusFee", - style: STextStyles.desktopTextExtraExtraSmall( - context, - ).copyWith( - color: - Theme.of( - context, - ).extension()!.textFieldActiveText, - ), - textAlign: TextAlign.left, - ); - }, - ) : Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart index c5e40a234..2456a909c 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart @@ -44,7 +44,6 @@ import '../../../../wallets/wallet/intermediate/lib_salvium_wallet.dart'; import '../../../../wallets/wallet/wallet.dart' show Wallet; import '../../../../wallets/wallet/wallet_mixin_interfaces/cash_fusion_interface.dart'; import '../../../../wallets/wallet/wallet_mixin_interfaces/coin_control_interface.dart'; -import '../../../../wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart'; import '../../../../wallets/wallet/wallet_mixin_interfaces/ordinals_interface.dart'; import '../../../../wallets/wallet/wallet_mixin_interfaces/paynym_interface.dart'; import '../../../../wallets/wallet/wallet_mixin_interfaces/rbf_interface.dart'; @@ -60,7 +59,6 @@ import '../../../cashfusion/desktop_cashfusion_view.dart'; import '../../../churning/desktop_churning_view.dart'; import '../../../coin_control/desktop_coin_control_view.dart'; import '../../../desktop_menu.dart'; -import '../../../lelantus_coins/lelantus_coins_view.dart'; import '../../../ordinals/desktop_ordinals_view.dart'; import '../../../spark_coins/spark_coins_view.dart'; import '../desktop_wallet_view.dart'; @@ -75,7 +73,6 @@ enum WalletFeature { "Coin control", "Control, freeze, and utilize outputs at your discretion", ), - lelantusCoins("Lelantus coins", "View wallet lelantus coins"), sparkCoins("Spark coins", "View wallet spark coins"), ordinals("Ordinals", "View and control your ordinals in ${AppConfig.prefix}"), monkey("MonKey", "Generate Banano MonKey"), @@ -86,7 +83,6 @@ enum WalletFeature { // special cases clearSparkCache("", ""), - lelantusScanOption("", ""), rbf("", ""), reuseAddress("", ""); @@ -136,12 +132,6 @@ class _DesktopWalletFeaturesState extends ConsumerState { ).pushNamed(DesktopCoinControlView.routeName, arguments: widget.walletId); } - void _onLelantusCoinsPressed() { - Navigator.of( - context, - ).pushNamed(LelantusCoinsView.routeName, arguments: widget.walletId); - } - void _onSparkCoinsPressed() { Navigator.of( context, @@ -236,7 +226,6 @@ class _DesktopWalletFeaturesState extends ConsumerState { } try { - // await firoWallet.anonymizeAllLelantus(); await firoWallet.anonymizeAllSpark(); shouldPop = true; if (mounted) { @@ -417,13 +406,6 @@ class _DesktopWalletFeaturesState extends ConsumerState { _onCoinControlPressed, ), - if (firoAdvanced && wallet is FiroWallet) - ( - WalletFeature.lelantusCoins, - Assets.svg.coinControl.gamePad, - _onLelantusCoinsPressed, - ), - if (firoAdvanced && wallet is FiroWallet) ( WalletFeature.sparkCoins, @@ -443,7 +425,8 @@ class _DesktopWalletFeaturesState extends ConsumerState { if (!isViewOnly && wallet is CashFusionInterface) (WalletFeature.fusion, Assets.svg.cashFusion, _onFusionPressed), - if (!isViewOnly && (wallet is LibMoneroWallet || wallet is LibSalviumWallet)) + if (!isViewOnly && + (wallet is LibMoneroWallet || wallet is LibSalviumWallet)) (WalletFeature.churn, Assets.svg.churn, _onChurnPressed), if (wallet is NamecoinWallet) @@ -482,9 +465,6 @@ class _DesktopWalletFeaturesState extends ConsumerState { if (wallet is SparkInterface && !isViewOnly) (WalletFeature.clearSparkCache, Assets.svg.key, () => ()), - if (wallet is LelantusInterface && !isViewOnly) - (WalletFeature.lelantusScanOption, Assets.svg.key, () => ()), - if (wallet is RbfInterface) (WalletFeature.rbf, Assets.svg.key, () => ()), if (!isViewOnlyNoAddressGen) diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart index dc09c757d..84c52c870 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_summary.dart @@ -109,11 +109,6 @@ class _WDesktopWalletSummaryState extends ConsumerState { balanceToShow = _showAvailable ? balance.spendable : balance.total; break; - case FiroType.lelantus: - final balance = ref.watch(pWalletBalanceSecondary(walletId)); - balanceToShow = _showAvailable ? balance.spendable : balance.total; - break; - case FiroType.public: final balance = ref.watch(pWalletBalance(walletId)); balanceToShow = _showAvailable ? balance.spendable : balance.total; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/firo_desktop_wallet_summary.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/firo_desktop_wallet_summary.dart index ecc80aa28..2de6daf39 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/firo_desktop_wallet_summary.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/firo_desktop_wallet_summary.dart @@ -85,8 +85,6 @@ class _WFiroDesktopWalletSummaryState _showAvailable ? balance0.spendable : balance0.total; final balance1 = ref.watch(pWalletBalanceSecondary(walletId)); - final balanceToShowLelantus = - _showAvailable ? balance1.spendable : balance1.total; final balance2 = ref.watch(pWalletBalance(walletId)); final balanceToShowPublic = @@ -116,19 +114,7 @@ class _WFiroDesktopWalletSummaryState ), ], ), - if (balanceToShowLelantus.raw > BigInt.zero) - TableRow( - children: [ - const _Prefix(type: FiroType.lelantus), - _Balance(coin: coin, amount: balanceToShowLelantus), - if (price != null) - _Price( - coin: coin, - amount: balanceToShowLelantus, - price: price, - ), - ], - ), + TableRow( children: [ const _Prefix(type: FiroType.public), @@ -167,8 +153,6 @@ class _Prefix extends StatelessWidget { switch (type) { case FiroType.public: return Assets.png.glasses; - case FiroType.lelantus: - return Assets.png.glasses; case FiroType.spark: return Assets.svg.spark; } diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart index 5a013787a..ab48068b4 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/more_features/more_features_dialog.dart @@ -14,7 +14,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:wakelock_plus/wakelock_plus.dart'; import '../../../../../db/sqlite/firo_cache.dart'; import '../../../../../providers/db/main_db_provider.dart'; @@ -22,10 +21,7 @@ import '../../../../../providers/global/wallets_provider.dart'; import '../../../../../themes/stack_colors.dart'; import '../../../../../themes/theme_providers.dart'; import '../../../../../utilities/assets.dart'; -import '../../../../../utilities/logger.dart'; -import '../../../../../utilities/show_loading.dart'; import '../../../../../utilities/text_styles.dart'; -import '../../../../../utilities/util.dart'; import '../../../../../wallets/crypto_currency/crypto_currency.dart'; import '../../../../../wallets/isar/models/wallet_info.dart'; import '../../../../../wallets/isar/providers/wallet_info_provider.dart'; @@ -35,7 +31,6 @@ import '../../../../../widgets/desktop/desktop_dialog_close_button.dart'; import '../../../../../widgets/desktop/primary_button.dart'; import '../../../../../widgets/desktop/secondary_button.dart'; import '../../../../../widgets/rounded_container.dart'; -import '../../../../../widgets/stack_dialog.dart'; import '../desktop_wallet_features.dart'; class MoreFeaturesDialog extends ConsumerStatefulWidget { @@ -53,30 +48,6 @@ class MoreFeaturesDialog extends ConsumerStatefulWidget { } class _MoreFeaturesDialogState extends ConsumerState { - bool _isUpdatingLelantusScanning = false; // Mutex. - - Future _switchToggled(bool newValue) async { - if (_isUpdatingLelantusScanning) return; - _isUpdatingLelantusScanning = true; // Lock mutex. - - try { - // Toggle enableLelantusScanning in wallet info. - await ref - .read(pWalletInfo(widget.walletId)) - .updateOtherData( - newEntries: {WalletInfoKeys.enableLelantusScanning: newValue}, - isar: ref.read(mainDBProvider).isar, - ); - - if (newValue) { - await _doRescanMaybe(); - } - } finally { - // ensure _isUpdatingLelantusScanning is set to false no matter what - _isUpdatingLelantusScanning = false; - } - } - bool _switchRbfToggledLock = false; // Mutex. Future _switchRbfToggled(bool newValue) async { if (_switchRbfToggledLock) { @@ -98,119 +69,6 @@ class _MoreFeaturesDialogState extends ConsumerState { } } - Future _doRescanMaybe() async { - final shouldRescan = await showDialog( - context: context, - builder: (context) { - return DesktopDialog( - maxWidth: 700, - child: Column( - children: [ - const DesktopDialogCloseButton(), - const SizedBox(height: 5), - Text( - "Rescan may be required", - style: STextStyles.desktopH2(context), - textAlign: TextAlign.left, - ), - const SizedBox(height: 16), - const Spacer(), - Text( - "A blockchain rescan may be required to fully recover all lelantus history." - "\nThis may take a while.", - style: STextStyles.desktopTextMedium(context).copyWith( - color: Theme.of(context).extension()!.textDark3, - ), - textAlign: TextAlign.center, - ), - const Spacer(), - Padding( - padding: const EdgeInsets.only(left: 32, right: 32, bottom: 32), - child: Row( - children: [ - Expanded( - child: SecondaryButton( - label: "Rescan now", - onPressed: () { - Navigator.of(context).pop(true); - }, - ), - ), - const SizedBox(width: 16), - Expanded( - child: PrimaryButton( - label: "Later", - onPressed: () => Navigator.of(context).pop(false), - ), - ), - ], - ), - ), - ], - ), - ); - }, - ); - - if (mounted && shouldRescan == true) { - try { - if (!Platform.isLinux) await WakelockPlus.enable(); - - Exception? e; - if (mounted) { - await showLoading( - whileFuture: ref - .read(pWallets) - .getWallet(widget.walletId) - .recover(isRescan: true), - context: context, - message: "Rescanning blockchain", - subMessage: - "This may take a while.\nPlease do not exit this screen.", - rootNavigator: Util.isDesktop, - onException: (ex) => e = ex, - ); - - if (e != null) { - throw e!; - } - } - } catch (e, s) { - Logging.instance.e("$e\n$s", error: e, stackTrace: s); - if (mounted) { - // show error - await showDialog( - context: context, - useSafeArea: false, - barrierDismissible: true, - builder: - (context) => StackDialog( - title: "Rescan failed", - message: e.toString(), - rightButton: TextButton( - style: Theme.of(context) - .extension()! - .getSecondaryEnabledButtonStyle(context), - child: Text( - "Ok", - style: STextStyles.itemSubtitle12(context), - ), - onPressed: () { - Navigator.of( - context, - rootNavigator: Util.isDesktop, - ).pop(); - }, - ), - ), - ); - } - } finally { - if (!Platform.isLinux) await WakelockPlus.disable(); - } - } - } - late final DSBController _switchController; bool _switchReuseAddressToggledLock = false; // Mutex. @@ -370,40 +228,6 @@ class _MoreFeaturesDialogState extends ConsumerState { cryptoCurrency: wallet.cryptoCurrency, ); - case WalletFeature.lelantusScanOption: - return _MoreFeaturesItemBase( - child: Row( - children: [ - const SizedBox(width: 3), - SizedBox( - height: 20, - width: 40, - child: DraggableSwitchButton( - isOn: - ref.watch( - pWalletInfo( - widget.walletId, - ).select((value) => value.otherData), - )[WalletInfoKeys.enableLelantusScanning] - as bool? ?? - false, - onValueChanged: _switchToggled, - ), - ), - const SizedBox(width: 16), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - "Scan for Lelantus transactions", - style: STextStyles.w600_20(context), - ), - ], - ), - ], - ), - ); - case WalletFeature.rbf: return _MoreFeaturesItemBase( child: Row( diff --git a/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart b/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart index 98a7dec34..179ce7650 100644 --- a/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart +++ b/lib/pages_desktop_specific/settings/settings_menu/desktop_about_view.dart @@ -38,14 +38,8 @@ class DesktopAboutView extends ConsumerWidget { isCompactHeight: true, leading: Row( children: [ - const SizedBox( - width: 24, - height: 24, - ), - Text( - "About", - style: STextStyles.desktopH3(context), - ), + const SizedBox(width: 24, height: 24), + Text("About", style: STextStyles.desktopH3(context)), ], ), ), @@ -85,55 +79,63 @@ class DesktopAboutView extends ConsumerWidget { TextSpan( text: "By using ${AppConfig.appName}, you agree to the ", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of(context) - .extension()! - .textDark3, - ), + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension()! + .textDark3, + ), ), TextSpan( text: "Terms of service", - style: STextStyles.richLink(context) - .copyWith(fontSize: 14), - recognizer: TapGestureRecognizer() - ..onTap = () { - launchUrl( - Uri.parse( - "https://stackwallet.com/terms-of-service.html", - ), - mode: - LaunchMode.externalApplication, - ); - }, + style: STextStyles.richLink( + context, + ).copyWith(fontSize: 14), + recognizer: + TapGestureRecognizer() + ..onTap = () { + launchUrl( + Uri.parse( + "https://stackwallet.com/terms-of-service.html", + ), + mode: + LaunchMode + .externalApplication, + ); + }, ), TextSpan( text: " and ", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of(context) - .extension()! - .textDark3, - ), + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension()! + .textDark3, + ), ), TextSpan( text: "Privacy policy", - style: STextStyles.richLink(context) - .copyWith(fontSize: 14), - recognizer: TapGestureRecognizer() - ..onTap = () { - launchUrl( - Uri.parse( - "https://stackwallet.com/privacy-policy.html", - ), - mode: - LaunchMode.externalApplication, - ); - }, + style: STextStyles.richLink( + context, + ).copyWith(fontSize: 14), + recognizer: + TapGestureRecognizer() + ..onTap = () { + launchUrl( + Uri.parse( + "https://stackwallet.com/privacy-policy.html", + ), + mode: + LaunchMode + .externalApplication, + ); + }, ), ], ), @@ -142,8 +144,10 @@ class DesktopAboutView extends ConsumerWidget { ), const SizedBox(height: 32), Padding( - padding: - const EdgeInsets.only(right: 10, bottom: 10), + padding: const EdgeInsets.only( + right: 10, + bottom: 10, + ), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -182,33 +186,29 @@ class DesktopAboutView extends ConsumerWidget { children: [ Text( "Version", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of( - context, - ) - .extension< - StackColors>()! - .textDark, - ), - ), - const SizedBox( - height: 2, + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension< + StackColors + >()! + .textDark, + ), ), + const SizedBox(height: 2), SelectableText( version, style: STextStyles.itemSubtitle( - context, - ), + context, + ), ), ], ), - const SizedBox( - width: 16, - ), + const SizedBox(width: 16), Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: @@ -216,33 +216,29 @@ class DesktopAboutView extends ConsumerWidget { children: [ Text( "Build number", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of( - context, - ) - .extension< - StackColors>()! - .textDark, - ), - ), - const SizedBox( - height: 2, + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension< + StackColors + >()! + .textDark, + ), ), + const SizedBox(height: 2), SelectableText( build, style: STextStyles.itemSubtitle( - context, - ), + context, + ), ), ], ), - const SizedBox( - width: 16, - ), + const SizedBox(width: 16), Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: @@ -250,27 +246,25 @@ class DesktopAboutView extends ConsumerWidget { children: [ Text( "Build commit", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of( - context, - ) - .extension< - StackColors>()! - .textDark, - ), - ), - const SizedBox( - height: 2, + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension< + StackColors + >()! + .textDark, + ), ), + const SizedBox(height: 2), SelectableText( GitStatus.appCommitHash, style: STextStyles.itemSubtitle( - context, - ), + context, + ), ), ], ), @@ -286,27 +280,25 @@ class DesktopAboutView extends ConsumerWidget { children: [ Text( "Build signature", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of( - context, - ) - .extension< - StackColors>()! - .textDark, - ), - ), - const SizedBox( - height: 2, + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension< + StackColors + >()! + .textDark, + ), ), + const SizedBox(height: 2), SelectableText( signature, style: STextStyles.itemSubtitle( - context, - ), + context, + ), ), ], ), @@ -317,74 +309,16 @@ class DesktopAboutView extends ConsumerWidget { spacing: 64, runSpacing: 32, children: [ - if (AppConfig.coins - .whereType() - .isNotEmpty) - FutureBuilder( - future: GitStatus - .getFiroCommitStatus(), - builder: ( - context, - AsyncSnapshot - snapshot, - ) { - CommitStatus stateOfCommit = - CommitStatus.notLoaded; - - if (snapshot.connectionState == - ConnectionState - .done && - snapshot.hasData) { - stateOfCommit = - snapshot.data!; - } - - return Column( - mainAxisSize: - MainAxisSize.min, - crossAxisAlignment: - CrossAxisAlignment - .start, - children: [ - Text( - "Firo Build Commit", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of( - context, - ) - .extension< - StackColors>()! - .textDark, - ), - ), - const SizedBox( - height: 2, - ), - SelectableText( - GitStatus.firoCommit, - style: GitStatus - .styleForStatus( - stateOfCommit, - context, - ), - ), - ], - ); - }, - ), if (AppConfig.coins .whereType() .isNotEmpty) FutureBuilder( - future: GitStatus - .getEpicCommitStatus(), + future: + GitStatus.getEpicCommitStatus(), builder: ( context, AsyncSnapshot - snapshot, + snapshot, ) { CommitStatus stateOfCommit = CommitStatus.notLoaded; @@ -406,29 +340,26 @@ class DesktopAboutView extends ConsumerWidget { children: [ Text( "Epic Cash Build Commit", - style: STextStyles - .desktopTextExtraExtraSmall( + style: STextStyles.desktopTextExtraExtraSmall( context, ).copyWith( - color: Theme.of( - context, - ) - .extension< - StackColors>()! - .textDark, + color: + Theme.of(context) + .extension< + StackColors + >()! + .textDark, ), ), - const SizedBox( - height: 2, - ), + const SizedBox(height: 2), SelectableText( GitStatus .epicCashCommit, - style: GitStatus - .styleForStatus( - stateOfCommit, - context, - ), + style: + GitStatus.styleForStatus( + stateOfCommit, + context, + ), ), ], ); @@ -498,14 +429,17 @@ class DesktopAboutView extends ConsumerWidget { children: [ Text( "Website:", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ), + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension< + StackColors + >()! + .textDark, + ), ), CustomTextButton( text: "https://stackwallet.com", @@ -514,8 +448,9 @@ class DesktopAboutView extends ConsumerWidget { Uri.parse( "https://stackwallet.com", ), - mode: LaunchMode - .externalApplication, + mode: + LaunchMode + .externalApplication, ); }, ), @@ -532,14 +467,17 @@ class DesktopAboutView extends ConsumerWidget { children: [ Text( "Tezos functionality:", - style: STextStyles - .desktopTextExtraExtraSmall( - context, - ).copyWith( - color: Theme.of(context) - .extension()! - .textDark, - ), + style: + STextStyles.desktopTextExtraExtraSmall( + context, + ).copyWith( + color: + Theme.of(context) + .extension< + StackColors + >()! + .textDark, + ), ), CustomTextButton( text: "Powered by TzKT API", @@ -548,8 +486,9 @@ class DesktopAboutView extends ConsumerWidget { Uri.parse( "https://tzkt.io", ), - mode: LaunchMode - .externalApplication, + mode: + LaunchMode + .externalApplication, ); }, ), diff --git a/lib/providers/ui/preview_tx_button_state_provider.dart b/lib/providers/ui/preview_tx_button_state_provider.dart index 196fe298d..35daf888f 100644 --- a/lib/providers/ui/preview_tx_button_state_provider.dart +++ b/lib/providers/ui/preview_tx_button_state_provider.dart @@ -20,31 +20,26 @@ final pValidSparkSendToAddress = StateProvider.autoDispose((_) => false); final pIsExchangeAddress = StateProvider((_) => false); -final pPreviewTxButtonEnabled = - Provider.autoDispose.family((ref, coin) { - final amount = ref.watch(pSendAmount) ?? Amount.zero; - - if (coin is Firo) { - final firoType = ref.watch(publicPrivateBalanceStateProvider); - switch (firoType) { - case FiroType.lelantus: - return ref.watch(pValidSendToAddress) && - !ref.watch(pValidSparkSendToAddress) && - amount > Amount.zero; - - case FiroType.spark: - return (ref.watch(pValidSendToAddress) || - ref.watch(pValidSparkSendToAddress)) && - !ref.watch(pIsExchangeAddress) && - amount > Amount.zero; - - case FiroType.public: +final pPreviewTxButtonEnabled = Provider.autoDispose + .family((ref, coin) { + final amount = ref.watch(pSendAmount) ?? Amount.zero; + + if (coin is Firo) { + final firoType = ref.watch(publicPrivateBalanceStateProvider); + switch (firoType) { + case FiroType.spark: + return (ref.watch(pValidSendToAddress) || + ref.watch(pValidSparkSendToAddress)) && + !ref.watch(pIsExchangeAddress) && + amount > Amount.zero; + + case FiroType.public: + return ref.watch(pValidSendToAddress) && amount > Amount.zero; + } + } else { return ref.watch(pValidSendToAddress) && amount > Amount.zero; - } - } else { - return ref.watch(pValidSendToAddress) && amount > Amount.zero; - } -}); + } + }); final previewTokenTxButtonStateProvider = StateProvider.autoDispose((_) { return false; diff --git a/lib/providers/wallet/public_private_balance_state_provider.dart b/lib/providers/wallet/public_private_balance_state_provider.dart index 8fa012edb..7484db9f0 100644 --- a/lib/providers/wallet/public_private_balance_state_provider.dart +++ b/lib/providers/wallet/public_private_balance_state_provider.dart @@ -10,11 +10,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart'; -enum FiroType { - public, - lelantus, - spark; -} +enum FiroType { public, spark } -final publicPrivateBalanceStateProvider = - StateProvider((_) => FiroType.spark); +final publicPrivateBalanceStateProvider = StateProvider( + (_) => FiroType.spark, +); diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 629a3a1a7..55f6964b3 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -143,7 +143,6 @@ import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_setting import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_recovery_phrase_view.dart'; import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/delete_wallet_warning_view.dart'; import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/edit_refresh_height_view.dart'; -import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/lelantus_settings_view.dart'; import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rbf_settings_view.dart'; import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart'; import 'pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/spark_info.dart'; @@ -179,7 +178,6 @@ import 'pages_desktop_specific/desktop_buy/desktop_buy_view.dart'; import 'pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart'; import 'pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart'; import 'pages_desktop_specific/desktop_home_view.dart'; -import 'pages_desktop_specific/lelantus_coins/lelantus_coins_view.dart'; import 'pages_desktop_specific/my_stack_view/my_stack_view.dart'; import 'pages_desktop_specific/my_stack_view/wallet_view/desktop_token_view.dart'; import 'pages_desktop_specific/my_stack_view/wallet_view/desktop_wallet_view.dart'; @@ -1512,7 +1510,7 @@ class RouteGenerator { return _routeError("${settings.name} invalid args: ${args.toString()}"); case RestoreWalletView.routeName: - if (args is Tuple6) { + if (args is Tuple5) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, builder: @@ -1522,7 +1520,6 @@ class RouteGenerator { seedWordsLength: args.item3, restoreBlockHeight: args.item4, mnemonicPassphrase: args.item5, - enableLelantusScanning: args.item6 ?? false, ), settings: RouteSettings(name: settings.name), ); @@ -1535,7 +1532,6 @@ class RouteGenerator { String walletName, CryptoCurrency coin, int restoreBlockHeight, - bool enableLelantusScanning, })) { return getRoute( shouldUseMaterialRoute: useMaterialPageRoute, @@ -1544,7 +1540,6 @@ class RouteGenerator { walletName: args.walletName, coin: args.coin, restoreBlockHeight: args.restoreBlockHeight, - enableLelantusScanning: args.enableLelantusScanning, ), settings: RouteSettings(name: settings.name), ); @@ -2045,16 +2040,6 @@ class RouteGenerator { } return _routeError("${settings.name} invalid args: ${args.toString()}"); - case LelantusSettingsView.routeName: - if (args is String) { - return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => LelantusSettingsView(walletId: args), - settings: RouteSettings(name: settings.name), - ); - } - return _routeError("${settings.name} invalid args: ${args.toString()}"); - case RbfSettingsView.routeName: if (args is String) { return getRoute( @@ -2232,16 +2217,6 @@ class RouteGenerator { } return _routeError("${settings.name} invalid args: ${args.toString()}"); - case LelantusCoinsView.routeName: - if (args is String) { - return getRoute( - shouldUseMaterialRoute: useMaterialPageRoute, - builder: (_) => LelantusCoinsView(walletId: args), - settings: RouteSettings(name: settings.name), - ); - } - return _routeError("${settings.name} invalid args: ${args.toString()}"); - case SparkCoinsView.routeName: if (args is String) { return getRoute( diff --git a/lib/utilities/git_status.dart b/lib/utilities/git_status.dart index 0a3f081a6..c89cf2439 100644 --- a/lib/utilities/git_status.dart +++ b/lib/utilities/git_status.dart @@ -2,9 +2,7 @@ import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:flutter_libepiccash/git_versions.dart' as epic_versions; -// import 'package:flutter_libmonero/git_versions.dart' as monero_versions; import 'package:http/http.dart'; -import 'package:lelantus/git_versions.dart' as firo_versions; import '../../../themes/stack_colors.dart'; import '../../../utilities/logger.dart'; @@ -18,37 +16,11 @@ const kGithubHead = "/repos"; enum CommitStatus { isHead, isOldCommit, notACommit, notLoaded } abstract class GitStatus { - static String get firoCommit => firo_versions.getPluginVersion(); static String get epicCashCommit => epic_versions.getPluginVersion(); // static String get moneroCommit => monero_versions.getPluginVersion(); static String get appCommitHash => AppConfig.commitHash; - static CommitStatus? _cachedFiroStatus; - static Future getFiroCommitStatus() async { - if (_cachedFiroStatus != null) { - return _cachedFiroStatus!; - } - - final List results = await Future.wait([ - _doesCommitExist("cypherstack", "flutter_liblelantus", firoCommit), - _isHeadCommit("cypherstack", "flutter_liblelantus", "main", firoCommit), - ]); - - final commitExists = results[0]; - final commitIsHead = results[1]; - - if (commitExists && commitIsHead) { - _cachedFiroStatus = CommitStatus.isHead; - } else if (commitExists) { - _cachedFiroStatus = CommitStatus.isOldCommit; - } else { - _cachedFiroStatus = CommitStatus.notACommit; - } - - return _cachedFiroStatus!; - } - static CommitStatus? _cachedEpicStatus; static Future getEpicCommitStatus() async { if (_cachedEpicStatus != null) { @@ -78,59 +50,24 @@ abstract class GitStatus { return _cachedEpicStatus!; } - // - // static CommitStatus? _cachedMoneroStatus; - // static Future getMoneroCommitStatus() async { - // if (_cachedMoneroStatus != null) { - // return _cachedMoneroStatus!; - // } - // - // final List results = await Future.wait([ - // _doesCommitExist("cypherstack", "flutter_libmonero", moneroCommit), - // _isHeadCommit("cypherstack", "flutter_libmonero", "main", moneroCommit), - // ]); - // - // final commitExists = results[0]; - // final commitIsHead = results[1]; - // - // if (commitExists && commitIsHead) { - // _cachedMoneroStatus = CommitStatus.isHead; - // } else if (commitExists) { - // _cachedMoneroStatus = CommitStatus.isOldCommit; - // } else { - // _cachedMoneroStatus = CommitStatus.notACommit; - // } - // - // return _cachedMoneroStatus!; - // } static TextStyle styleForStatus(CommitStatus status, BuildContext context) { final Color color; switch (status) { case CommitStatus.isHead: - color = Theme.of( - context, - ).extension()!.accentColorGreen; + color = Theme.of(context).extension()!.accentColorGreen; break; case CommitStatus.isOldCommit: - color = Theme.of( - context, - ).extension()!.accentColorYellow; + color = Theme.of(context).extension()!.accentColorYellow; break; case CommitStatus.notACommit: - color = Theme.of( - context, - ).extension()!.accentColorRed; + color = Theme.of(context).extension()!.accentColorRed; break; default: - return STextStyles.itemSubtitle( - context, - ); + return STextStyles.itemSubtitle(context); } - return STextStyles.itemSubtitle( - context, - ).copyWith(color: color); + return STextStyles.itemSubtitle(context).copyWith(color: color); } static Future _doesCommitExist( diff --git a/lib/utilities/prefs.dart b/lib/utilities/prefs.dart index a436c8483..087aaa631 100644 --- a/lib/utilities/prefs.dart +++ b/lib/utilities/prefs.dart @@ -1270,7 +1270,7 @@ class Prefs extends ChangeNotifier { true; } - // Show/hide lelantus and spark coins. Defaults to false + // Show/hide spark coins. Defaults to false bool _advancedFiroFeatures = false; bool get advancedFiroFeatures => _advancedFiroFeatures; set advancedFiroFeatures(bool advancedFiroFeatures) { diff --git a/lib/utilities/wallet_tools.dart b/lib/utilities/wallet_tools.dart index 8d869ea63..b38578370 100644 --- a/lib/utilities/wallet_tools.dart +++ b/lib/utilities/wallet_tools.dart @@ -2,7 +2,6 @@ import 'package:isar/isar.dart'; import '../db/isar/main_db.dart'; import '../models/isar/models/blockchain_data/v2/transaction_v2.dart'; -import '../models/isar/models/firo_specific/lelantus_coin.dart'; import '../wallets/crypto_currency/crypto_currency.dart'; import '../wallets/isar/models/spark_coin.dart'; import '../wallets/wallet/impl/firo_wallet.dart'; @@ -20,10 +19,11 @@ abstract class WalletDevTools { maxDecimals: 8, ); - final all = MainDB.instance.isar.transactionV2s - .where() - .walletIdEqualTo(wallet.walletId) - .findAllSync(); + final all = + MainDB.instance.isar.transactionV2s + .where() + .walletIdEqualTo(wallet.walletId) + .findAllSync(); final totalCount = all.length; @@ -47,14 +47,11 @@ abstract class WalletDevTools { fractionDigits: 8, ); - final lelantusCoinsCount = MainDB.instance.isar.lelantusCoins - .where() - .walletIdEqualTo(wallet.walletId) - .countSync(); - final sparkCoinsCount = MainDB.instance.isar.sparkCoins - .where() - .walletIdEqualToAnyLTagHash(wallet.walletId) - .countSync(); + final sparkCoinsCount = + MainDB.instance.isar.sparkCoins + .where() + .walletIdEqualToAnyLTagHash(wallet.walletId) + .countSync(); final buffer = StringBuffer(); buffer.writeln("============= ${wallet.info.name} ============="); @@ -63,7 +60,6 @@ abstract class WalletDevTools { buffer.writeln( "balanceAccordingToTxns: ${amtFmt.format(balanceAccordingToTxHistory)}", ); - buffer.writeln("lelantusCoinsCount: $lelantusCoinsCount"); buffer.writeln("sparkCoinsCount: $sparkCoinsCount"); buffer.writeln("=================================================="); diff --git a/lib/wallets/api/lelantus_ffi_wrapper.dart b/lib/wallets/api/lelantus_ffi_wrapper.dart deleted file mode 100644 index 3ee60d994..000000000 --- a/lib/wallets/api/lelantus_ffi_wrapper.dart +++ /dev/null @@ -1,551 +0,0 @@ -import 'package:bip32/bip32.dart'; -import 'package:bitcoindart/bitcoindart.dart' as bitcoindart; -import 'package:flutter/foundation.dart'; -import 'package:lelantus/lelantus.dart' as lelantus; - -import '../../models/isar/models/isar_models.dart' as isar_models; -import '../../models/isar/models/isar_models.dart'; -import '../../models/lelantus_fee_data.dart'; -import '../../utilities/amount/amount.dart'; -import '../../utilities/extensions/impl/string.dart'; -import '../../utilities/extensions/impl/uint8_list.dart'; -import '../../utilities/format.dart'; -import '../../utilities/logger.dart'; -import '../crypto_currency/intermediate/bip39_hd_currency.dart'; -import '../models/tx_data.dart'; - -abstract final class LelantusFfiWrapper { - static const MINT_LIMIT = 5001 * 100000000; - static const MINT_LIMIT_TESTNET = 1001 * 100000000; - - static const JMINT_INDEX = 5; - static const MINT_INDEX = 2; - static const TRANSACTION_LELANTUS = 8; - static const ANONYMITY_SET_EMPTY_ID = 0; - - // partialDerivationPath should be something like "m/$purpose'/$coinType'/$account'/" - static Future<({List spendTxIds, List lelantusCoins})> - restore({ - required final String hexRootPrivateKey, - required final Uint8List chaincode, - required final Bip39HDCurrency cryptoCurrency, - required final int latestSetId, - required final Map setDataMap, - required final Set usedSerialNumbers, - required final String walletId, - required final String partialDerivationPath, - }) async { - final args = ( - hexRootPrivateKey: hexRootPrivateKey, - chaincode: chaincode, - cryptoCurrency: cryptoCurrency, - latestSetId: latestSetId, - setDataMap: setDataMap, - usedSerialNumbers: usedSerialNumbers, - walletId: walletId, - partialDerivationPath: partialDerivationPath, - ); - try { - return await compute(_restore, args); - } catch (e, s) { - Logging.instance.i("Exception rethrown from _restore(): ", error: e, stackTrace: s); - rethrow; - } - } - - // partialDerivationPath should be something like "m/$purpose'/$coinType'/$account'/" - static Future<({List spendTxIds, List lelantusCoins})> - _restore( - ({ - String hexRootPrivateKey, - Uint8List chaincode, - Bip39HDCurrency cryptoCurrency, - int latestSetId, - Map setDataMap, - Set usedSerialNumbers, - String walletId, - String partialDerivationPath, - }) args, - ) async { - final List jindexes = []; - final List lelantusCoins = []; - - final List spendTxIds = []; - int lastFoundIndex = 0; - int currentIndex = 0; - - final root = BIP32.fromPrivateKey( - args.hexRootPrivateKey.toUint8ListFromHex, - args.chaincode, - ); - - while (currentIndex < lastFoundIndex + 50) { - final mintKeyPair = root.derivePath( - "${args.partialDerivationPath}$MINT_INDEX/$currentIndex", - ); - - final String mintTag = lelantus.CreateTag( - mintKeyPair.privateKey!.toHex, - currentIndex, - mintKeyPair.identifier.toHex, - isTestnet: args.cryptoCurrency.network.isTestNet, - ); - - for (int setId = 1; setId <= args.latestSetId; setId++) { - final setData = args.setDataMap[setId] as Map; - final foundCoin = (setData["coins"] as List).firstWhere( - (e) => e[1] == mintTag, - orElse: () => [], - ); - - if (foundCoin.length == 4) { - lastFoundIndex = currentIndex; - - final String publicCoin = foundCoin[0] as String; - final String txId = foundCoin[3] as String; - - // this value will either be an int or a String - final dynamic thirdValue = foundCoin[2]; - - if (thirdValue is int) { - final int amount = thirdValue; - final String serialNumber = lelantus.GetSerialNumber( - amount, - mintKeyPair.privateKey!.toHex, - currentIndex, - isTestnet: args.cryptoCurrency.network.isTestNet, - ); - final bool isUsed = args.usedSerialNumbers.contains(serialNumber); - - lelantusCoins.removeWhere( - (e) => - e.txid == txId && - e.mintIndex == currentIndex && - e.anonymitySetId != setId, - ); - - lelantusCoins.add( - isar_models.LelantusCoin( - walletId: args.walletId, - mintIndex: currentIndex, - value: amount.toString(), - txid: txId, - anonymitySetId: setId, - isUsed: isUsed, - isJMint: false, - otherData: - publicCoin, // not really needed but saved just in case - ), - ); - debugPrint("serial=$serialNumber amount=$amount used=$isUsed"); - } else if (thirdValue is String) { - final int keyPath = lelantus.GetAesKeyPath(publicCoin); - - final aesKeyPair = root.derivePath( - "${args.partialDerivationPath}$JMINT_INDEX/$keyPath", - ); - - try { - final String aesPrivateKey = aesKeyPair.privateKey!.toHex; - - final int amount = lelantus.decryptMintAmount( - aesPrivateKey, - thirdValue, - ); - - final String serialNumber = lelantus.GetSerialNumber( - amount, - aesPrivateKey, - currentIndex, - isTestnet: args.cryptoCurrency.network.isTestNet, - ); - final bool isUsed = args.usedSerialNumbers.contains(serialNumber); - - lelantusCoins.removeWhere( - (e) => - e.txid == txId && - e.mintIndex == currentIndex && - e.anonymitySetId != setId, - ); - - lelantusCoins.add( - isar_models.LelantusCoin( - walletId: args.walletId, - mintIndex: currentIndex, - value: amount.toString(), - txid: txId, - anonymitySetId: setId, - isUsed: isUsed, - isJMint: true, - otherData: - publicCoin, // not really needed but saved just in case - ), - ); - jindexes.add(currentIndex); - - spendTxIds.add(txId); - } catch (_) { - debugPrint("AES keypair derivation issue for key path: $keyPath"); - } - } else { - debugPrint("Unexpected coin found: $foundCoin"); - } - } - } - - currentIndex++; - } - - return (spendTxIds: spendTxIds, lelantusCoins: lelantusCoins); - } - - static Future estimateJoinSplitFee({ - required Amount spendAmount, - required bool subtractFeeFromAmount, - required List lelantusEntries, - required bool isTestNet, - }) async { - return await compute( - LelantusFfiWrapper._estimateJoinSplitFee, - ( - spendAmount: spendAmount.raw.toInt(), - subtractFeeFromAmount: subtractFeeFromAmount, - lelantusEntries: lelantusEntries, - isTestNet: isTestNet, - ), - ); - } - - static Future _estimateJoinSplitFee( - ({ - int spendAmount, - bool subtractFeeFromAmount, - List lelantusEntries, - bool isTestNet, - }) data, - ) async { - debugPrint("estimateJoinSplit fee"); - // for (int i = 0; i < lelantusEntries.length; i++) { - // Logging.instance.log(lelantusEntries[i], addToDebugMessagesDB: false); - // } - debugPrint( - "${data.spendAmount} ${data.subtractFeeFromAmount}", - ); - - final List changeToMint = List.empty(growable: true); - final List spendCoinIndexes = List.empty(growable: true); - // Logging.instance.log(lelantusEntries, addToDebugMessagesDB: false); - final fee = lelantus.estimateFee( - data.spendAmount, - data.subtractFeeFromAmount, - data.lelantusEntries, - changeToMint, - spendCoinIndexes, - isTestnet: data.isTestNet, - ); - - final estimateFeeData = LelantusFeeData( - changeToMint[0], - fee, - spendCoinIndexes, - ); - debugPrint( - "estimateFeeData ${estimateFeeData.changeToMint}" - " ${estimateFeeData.fee}" - " ${estimateFeeData.spendCoinIndexes}", - ); - return estimateFeeData; - } - - static Future createJoinSplitTransaction({ - required TxData txData, - required bool subtractFeeFromAmount, - required int nextFreeMintIndex, - required int locktime, // set to current chain height - required List lelantusEntries, - required List> anonymitySets, - required Bip39HDCurrency cryptoCurrency, - required String partialDerivationPath, - required String hexRootPrivateKey, - required Uint8List chaincode, - }) async { - final arg = ( - txData: txData, - subtractFeeFromAmount: subtractFeeFromAmount, - index: nextFreeMintIndex, - lelantusEntries: lelantusEntries, - locktime: locktime, - cryptoCurrency: cryptoCurrency, - anonymitySetsArg: anonymitySets, - partialDerivationPath: partialDerivationPath, - hexRootPrivateKey: hexRootPrivateKey, - chaincode: chaincode, - ); - - return await compute(_createJoinSplitTransaction, arg); - } - - static Future _createJoinSplitTransaction( - ({ - TxData txData, - bool subtractFeeFromAmount, - int index, - List lelantusEntries, - int locktime, - Bip39HDCurrency cryptoCurrency, - List> anonymitySetsArg, - String partialDerivationPath, - String hexRootPrivateKey, - Uint8List chaincode, - }) arg, - ) async { - final spendAmount = arg.txData.recipients!.first.amount.raw.toInt(); - final address = arg.txData.recipients!.first.address; - final isChange = arg.txData.recipients!.first.isChange; - - final estimateJoinSplitFee = await _estimateJoinSplitFee( - ( - spendAmount: spendAmount, - subtractFeeFromAmount: arg.subtractFeeFromAmount, - lelantusEntries: arg.lelantusEntries, - isTestNet: arg.cryptoCurrency.network.isTestNet, - ), - ); - final changeToMint = estimateJoinSplitFee.changeToMint; - final fee = estimateJoinSplitFee.fee; - final spendCoinIndexes = estimateJoinSplitFee.spendCoinIndexes; - debugPrint("$changeToMint $fee $spendCoinIndexes"); - if (spendCoinIndexes.isEmpty) { - throw Exception("Error, Not enough funds."); - } - - final params = arg.cryptoCurrency.networkParams; - final _network = bitcoindart.NetworkType( - messagePrefix: params.messagePrefix, - bech32: params.bech32Hrp, - bip32: bitcoindart.Bip32Type( - public: params.pubHDPrefix, - private: params.privHDPrefix, - ), - pubKeyHash: params.p2pkhPrefix, - scriptHash: params.p2shPrefix, - wif: params.wifPrefix, - ); - - final tx = bitcoindart.TransactionBuilder(network: _network); - tx.setLockTime(arg.locktime); - - tx.setVersion(3 | (TRANSACTION_LELANTUS << 16)); - - tx.addInput( - '0000000000000000000000000000000000000000000000000000000000000000', - 4294967295, - 4294967295, - Uint8List(0), - ); - final derivePath = "${arg.partialDerivationPath}$MINT_INDEX/${arg.index}"; - - final root = BIP32.fromPrivateKey( - arg.hexRootPrivateKey.toUint8ListFromHex, - arg.chaincode, - ); - - final jmintKeyPair = root.derivePath(derivePath); - - final String jmintprivatekey = jmintKeyPair.privateKey!.toHex; - - final keyPath = lelantus.getMintKeyPath( - changeToMint, - jmintprivatekey, - arg.index, - isTestnet: arg.cryptoCurrency.network.isTestNet, - ); - - final _derivePath = "${arg.partialDerivationPath}$JMINT_INDEX/$keyPath"; - - final aesKeyPair = root.derivePath(_derivePath); - final aesPrivateKey = aesKeyPair.privateKey!.toHex; - - final jmintData = lelantus.createJMintScript( - changeToMint, - jmintprivatekey, - arg.index, - Format.uint8listToString(jmintKeyPair.identifier), - aesPrivateKey, - isTestnet: arg.cryptoCurrency.network.isTestNet, - ); - - tx.addOutput( - Format.stringToUint8List(jmintData), - 0, - ); - - int amount = spendAmount; - if (arg.subtractFeeFromAmount) { - amount -= fee; - } - tx.addOutput( - address, - amount, - ); - - final extractedTx = tx.buildIncomplete(); - extractedTx.setPayload(Uint8List(0)); - final txHash = extractedTx.getId(); - - final List setIds = []; - final List> anonymitySets = []; - final List anonymitySetHashes = []; - final List groupBlockHashes = []; - for (var i = 0; i < arg.lelantusEntries.length; i++) { - final anonymitySetId = arg.lelantusEntries[i].anonymitySetId; - if (!setIds.contains(anonymitySetId)) { - setIds.add(anonymitySetId); - final anonymitySet = arg.anonymitySetsArg.firstWhere( - (element) => element["setId"] == anonymitySetId, - orElse: () => {}, - ); - if (anonymitySet.isNotEmpty) { - anonymitySetHashes.add(anonymitySet['setHash'] as String); - groupBlockHashes.add(anonymitySet['blockHash'] as String); - final List list = []; - for (int i = 0; i < (anonymitySet['coins'] as List).length; i++) { - list.add(anonymitySet['coins'][i][0] as String); - } - anonymitySets.add(list); - } - } - } - - final String spendScript = lelantus.createJoinSplitScript( - txHash, - spendAmount, - arg.subtractFeeFromAmount, - jmintprivatekey, - arg.index, - arg.lelantusEntries, - setIds, - anonymitySets, - anonymitySetHashes, - groupBlockHashes, - isTestnet: arg.cryptoCurrency.network.isTestNet, - ); - - final finalTx = bitcoindart.TransactionBuilder(network: _network); - finalTx.setLockTime(arg.locktime); - - finalTx.setVersion(3 | (TRANSACTION_LELANTUS << 16)); - - finalTx.addOutput( - Format.stringToUint8List(jmintData), - 0, - ); - - finalTx.addOutput( - address, - amount, - ); - - final extTx = finalTx.buildIncomplete(); - extTx.addInput( - Format.stringToUint8List( - '0000000000000000000000000000000000000000000000000000000000000000', - ), - 4294967295, - 4294967295, - Format.stringToUint8List("c9"), - ); - // debugPrint("spendscript: $spendScript"); - extTx.setPayload(Format.stringToUint8List(spendScript)); - - final txHex = extTx.toHex(); - final txId = extTx.getId(); - - final amountAmount = Amount( - rawValue: BigInt.from(amount), - fractionDigits: arg.cryptoCurrency.fractionDigits, - ); - - return arg.txData.copyWith( - txid: txId, - raw: txHex, - recipients: [ - (address: address, amount: amountAmount, isChange: isChange), - ], - fee: Amount( - rawValue: BigInt.from(fee), - fractionDigits: arg.cryptoCurrency.fractionDigits, - ), - vSize: extTx.virtualSize(), - jMintValue: changeToMint, - spendCoinIndexes: spendCoinIndexes, - height: arg.locktime, - txType: TransactionType.outgoing, - txSubType: TransactionSubType.join, - // "confirmed_status": false, - // "timestamp": DateTime.now().millisecondsSinceEpoch ~/ 1000, - ); - - // return { - // "txid": txId, - // "txHex": txHex, - // "value": amount, - // "fees": Amount( - // rawValue: BigInt.from(fee), - // fractionDigits: arg.cryptoCurrency.fractionDigits, - // ).decimal.toDouble(), - // "fee": fee, - // "vSize": extTx.virtualSize(), - // "jmintValue": changeToMint, - // "spendCoinIndexes": spendCoinIndexes, - // "height": arg.locktime, - // "txType": "Sent", - // "confirmed_status": false, - // "amount": amountAmount.decimal.toDouble(), - // "recipientAmt": amountAmount, - // "address": arg.address, - // "timestamp": DateTime.now().millisecondsSinceEpoch ~/ 1000, - // "subType": "join", - // }; - } - - // =========================================================================== - - static Future _getMintScriptWrapper( - ({ - int amount, - String privateKeyHex, - int index, - String seedId, - bool isTestNet - }) data, - ) async { - final String mintHex = lelantus.getMintScript( - data.amount, - data.privateKeyHex, - data.index, - data.seedId, - isTestnet: data.isTestNet, - ); - return mintHex; - } - - static Future getMintScript({ - required Amount amount, - required String privateKeyHex, - required int index, - required String seedId, - required bool isTestNet, - }) async { - return await compute( - LelantusFfiWrapper._getMintScriptWrapper, - ( - amount: amount.raw.toInt(), - privateKeyHex: privateKeyHex, - index: index, - seedId: seedId, - isTestNet: isTestNet - ), - ); - } -} diff --git a/lib/wallets/isar/models/wallet_info.dart b/lib/wallets/isar/models/wallet_info.dart index f943ea5aa..bb4dd4ab2 100644 --- a/lib/wallets/isar/models/wallet_info.dart +++ b/lib/wallets/isar/models/wallet_info.dart @@ -497,9 +497,6 @@ abstract class WalletInfoKeys { static const String bananoMonkeyImageBytes = "monkeyImageBytesKey"; static const String tezosDerivationPath = "tezosDerivationPathKey"; static const String xelisDerivationPath = "xelisDerivationPathKey"; - static const String lelantusCoinIsarRescanRequired = - "lelantusCoinIsarRescanRequired"; - static const String enableLelantusScanning = "enableLelantusScanningKey"; static const String firoSparkCacheSetBlockHashCache = "firoSparkCacheSetBlockHashCacheKey"; static const String enableOptInRbf = "enableOptInRbfKey"; diff --git a/lib/wallets/models/tx_data.dart b/lib/wallets/models/tx_data.dart index 96882d428..28b985be4 100644 --- a/lib/wallets/models/tx_data.dart +++ b/lib/wallets/models/tx_data.dart @@ -52,15 +52,9 @@ class TxData { final BigInt? chainId; // wownero and monero specific final lib_monero.PendingTransaction? pendingTransaction; - final lib_salvium.PendingTransaction? pendingSalviumTransaction; - // firo lelantus specific - final int? jMintValue; - final List? spendCoinIndexes; - final int? height; - final TransactionType? txType; - final TransactionSubType? txSubType; - final List>? mintsMapLelantus; + // salvium + final lib_salvium.PendingTransaction? pendingSalviumTransaction; // tezos specific final tezart.OperationsList? tezosOperationsList; @@ -113,12 +107,6 @@ class TxData { this.chainId, this.pendingTransaction, this.pendingSalviumTransaction, - this.jMintValue, - this.spendCoinIndexes, - this.height, - this.txType, - this.txSubType, - this.mintsMapLelantus, this.tezosOperationsList, this.sparkRecipients, this.otherData, @@ -303,12 +291,6 @@ class TxData { pendingTransaction: pendingTransaction ?? this.pendingTransaction, pendingSalviumTransaction: pendingSalviumTransaction ?? this.pendingSalviumTransaction, - jMintValue: jMintValue ?? this.jMintValue, - spendCoinIndexes: spendCoinIndexes ?? this.spendCoinIndexes, - height: height ?? this.height, - txType: txType ?? this.txType, - txSubType: txSubType ?? this.txSubType, - mintsMapLelantus: mintsMapLelantus ?? this.mintsMapLelantus, tezosOperationsList: tezosOperationsList ?? this.tezosOperationsList, sparkRecipients: sparkRecipients ?? this.sparkRecipients, sparkMints: sparkMints ?? this.sparkMints, @@ -347,12 +329,6 @@ class TxData { 'chainId: $chainId, ' 'pendingTransaction: $pendingTransaction, ' 'pendingSalviumTransaction: $pendingSalviumTransaction, ' - 'jMintValue: $jMintValue, ' - 'spendCoinIndexes: $spendCoinIndexes, ' - 'height: $height, ' - 'txType: $txType, ' - 'txSubType: $txSubType, ' - 'mintsMapLelantus: $mintsMapLelantus, ' 'tezosOperationsList: $tezosOperationsList, ' 'sparkRecipients: $sparkRecipients, ' 'sparkMints: $sparkMints, ' diff --git a/lib/wallets/wallet/impl/firo_wallet.dart b/lib/wallets/wallet/impl/firo_wallet.dart index 75d7290a9..233bfd344 100644 --- a/lib/wallets/wallet/impl/firo_wallet.dart +++ b/lib/wallets/wallet/impl/firo_wallet.dart @@ -23,7 +23,6 @@ import '../intermediate/bip39_hd_wallet.dart'; import '../wallet_mixin_interfaces/coin_control_interface.dart'; import '../wallet_mixin_interfaces/electrumx_interface.dart'; import '../wallet_mixin_interfaces/extended_keys_interface.dart'; -import '../wallet_mixin_interfaces/lelantus_interface.dart'; import '../wallet_mixin_interfaces/spark_interface.dart'; const sparkStartBlock = 819300; // (approx 18 Jan 2024) @@ -32,11 +31,9 @@ class FiroWallet extends Bip39HDWallet with ElectrumXInterface, ExtendedKeysInterface, - LelantusInterface, SparkInterface, CoinControlInterface { // IMPORTANT: The order of the above mixins matters. - // SparkInterface MUST come after LelantusInterface. FiroWallet(CryptoCurrencyNetwork network) : super(Firo(network) as T); @@ -695,20 +692,6 @@ class FiroWallet extends Bip39HDWallet await mainDB.deleteWalletBlockchainData(walletId); } - // lelantus - int? latestSetId; - final List> lelantusFutures = []; - final enableLelantusScanning = - info.otherData[WalletInfoKeys.enableLelantusScanning] as bool? ?? - false; - if (enableLelantusScanning) { - latestSetId = await electrumXClient.getLelantusLatestCoinId(); - lelantusFutures.add( - electrumXCachedClient.getUsedCoinSerials(cryptoCurrency: info.coin), - ); - lelantusFutures.add(getSetDataMap(latestSetId)); - } - // spark final latestSparkCoinId = await electrumXClient.getSparkLatestCoinId(); final List> sparkAnonSetFutures = []; @@ -809,44 +792,9 @@ class FiroWallet extends Bip39HDWallet await Future.wait([updateTransactions(), updateUTXOs()]); - final List> futures = []; - if (enableLelantusScanning) { - futures.add(lelantusFutures[0]); - futures.add(lelantusFutures[1]); - } - futures.add(sparkUsedCoinTagsFuture); - futures.addAll(sparkAnonSetFutures); - - final futureResults = await Future.wait(futures); + await Future.wait([sparkUsedCoinTagsFuture, ...sparkAnonSetFutures]); - // lelantus - Set? usedSerialsSet; - Map? setDataMap; - if (enableLelantusScanning) { - usedSerialsSet = (futureResults[0] as List).toSet(); - setDataMap = futureResults[1] as Map; - } - - if (Util.isDesktop) { - await Future.wait([ - if (enableLelantusScanning) - recoverLelantusWallet( - latestSetId: latestSetId!, - usedSerialNumbers: usedSerialsSet!, - setDataMap: setDataMap!, - ), - recoverSparkWallet(latestSparkCoinId: latestSparkCoinId), - ]); - } else { - if (enableLelantusScanning) { - await recoverLelantusWallet( - latestSetId: latestSetId!, - usedSerialNumbers: usedSerialsSet!, - setDataMap: setDataMap!, - ); - } - await recoverSparkWallet(latestSparkCoinId: latestSparkCoinId); - } + await recoverSparkWallet(latestSparkCoinId: latestSparkCoinId); }); unawaited(refresh()); @@ -884,23 +832,4 @@ class FiroWallet extends Bip39HDWallet int estimateTxFee({required int vSize, required BigInt feeRatePerKB}) { return vSize * (feeRatePerKB.toInt() / 1000).ceil(); } - - // =========================================================================== - - bool get lelantusCoinIsarRescanRequired => - info.otherData[WalletInfoKeys.lelantusCoinIsarRescanRequired] as bool? ?? - true; - - Future firoRescanRecovery() async { - try { - await recover(isRescan: true); - await info.updateOtherData( - newEntries: {WalletInfoKeys.lelantusCoinIsarRescanRequired: false}, - isar: mainDB.isar, - ); - return true; - } catch (_) { - return false; - } - } } diff --git a/lib/wallets/wallet/wallet.dart b/lib/wallets/wallet/wallet.dart index 19923d45a..6ea950fe7 100644 --- a/lib/wallets/wallet/wallet.dart +++ b/lib/wallets/wallet/wallet.dart @@ -52,7 +52,6 @@ import 'impl/wownero_wallet.dart'; import 'impl/xelis_wallet.dart'; import 'intermediate/cryptonote_wallet.dart'; import 'wallet_mixin_interfaces/electrumx_interface.dart'; -import 'wallet_mixin_interfaces/lelantus_interface.dart'; import 'wallet_mixin_interfaces/mnemonic_interface.dart'; import 'wallet_mixin_interfaces/multi_address_interface.dart'; import 'wallet_mixin_interfaces/paynym_interface.dart'; @@ -686,13 +685,6 @@ abstract class Wallet { // await getAllTxsToWatch(); - // TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided. - if (this is LelantusInterface && !viewOnly) { - if (info.otherData[WalletInfoKeys.enableLelantusScanning] as bool? ?? - false) { - await (this as LelantusInterface).refreshLelantusData(); - } - } _fireRefreshPercentChange(0.90); await updateBalance(); diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart deleted file mode 100644 index 1a7937113..000000000 --- a/lib/wallets/wallet/wallet_mixin_interfaces/lelantus_interface.dart +++ /dev/null @@ -1,1215 +0,0 @@ -import 'dart:async'; -import 'dart:math'; -import 'dart:typed_data'; - -import 'package:bitcoindart/bitcoindart.dart' as bitcoindart; -import 'package:decimal/decimal.dart'; -import 'package:isar/isar.dart'; -import 'package:lelantus/lelantus.dart' as lelantus; -import 'package:tuple/tuple.dart'; - -import '../../../models/balance.dart'; -import '../../../models/isar/models/isar_models.dart'; -import '../../../models/lelantus_fee_data.dart'; -import '../../../utilities/amount/amount.dart'; -import '../../../utilities/enums/derive_path_type_enum.dart'; -import '../../../utilities/extensions/impl/uint8_list.dart'; -import '../../../utilities/format.dart'; -import '../../../utilities/logger.dart'; -import '../../api/lelantus_ffi_wrapper.dart'; -import '../../crypto_currency/interfaces/electrumx_currency_interface.dart'; -import '../../models/tx_data.dart'; -import '../intermediate/bip39_hd_wallet.dart'; -import 'electrumx_interface.dart'; - -mixin LelantusInterface - on Bip39HDWallet, ElectrumXInterface { - Future estimateFeeForLelantus(Amount amount) async { - final lelantusEntries = await _getLelantusEntry(); - final int spendAmount = amount.raw.toInt(); - if (spendAmount == 0 || lelantusEntries.isEmpty) { - return Amount( - rawValue: BigInt.from(LelantusFeeData(0, 0, []).fee), - fractionDigits: cryptoCurrency.fractionDigits, - ); - } - - final result = await LelantusFfiWrapper.estimateJoinSplitFee( - spendAmount: amount, - subtractFeeFromAmount: true, - lelantusEntries: lelantusEntries, - isTestNet: cryptoCurrency.network.isTestNet, - ); - - return Amount( - rawValue: BigInt.from(result.fee), - fractionDigits: cryptoCurrency.fractionDigits, - ); - } - - Future> _getLelantusEntry() async { - final List lelantusCoins = - await mainDB.isar.lelantusCoins - .where() - .walletIdEqualTo(walletId) - .filter() - .isUsedEqualTo(false) - .not() - .group( - (q) => q - .valueEqualTo("0") - .or() - .anonymitySetIdEqualTo( - LelantusFfiWrapper.ANONYMITY_SET_EMPTY_ID, - ), - ) - .findAll(); - - final root = await getRootHDNode(); - - final waitLelantusEntries = - lelantusCoins.map((coin) async { - final derivePath = cryptoCurrency.constructDerivePath( - derivePathType: DerivePathType.bip44, - chain: LelantusFfiWrapper.MINT_INDEX, - index: coin.mintIndex, - ); - - try { - final keyPair = root.derivePath(derivePath); - final String privateKey = keyPair.privateKey.data.toHex; - return lelantus.DartLelantusEntry( - coin.isUsed ? 1 : 0, - 0, - coin.anonymitySetId, - int.parse(coin.value), - coin.mintIndex, - privateKey, - ); - } catch (e, s) { - Logging.instance.e("error bad key"); - Logging.instance.t("error bad key", error: e, stackTrace: s); - return lelantus.DartLelantusEntry(1, 0, 0, 0, 0, ''); - } - }).toList(); - - final lelantusEntries = await Future.wait(waitLelantusEntries); - - if (lelantusEntries.isNotEmpty) { - // should be redundant as _getUnspentCoins() should - // already remove all where value=0 - lelantusEntries.removeWhere((element) => element.amount == 0); - } - - return lelantusEntries; - } - - Future prepareSendLelantus({required TxData txData}) async { - if (txData.recipients!.length != 1) { - throw Exception("Lelantus send requires a single recipient"); - } - - if (txData.recipients!.first.amount.raw > - BigInt.from(LelantusFfiWrapper.MINT_LIMIT)) { - throw Exception( - "Lelantus sends of more than 5001 are currently disabled", - ); - } - - try { - // check for send all - bool isSendAll = false; - final balance = info.cachedBalanceSecondary.spendable; - if (txData.recipients!.first.amount == balance) { - // print("is send all"); - isSendAll = true; - } - - final lastUsedIndex = await mainDB.getHighestUsedMintIndex( - walletId: walletId, - ); - final nextFreeMintIndex = (lastUsedIndex ?? 0) + 1; - - final root = await getRootHDNode(); - - final derivePath = cryptoCurrency.constructDerivePath( - derivePathType: DerivePathType.bip44, - chain: 0, - index: 0, - ); - final partialDerivationPath = derivePath.substring( - 0, - derivePath.length - 3, - ); - - final result = await LelantusFfiWrapper.createJoinSplitTransaction( - txData: txData, - subtractFeeFromAmount: isSendAll, - nextFreeMintIndex: nextFreeMintIndex, - locktime: await chainHeight, - lelantusEntries: await _getLelantusEntry(), - anonymitySets: await fetchAnonymitySets(), - cryptoCurrency: cryptoCurrency, - partialDerivationPath: partialDerivationPath, - hexRootPrivateKey: root.privateKey.data.toHex, - chaincode: root.chaincode, - ); - - Logging.instance.d("prepared fee: ${result.fee}"); - Logging.instance.d("prepared vSize: ${result.vSize}"); - - // fee should never be less than vSize sanity check - if (result.fee!.raw.toInt() < result.vSize!) { - throw Exception( - "Error in fee calculation: Transaction fee cannot be less than vSize", - ); - } - return result; - } catch (e, s) { - Logging.instance.e( - "Exception rethrown in firo prepareSend()", - error: e, - stackTrace: s, - ); - rethrow; - } - } - - Future confirmSendLelantus({required TxData txData}) async { - final latestSetId = await electrumXClient.getLelantusLatestCoinId(); - final txid = await electrumXClient.broadcastTransaction(rawTx: txData.raw!); - - assert(txid == txData.txid!); - - final lastUsedIndex = await mainDB.getHighestUsedMintIndex( - walletId: walletId, - ); - final nextFreeMintIndex = (lastUsedIndex ?? 0) + 1; - - if (txData.spendCoinIndexes != null) { - // This is a joinsplit - - final spentCoinIndexes = txData.spendCoinIndexes!; - final List updatedCoins = []; - - // Update all of the coins that have been spent. - - for (final index in spentCoinIndexes) { - final possibleCoin = - await mainDB.isar.lelantusCoins - .where() - .mintIndexWalletIdEqualTo(index, walletId) - .findFirst(); - - if (possibleCoin != null) { - updatedCoins.add(possibleCoin.copyWith(isUsed: true)); - } - } - - // if a jmint was made add it to the unspent coin index - final jmint = LelantusCoin( - walletId: walletId, - mintIndex: nextFreeMintIndex, - value: (txData.jMintValue ?? 0).toString(), - txid: txid, - anonymitySetId: latestSetId, - isUsed: false, - isJMint: true, - otherData: null, - ); - - try { - await mainDB.isar.writeTxn(() async { - for (final c in updatedCoins) { - await mainDB.isar.lelantusCoins.deleteByMintIndexWalletId( - c.mintIndex, - c.walletId, - ); - } - await mainDB.isar.lelantusCoins.putAll(updatedCoins); - - await mainDB.isar.lelantusCoins.put(jmint); - }); - } catch (e, s) { - Logging.instance.e("", error: e, stackTrace: s); - rethrow; - } - - final amount = txData.amount!; - - // add the send transaction - final transaction = Transaction( - walletId: walletId, - txid: txid, - timestamp: (DateTime.now().millisecondsSinceEpoch ~/ 1000), - type: TransactionType.outgoing, - subType: TransactionSubType.join, - amount: amount.raw.toInt(), - amountString: amount.toJsonString(), - fee: txData.fee!.raw.toInt(), - height: txData.height, - isCancelled: false, - isLelantus: true, - slateId: null, - nonce: null, - otherData: null, - // otherData: transactionInfo["otherData"] as String?, - inputs: [], - outputs: [], - numberOfMessages: null, - ); - - final transactionAddress = - await mainDB - .getAddresses(walletId) - .filter() - .valueEqualTo(txData.recipients!.first.address) - .findFirst() ?? - Address( - walletId: walletId, - value: txData.recipients!.first.address, - derivationIndex: -1, - derivationPath: null, - type: AddressType.nonWallet, - subType: AddressSubType.nonWallet, - publicKey: [], - ); - - final List> txnsData = []; - - txnsData.add(Tuple2(transaction, transactionAddress)); - - await mainDB.addNewTransactionData(txnsData, walletId); - } else { - // This is a mint - Logging.instance.t("this is a mint"); - - final List updatedCoins = []; - - for (final mintMap in txData.mintsMapLelantus!) { - final index = mintMap['index'] as int; - final mint = LelantusCoin( - walletId: walletId, - mintIndex: index, - value: (mintMap['value'] as int).toString(), - txid: txid, - anonymitySetId: latestSetId, - isUsed: false, - isJMint: false, - otherData: null, - ); - - updatedCoins.add(mint); - } - // Logging.instance.log(coins); - try { - await mainDB.isar.writeTxn(() async { - await mainDB.isar.lelantusCoins.putAll(updatedCoins); - }); - } catch (e, s) { - Logging.instance.e("", error: e, stackTrace: s); - rethrow; - } - } - - return txData.copyWith(txid: txid); - } - - Future>> fastFetch(List allTxHashes) async { - final List> allTransactions = []; - - const futureLimit = 30; - final List>> transactionFutures = []; - int currentFutureCount = 0; - for (final txHash in allTxHashes) { - final Future> transactionFuture = - electrumXCachedClient.getTransaction( - txHash: txHash, - verbose: true, - cryptoCurrency: cryptoCurrency, - ); - transactionFutures.add(transactionFuture); - currentFutureCount++; - if (currentFutureCount > futureLimit) { - currentFutureCount = 0; - await Future.wait(transactionFutures); - for (final fTx in transactionFutures) { - final tx = await fTx; - // delete unused large parts - tx.remove("hex"); - tx.remove("lelantusData"); - - allTransactions.add(tx); - } - } - } - if (currentFutureCount != 0) { - currentFutureCount = 0; - await Future.wait(transactionFutures); - for (final fTx in transactionFutures) { - final tx = await fTx; - // delete unused large parts - tx.remove("hex"); - tx.remove("lelantusData"); - - allTransactions.add(tx); - } - } - return allTransactions; - } - - Future> getJMintTransactions( - List transactions, - ) async { - try { - final Map txs = {}; - final List> allTransactions = await fastFetch( - transactions, - ); - - for (int i = 0; i < allTransactions.length; i++) { - try { - final tx = allTransactions[i]; - - var sendIndex = 1; - if (tx["vout"][0]["value"] != null && - Decimal.parse(tx["vout"][0]["value"].toString()) > Decimal.zero) { - sendIndex = 0; - } - tx["amount"] = tx["vout"][sendIndex]["value"]; - tx["address"] = tx["vout"][sendIndex]["scriptPubKey"]["addresses"][0]; - tx["fees"] = tx["vin"][0]["nFees"]; - - final Amount amount = Amount.fromDecimal( - Decimal.parse(tx["amount"].toString()), - fractionDigits: cryptoCurrency.fractionDigits, - ); - - final txn = Transaction( - walletId: walletId, - txid: tx["txid"] as String, - timestamp: - tx["time"] as int? ?? - (DateTime.now().millisecondsSinceEpoch ~/ 1000), - type: TransactionType.outgoing, - subType: TransactionSubType.join, - amount: amount.raw.toInt(), - amountString: amount.toJsonString(), - fee: - Amount.fromDecimal( - Decimal.parse(tx["fees"].toString()), - fractionDigits: cryptoCurrency.fractionDigits, - ).raw.toInt(), - height: tx["height"] as int?, - isCancelled: false, - isLelantus: true, - slateId: null, - otherData: null, - nonce: null, - inputs: [], - outputs: [], - numberOfMessages: null, - ); - - final address = - await mainDB - .getAddresses(walletId) - .filter() - .valueEqualTo(tx["address"] as String) - .findFirst() ?? - Address( - walletId: walletId, - value: tx["address"] as String, - derivationIndex: -2, - derivationPath: null, - type: AddressType.nonWallet, - subType: AddressSubType.unknown, - publicKey: [], - ); - - txs[address] = txn; - } catch (e, s) { - Logging.instance.i( - "Exception caught in getJMintTransactions(): ", - error: e, - stackTrace: s, - ); - rethrow; - } - } - return txs; - } catch (e, s) { - Logging.instance.i( - "Exception rethrown in getJMintTransactions(): ", - error: e, - stackTrace: s, - ); - rethrow; - } - } - - Future>> fetchAnonymitySets() async { - try { - final latestSetId = await electrumXClient.getLelantusLatestCoinId(); - - final List> sets = []; - final List>> anonFutures = []; - for (int i = 1; i <= latestSetId; i++) { - final set = electrumXCachedClient.getAnonymitySet( - groupId: "$i", - cryptoCurrency: info.coin, - ); - anonFutures.add(set); - } - await Future.wait(anonFutures); - for (int i = 1; i <= latestSetId; i++) { - final Map set = (await anonFutures[i - 1]); - set["setId"] = i; - sets.add(set); - } - return sets; - } catch (e, s) { - Logging.instance.e( - "Exception rethrown from refreshAnonymitySets: ", - error: e, - stackTrace: s, - ); - rethrow; - } - } - - Future> getSetDataMap(int latestSetId) async { - final Map setDataMap = {}; - final anonymitySets = await fetchAnonymitySets(); - for (int setId = 1; setId <= latestSetId; setId++) { - final setData = anonymitySets.firstWhere( - (element) => element["setId"] == setId, - orElse: () => {}, - ); - - if (setData.isNotEmpty) { - setDataMap[setId] = setData; - } - } - return setDataMap; - } - - // TODO: verify this function does what we think it does - Future refreshLelantusData() async { - final lelantusCoins = - await mainDB.isar.lelantusCoins - .where() - .walletIdEqualTo(walletId) - .filter() - .isUsedEqualTo(false) - .not() - .valueEqualTo(0.toString()) - .findAll(); - - final List updatedCoins = []; - - final usedSerialNumbersSet = - (await electrumXCachedClient.getUsedCoinSerials( - cryptoCurrency: info.coin, - )).toSet(); - - final root = await getRootHDNode(); - - for (final coin in lelantusCoins) { - final _derivePath = cryptoCurrency.constructDerivePath( - derivePathType: DerivePathType.bip44, - chain: LelantusFfiWrapper.MINT_INDEX, - index: coin.mintIndex, - ); - - final mintKeyPair = root.derivePath(_derivePath); - - final String serialNumber = lelantus.GetSerialNumber( - int.parse(coin.value), - mintKeyPair.privateKey.data.toHex, - coin.mintIndex, - isTestnet: cryptoCurrency.network.isTestNet, - ); - final bool isUsed = usedSerialNumbersSet.contains(serialNumber); - - if (isUsed) { - updatedCoins.add(coin.copyWith(isUsed: isUsed)); - } - - final tx = await mainDB.getTransaction(walletId, coin.txid); - if (tx == null) { - Logging.instance.e( - "Transaction with txid=REDACTED not found in local db!", - ); - Logging.instance.d( - "Transaction with txid=${coin.txid} not found in local db!", - ); - } - } - - if (updatedCoins.isNotEmpty) { - try { - await mainDB.isar.writeTxn(() async { - for (final c in updatedCoins) { - await mainDB.isar.lelantusCoins.deleteByMintIndexWalletId( - c.mintIndex, - c.walletId, - ); - } - await mainDB.isar.lelantusCoins.putAll(updatedCoins); - }); - } catch (e, s) { - Logging.instance.f(" ", error: e, stackTrace: s); - rethrow; - } - } - } - - /// Should only be called within the standard wallet [recover] function due to - /// mutex locking. Otherwise behaviour MAY be undefined. - Future recoverLelantusWallet({ - required int latestSetId, - required Map setDataMap, - required Set usedSerialNumbers, - }) async { - final root = await getRootHDNode(); - - final derivePath = cryptoCurrency.constructDerivePath( - derivePathType: DerivePathType.bip44, - chain: 0, - index: 0, - ); - - // get "m/$purpose'/$coinType'/$account'/" from "m/$purpose'/$coinType'/$account'/0/0" - final partialDerivationPath = derivePath.substring( - 0, - derivePath.length - 3, - ); - - final result = await LelantusFfiWrapper.restore( - hexRootPrivateKey: root.privateKey.data.toHex, - chaincode: root.chaincode, - cryptoCurrency: cryptoCurrency, - latestSetId: latestSetId, - setDataMap: setDataMap, - usedSerialNumbers: usedSerialNumbers, - walletId: walletId, - partialDerivationPath: partialDerivationPath, - ); - - final currentHeight = await chainHeight; - - final txns = - await mainDB - .getTransactions(walletId) - .filter() - .isLelantusIsNull() - .or() - .isLelantusEqualTo(false) - .findAll(); - - // TODO: [prio=high] shouldn't these be v2? If it doesn't matter than we can get rid of this logic - // Edit the receive transactions with the mint fees. - final List editedTransactions = []; - - for (final coin in result.lelantusCoins) { - final String txid = coin.txid; - Transaction? tx; - try { - tx = txns.firstWhere((e) => e.txid == txid); - } catch (_) { - tx = null; - } - - if (tx == null || tx.subType == TransactionSubType.join) { - // This is a jmint. - continue; - } - - final List inputTxns = []; - for (final input in tx.inputs) { - Transaction? inputTx; - try { - inputTx = txns.firstWhere((e) => e.txid == input.txid); - } catch (_) { - inputTx = null; - } - if (inputTx != null) { - inputTxns.add(inputTx); - } - } - if (inputTxns.isEmpty) { - //some error. - Logging.instance.f( - "cryptic \"//some error\" occurred in staticProcessRestore on lelantus coin: $coin", - ); - continue; - } - - final int mintFee = tx.fee; - final int sharedFee = mintFee ~/ inputTxns.length; - for (final inputTx in inputTxns) { - final edited = Transaction( - walletId: inputTx.walletId, - txid: inputTx.txid, - timestamp: inputTx.timestamp, - type: inputTx.type, - subType: TransactionSubType.mint, - amount: inputTx.amount, - amountString: - Amount( - rawValue: BigInt.from(inputTx.amount), - fractionDigits: cryptoCurrency.fractionDigits, - ).toJsonString(), - fee: sharedFee, - height: inputTx.height, - isCancelled: false, - isLelantus: true, - slateId: null, - otherData: txid, - nonce: null, - inputs: inputTx.inputs, - outputs: inputTx.outputs, - numberOfMessages: null, - )..address.value = inputTx.address.value; - editedTransactions.add(edited); - } - } - // Logging.instance.log(editedTransactions, addToDebugMessagesDB: false); - - final Map transactionMap = {}; - for (final e in txns) { - transactionMap[e.txid] = e; - } - // Logging.instance.log(transactionMap, addToDebugMessagesDB: false); - - // update with edited transactions - for (final tx in editedTransactions) { - transactionMap[tx.txid] = tx; - } - - transactionMap.removeWhere( - (key, value) => - result.lelantusCoins.any((element) => element.txid == key) || - ((value.height == -1 || value.height == null) && - !value.isConfirmed(currentHeight, cryptoCurrency.minConfirms)), - ); - - try { - await mainDB.isar.writeTxn(() async { - await mainDB.isar.lelantusCoins.putAll(result.lelantusCoins); - }); - } catch (e, s) { - Logging.instance.e("", error: e, stackTrace: s); - // don't just rethrow since isar likes to strip stack traces for some reason - throw Exception("e=$e & s=$s"); - } - - final Map> data = {}; - - for (final entry in transactionMap.entries) { - data[entry.key] = Tuple2(entry.value.address.value, entry.value); - } - - // Create the joinsplit transactions. - final spendTxs = await getJMintTransactions(result.spendTxIds); - Logging.instance.d("lelantus spendTxs: $spendTxs"); - - for (final element in spendTxs.entries) { - final address = - element.value.address.value ?? - data[element.value.txid]?.item1 ?? - element.key; - // Address( - // walletId: walletId, - // value: transactionInfo["address"] as String, - // derivationIndex: -1, - // type: AddressType.nonWallet, - // subType: AddressSubType.nonWallet, - // publicKey: [], - // ); - - data[element.value.txid] = Tuple2(address, element.value); - } - - final List> txnsData = []; - - for (final value in data.values) { - final transactionAddress = value.item1!; - final outs = value.item2.outputs - .where((_) => true) - .toList(growable: false); - final ins = value.item2.inputs.where((_) => true).toList(growable: false); - - txnsData.add( - Tuple2( - value.item2.copyWith(inputs: ins, outputs: outs).item1, - transactionAddress, - ), - ); - } - - await mainDB.addNewTransactionData(txnsData, walletId); - } - - /// Builds and signs a transaction - Future buildMintTransaction({required TxData txData}) async { - final signingData = await fetchBuildTxData(txData.utxos!.toList()); - - final convertedNetwork = bitcoindart.NetworkType( - messagePrefix: cryptoCurrency.networkParams.messagePrefix, - bech32: cryptoCurrency.networkParams.bech32Hrp, - bip32: bitcoindart.Bip32Type( - public: cryptoCurrency.networkParams.pubHDPrefix, - private: cryptoCurrency.networkParams.privHDPrefix, - ), - pubKeyHash: cryptoCurrency.networkParams.p2pkhPrefix, - scriptHash: cryptoCurrency.networkParams.p2shPrefix, - wif: cryptoCurrency.networkParams.wifPrefix, - ); - - final txb = bitcoindart.TransactionBuilder(network: convertedNetwork); - txb.setVersion(2); - - final int height = await chainHeight; - - txb.setLockTime(height); - int amount = 0; - // Add transaction inputs - for (var i = 0; i < signingData.length; i++) { - final pubKey = signingData[i].keyPair!.publicKey.data; - final bitcoindart.PaymentData? data; - - switch (signingData[i].derivePathType) { - case DerivePathType.bip44: - data = - bitcoindart - .P2PKH( - data: bitcoindart.PaymentData(pubkey: pubKey), - network: convertedNetwork, - ) - .data; - break; - - case DerivePathType.bip49: - final p2wpkh = - bitcoindart - .P2WPKH( - data: bitcoindart.PaymentData(pubkey: pubKey), - network: convertedNetwork, - ) - .data; - data = - bitcoindart - .P2SH( - data: bitcoindart.PaymentData(redeem: p2wpkh), - network: convertedNetwork, - ) - .data; - break; - - case DerivePathType.bip84: - data = - bitcoindart - .P2WPKH( - data: bitcoindart.PaymentData(pubkey: pubKey), - network: convertedNetwork, - ) - .data; - break; - - case DerivePathType.bip86: - data = null; - break; - - default: - throw Exception("DerivePathType unsupported"); - } - - txb.addInput( - signingData[i].utxo.txid, - signingData[i].utxo.vout, - null, - data!.output!, - ); - amount += signingData[i].utxo.value; - } - - for (final mintsElement in txData.mintsMapLelantus!) { - Logging.instance.d("using $mintsElement"); - final Uint8List mintu8 = Format.stringToUint8List( - mintsElement['script'] as String, - ); - txb.addOutput(mintu8, mintsElement['value'] as int); - } - - for (var i = 0; i < signingData.length; i++) { - txb.sign( - vin: i, - keyPair: bitcoindart.ECPair.fromPrivateKey( - signingData[i].keyPair!.privateKey.data, - network: convertedNetwork, - compressed: signingData[i].keyPair!.privateKey.compressed, - ), - witnessValue: signingData[i].utxo.value, - ); - } - final incomplete = txb.buildIncomplete(); - final txId = incomplete.getId(); - final txHex = incomplete.toHex(); - final int fee = amount - incomplete.outs[0].value!; - - final builtHex = txb.build(); - - return txData.copyWith( - recipients: [ - ( - amount: Amount( - rawValue: BigInt.from(incomplete.outs[0].value!), - fractionDigits: cryptoCurrency.fractionDigits, - ), - address: "no address for lelantus mints", - isChange: false, - ), - ], - vSize: builtHex.virtualSize(), - txid: txId, - raw: txHex, - height: height, - txType: TransactionType.outgoing, - txSubType: TransactionSubType.mint, - fee: Amount( - rawValue: BigInt.from(fee), - fractionDigits: cryptoCurrency.fractionDigits, - ), - ); - - // return { - // "transaction": builtHex, - // "txid": txId, - // "txHex": txHex, - // "value": amount - fee, - // "fees": Amount( - // rawValue: BigInt.from(fee), - // fractionDigits: coin.fractionDigits, - // ).decimal.toDouble(), - // "height": height, - // "txType": "Sent", - // "confirmed_status": false, - // "amount": Amount( - // rawValue: BigInt.from(amount), - // fractionDigits: coin.fractionDigits, - // ).decimal.toDouble(), - // "timestamp": DateTime.now().millisecondsSinceEpoch ~/ 1000, - // "subType": "mint", - // "mintsMap": mintsMap, - // }; - } - - /// Returns the mint transaction hex to mint all of the available funds. - Future _mintSelection() async { - final currentChainHeight = await chainHeight; - final List availableOutputs = - await mainDB - .getUTXOs(walletId) - .filter() - .isBlockedEqualTo(false) - .findAll(); - final List spendableOutputs = []; - - // Build list of spendable outputs and totaling their satoshi amount - for (var i = 0; i < availableOutputs.length; i++) { - if (availableOutputs[i].isConfirmed( - currentChainHeight, - cryptoCurrency.minConfirms, - cryptoCurrency.minCoinbaseConfirms, - ) == - true && - !(availableOutputs[i].isCoinbase && - availableOutputs[i].getConfirmations(currentChainHeight) <= - 101)) { - spendableOutputs.add(availableOutputs[i]); - } - } - - final lelantusCoins = - await mainDB.isar.lelantusCoins - .where() - .walletIdEqualTo(walletId) - .filter() - .not() - .valueEqualTo(0.toString()) - .findAll(); - - final data = - await mainDB - .getTransactions(walletId) - .filter() - .isLelantusIsNull() - .or() - .isLelantusEqualTo(false) - .findAll(); - - for (final value in data) { - if (value.inputs.isNotEmpty) { - for (final element in value.inputs) { - if (lelantusCoins.any((e) => e.txid == value.txid) && - spendableOutputs.firstWhere( - (output) => output?.txid == element.txid, - orElse: () => null, - ) != - null) { - spendableOutputs.removeWhere( - (output) => output!.txid == element.txid, - ); - } - } - } - } - - // If there is no Utxos to mint then stop the function. - if (spendableOutputs.isEmpty) { - throw Exception("_mintSelection(): No spendable outputs found"); - } - - int satoshisBeingUsed = 0; - final Set utxoObjectsToUse = {}; - - for (var i = 0; i < spendableOutputs.length; i++) { - final spendable = spendableOutputs[i]; - if (spendable != null) { - utxoObjectsToUse.add(spendable); - satoshisBeingUsed += spendable.value; - } - } - - final mintsWithoutFee = await _createMintsFromAmount(satoshisBeingUsed); - - TxData txData = await buildMintTransaction( - txData: TxData( - utxos: utxoObjectsToUse, - mintsMapLelantus: mintsWithoutFee, - ), - ); - - final Decimal dvSize = Decimal.fromInt(txData.vSize!); - - final feesObject = await fees; - - final Decimal fastFee = - Amount( - rawValue: feesObject.fast, - fractionDigits: cryptoCurrency.fractionDigits, - ).decimal; - int firoFee = - (dvSize * fastFee * Decimal.fromInt(100000)).toDouble().ceil(); - // int firoFee = (vSize * feesObject.fast * (1 / 1000.0) * 100000000).ceil(); - - if (firoFee < txData.vSize!) { - firoFee = txData.vSize! + 1; - } - firoFee = firoFee + 10; - final int satoshiAmountToSend = satoshisBeingUsed - firoFee; - - final mintsWithFee = await _createMintsFromAmount(satoshiAmountToSend); - - txData = await buildMintTransaction( - txData: txData.copyWith(mintsMapLelantus: mintsWithFee), - ); - - return txData; - } - - Future>> _createMintsFromAmount(int total) async { - if (total > LelantusFfiWrapper.MINT_LIMIT) { - throw Exception( - "Lelantus mints of more than 5001 are currently disabled", - ); - } - - int tmpTotal = total; - int counter = 0; - final lastUsedIndex = await mainDB.getHighestUsedMintIndex( - walletId: walletId, - ); - final nextFreeMintIndex = (lastUsedIndex ?? 0) + 1; - - final isTestnet = cryptoCurrency.network.isTestNet; - - final root = await getRootHDNode(); - - final mints = >[]; - while (tmpTotal > 0) { - final index = nextFreeMintIndex + counter; - - final mintKeyPair = root.derivePath( - cryptoCurrency.constructDerivePath( - derivePathType: DerivePathType.bip44, - chain: LelantusFfiWrapper.MINT_INDEX, - index: index, - ), - ); - - final privateKeyHex = mintKeyPair.privateKey.data.toHex; - final seedId = Format.uint8listToString(mintKeyPair.identifier); - - final String mintTag = lelantus.CreateTag( - privateKeyHex, - index, - seedId, - isTestnet: isTestnet, - ); - final List> anonymitySets; - try { - anonymitySets = await fetchAnonymitySets(); - } catch (e, s) { - Logging.instance.f( - "Firo needs better internet to create mints: ", - error: e, - stackTrace: s, - ); - rethrow; - } - - bool isUsedMintTag = false; - - // stupid dynamic maps - for (final set in anonymitySets) { - final setCoins = set["coins"] as List; - for (final coin in setCoins) { - if (coin[1] == mintTag) { - isUsedMintTag = true; - break; - } - } - if (isUsedMintTag) { - break; - } - } - - if (isUsedMintTag) { - Logging.instance.d("Found used index when minting"); - } - - if (!isUsedMintTag) { - final mintValue = min( - tmpTotal, - (isTestnet - ? LelantusFfiWrapper.MINT_LIMIT_TESTNET - : LelantusFfiWrapper.MINT_LIMIT), - ); - final mint = await LelantusFfiWrapper.getMintScript( - amount: Amount( - rawValue: BigInt.from(mintValue), - fractionDigits: cryptoCurrency.fractionDigits, - ), - privateKeyHex: privateKeyHex, - index: index, - seedId: seedId, - isTestNet: isTestnet, - ); - - mints.add({"value": mintValue, "script": mint, "index": index}); - tmpTotal = - tmpTotal - - (isTestnet - ? LelantusFfiWrapper.MINT_LIMIT_TESTNET - : LelantusFfiWrapper.MINT_LIMIT); - } - - counter++; - } - return mints; - } - - Future anonymizeAllLelantus() async { - try { - final mintResult = await _mintSelection(); - - await confirmSendLelantus(txData: mintResult); - - unawaited(refresh()); - } catch (e, s) { - Logging.instance.w( - "Exception caught in anonymizeAllLelantus(): ", - error: e, - stackTrace: s, - ); - rethrow; - } - } - - @override - Future updateBalance() async { - // call to super to update transparent balance - final normalBalanceFuture = super.updateBalance(); - - final lelantusCoins = - await mainDB.isar.lelantusCoins - .where() - .walletIdEqualTo(walletId) - .filter() - .isUsedEqualTo(false) - .not() - .valueEqualTo(0.toString()) - .findAll(); - - final currentChainHeight = await chainHeight; - int intLelantusBalance = 0; - int unconfirmedLelantusBalance = 0; - - for (final lelantusCoin in lelantusCoins) { - final Transaction? txn = - mainDB.isar.transactions - .where() - .txidWalletIdEqualTo(lelantusCoin.txid, walletId) - .findFirstSync(); - - if (txn == null) { - Logging.instance.e("Transaction not found in DB for lelantus coin"); - Logging.instance.d( - "Transaction not found in DB for lelantus coin: $lelantusCoin", - ); - } else { - if (txn.isLelantus != true) { - Logging.instance.f( - "Bad database state found in ${info.name} $walletId for _refreshBalance lelantus", - ); - } - - if (txn.isConfirmed(currentChainHeight, cryptoCurrency.minConfirms)) { - // mint tx, add value to balance - intLelantusBalance += int.parse(lelantusCoin.value); - } else { - unconfirmedLelantusBalance += int.parse(lelantusCoin.value); - } - } - } - - final balancePrivate = Balance( - total: Amount( - rawValue: BigInt.from(intLelantusBalance + unconfirmedLelantusBalance), - fractionDigits: cryptoCurrency.fractionDigits, - ), - spendable: Amount( - rawValue: BigInt.from(intLelantusBalance), - fractionDigits: cryptoCurrency.fractionDigits, - ), - blockedTotal: Amount( - rawValue: BigInt.zero, - fractionDigits: cryptoCurrency.fractionDigits, - ), - pendingSpendable: Amount( - rawValue: BigInt.from(unconfirmedLelantusBalance), - fractionDigits: cryptoCurrency.fractionDigits, - ), - ); - await info.updateBalanceSecondary( - newBalance: balancePrivate, - isar: mainDB.isar, - ); - - // wait for updated uxtos to get updated public balance - await normalBalanceFuture; - } -} diff --git a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart index c22429d10..21bd7a74a 100644 --- a/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart +++ b/lib/wallets/wallet/wallet_mixin_interfaces/spark_interface.dart @@ -2243,8 +2243,7 @@ mixin SparkInterface @override Future updateBalance() async { - // call to super to update transparent balance (and lelantus balance if - // what ever class this mixin is used on uses LelantusInterface as well) + // call to super to update transparent balance final normalBalanceFuture = super.updateBalance(); // todo: spark balance aka update info.tertiaryBalance here? diff --git a/lib/widgets/desktop/desktop_fee_dialog.dart b/lib/widgets/desktop/desktop_fee_dialog.dart index aa3175cac..3252be98e 100644 --- a/lib/widgets/desktop/desktop_fee_dialog.dart +++ b/lib/widgets/desktop/desktop_fee_dialog.dart @@ -73,10 +73,6 @@ class _DesktopFeeDialogState extends ConsumerState { fee = await (wallet as FiroWallet).estimateFeeForSpark( amount, ); - case FiroType.lelantus: - fee = await (wallet as FiroWallet).estimateFeeForLelantus( - amount, - ); case FiroType.public: fee = await (wallet as FiroWallet).estimateFeeFor( amount, @@ -127,10 +123,6 @@ class _DesktopFeeDialogState extends ConsumerState { fee = await (wallet as FiroWallet).estimateFeeForSpark( amount, ); - case FiroType.lelantus: - fee = await (wallet as FiroWallet).estimateFeeForLelantus( - amount, - ); case FiroType.public: fee = await (wallet as FiroWallet).estimateFeeFor( amount, @@ -181,10 +173,6 @@ class _DesktopFeeDialogState extends ConsumerState { fee = await (wallet as FiroWallet).estimateFeeForSpark( amount, ); - case FiroType.lelantus: - fee = await (wallet as FiroWallet).estimateFeeForLelantus( - amount, - ); case FiroType.public: fee = await (wallet as FiroWallet).estimateFeeFor( amount, @@ -361,28 +349,6 @@ class _DesktopFeeItemState extends ConsumerState { ), child: Builder( builder: (_) { - if (!widget.isButton) { - final coin = ref.watch( - pWallets.select( - (value) => value.getWallet(widget.walletId).info.coin, - ), - ); - if ((coin is Firo) && - ref.watch(publicPrivateBalanceStateProvider.state).state == - FiroType.lelantus) { - return Text( - "~${ref.watch(pAmountFormatter(coin)).format(Amount(rawValue: BigInt.parse("3794"), fractionDigits: coin.fractionDigits), indicatePrecisionLoss: false)}", - style: STextStyles.desktopTextExtraExtraSmall(context).copyWith( - color: - Theme.of( - context, - ).extension()!.textFieldActiveText, - ), - textAlign: TextAlign.left, - ); - } - } - if (widget.feeRateType == FeeRateType.custom) { return Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 8b28c002f..d2bf8597f 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -17,7 +17,6 @@ import flutter_libepiccash import flutter_local_notifications import flutter_secure_storage_macos import isar_flutter_libs -import lelantus import local_auth_darwin import package_info_plus import path_provider_foundation @@ -41,7 +40,6 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterSecureStoragePlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStoragePlugin")) IsarFlutterLibsPlugin.register(with: registry.registrar(forPlugin: "IsarFlutterLibsPlugin")) - LelantusPlugin.register(with: registry.registrar(forPlugin: "LelantusPlugin")) FLALocalAuthPlugin.register(with: registry.registrar(forPlugin: "FLALocalAuthPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) diff --git a/macos/Podfile.lock b/macos/Podfile.lock index a51d63f71..3dba40491 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -30,8 +30,6 @@ PODS: - FlutterMacOS - isar_flutter_libs (1.0.0): - FlutterMacOS - - lelantus (0.0.1): - - FlutterMacOS - local_auth_darwin (0.0.1): - Flutter - FlutterMacOS @@ -86,7 +84,6 @@ DEPENDENCIES: - FlutterMacOS (from `Flutter/ephemeral`) - frostdart (from `Flutter/ephemeral/.symlinks/plugins/frostdart/macos`) - isar_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/isar_flutter_libs/macos`) - - lelantus (from `Flutter/ephemeral/.symlinks/plugins/lelantus/macos`) - local_auth_darwin (from `Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin`) - package_info_plus (from `Flutter/ephemeral/.symlinks/plugins/package_info_plus/macos`) - path_provider_foundation (from `Flutter/ephemeral/.symlinks/plugins/path_provider_foundation/darwin`) @@ -135,8 +132,6 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/frostdart/macos isar_flutter_libs: :path: Flutter/ephemeral/.symlinks/plugins/isar_flutter_libs/macos - lelantus: - :path: Flutter/ephemeral/.symlinks/plugins/lelantus/macos local_auth_darwin: :path: Flutter/ephemeral/.symlinks/plugins/local_auth_darwin/darwin package_info_plus: @@ -176,7 +171,6 @@ SPEC CHECKSUMS: FlutterMacOS: 8f6f14fa908a6fb3fba0cd85dbd81ec4b251fb24 frostdart: e6bf3119527ccfbcec1b8767da6ede5bb4c4f716 isar_flutter_libs: 43385c99864c168fadba7c9adeddc5d38838ca6a - lelantus: 308e42c5a648598936a07a234471dd8cf8e687a0 local_auth_darwin: 66e40372f1c29f383a314c738c7446e2f7fdadc3 package_info_plus: 12f1c5c2cfe8727ca46cbd0b26677728972d9a5b path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46 diff --git a/pubspec.lock b/pubspec.lock index 6cb6be1ac..7c3844799 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -1361,13 +1361,6 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.1" - lelantus: - dependency: "direct main" - description: - path: "crypto_plugins/flutter_liblelantus" - relative: true - source: path - version: "0.0.3" lints: dependency: transitive description: diff --git a/scripts/android/build_all.sh b/scripts/android/build_all.sh index 5438234ea..d791b933b 100755 --- a/scripts/android/build_all.sh +++ b/scripts/android/build_all.sh @@ -7,8 +7,6 @@ mkdir -p build PLUGINS_DIR=../../crypto_plugins -(cd "${PLUGINS_DIR}"/flutter_liblelantus/scripts/android && ./build_all.sh ) - # libepiccash requires old rust source ../rust_version.sh set_rust_version_for_libepiccash diff --git a/scripts/android/build_all_campfire.sh b/scripts/android/build_all_campfire.sh index 5438234ea..d791b933b 100755 --- a/scripts/android/build_all_campfire.sh +++ b/scripts/android/build_all_campfire.sh @@ -7,8 +7,6 @@ mkdir -p build PLUGINS_DIR=../../crypto_plugins -(cd "${PLUGINS_DIR}"/flutter_liblelantus/scripts/android && ./build_all.sh ) - # libepiccash requires old rust source ../rust_version.sh set_rust_version_for_libepiccash diff --git a/scripts/android/build_all_duo.sh b/scripts/android/build_all_duo.sh index 40be4bee4..39579d238 100755 --- a/scripts/android/build_all_duo.sh +++ b/scripts/android/build_all_duo.sh @@ -9,8 +9,6 @@ mkdir -p build PLUGINS_DIR=../../crypto_plugins -(cd "${PLUGINS_DIR}"/flutter_liblelantus/scripts/android && ./build_all.sh ) - # libepiccash requires old rust source ../rust_version.sh set_rust_version_for_libepiccash diff --git a/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj b/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj index c89885057..5c1e9e238 100644 --- a/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj +++ b/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj @@ -11,8 +11,6 @@ 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 7E1603B5288D73EA002F7A6F /* libepic_cash_wallet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E8A4F06288D5A9300F18717 /* libepic_cash_wallet.a */; }; - 7E569F992798D47200056D51 /* mobileliblelantus.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E569F982798D47200056D51 /* mobileliblelantus.framework */; }; - 7E569F9A2798D47F00056D51 /* mobileliblelantus.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 7E569F982798D47200056D51 /* mobileliblelantus.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 7E729AE82893C1B1009BBD65 /* flutter_libepiccash.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E1603B3288D734C002F7A6F /* flutter_libepiccash.framework */; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; @@ -20,20 +18,6 @@ B49D91439948369648AB0603 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 51604430FD0FD1FA5C4767A0 /* Pods_Runner.framework */; }; /* End PBXBuildFile section */ -/* Begin PBXCopyFilesBuildPhase section */ - 9705A1C41CF9048500538489 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - 7E569F9A2798D47F00056D51 /* mobileliblelantus.framework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - /* Begin PBXFileReference section */ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; @@ -45,7 +29,6 @@ 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 7E1603B3288D734C002F7A6F /* flutter_libepiccash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = flutter_libepiccash.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 7E569F982798D47200056D51 /* mobileliblelantus.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mobileliblelantus.framework; path = ../crypto_plugins/flutter_liblelantus/scripts/ios/mobileliblelantus/mobileliblelantus.framework; sourceTree = ""; }; 7E8A4F02288D57DE00F18717 /* flutter_libepiccash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = flutter_libepiccash.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7E8A4F06288D5A9300F18717 /* libepic_cash_wallet.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libepic_cash_wallet.a; path = ../crypto_plugins/flutter_libepiccash/ios/libs/libepic_cash_wallet.a; sourceTree = ""; }; 7E8A4F09288D5E8F00F18717 /* flutter_libepiccash.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = flutter_libepiccash.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -74,7 +57,6 @@ files = ( 7E1603B5288D73EA002F7A6F /* libepic_cash_wallet.a in Frameworks */, 7E729AE82893C1B1009BBD65 /* flutter_libepiccash.framework in Frameworks */, - 7E569F992798D47200056D51 /* mobileliblelantus.framework in Frameworks */, B49D91439948369648AB0603 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -104,7 +86,6 @@ 7E8A4F09288D5E8F00F18717 /* flutter_libepiccash.framework */, 7E8A4F06288D5A9300F18717 /* libepic_cash_wallet.a */, 7E8A4F02288D57DE00F18717 /* flutter_libepiccash.framework */, - 7E569F982798D47200056D51 /* mobileliblelantus.framework */, 51604430FD0FD1FA5C4767A0 /* Pods_Runner.framework */, ); name = Frameworks; @@ -178,7 +159,6 @@ 97C146EA1CF9000F007C117D /* Sources */, 97C146EB1CF9000F007C117D /* Frameworks */, 97C146EC1CF9000F007C117D /* Resources */, - 9705A1C41CF9048500538489 /* Embed Frameworks */, 3B06AD1E1E4923F5004D2608 /* Thin Binary */, FD1CA371131604E6658D4146 /* [CP] Embed Pods Frameworks */, 4823D12ED8C268BC85F26ABD /* [CP] Copy Pods Resources */, @@ -343,7 +323,6 @@ "${BUILT_PRODUCTS_DIR}/frostdart/frostdart.framework", "${BUILT_PRODUCTS_DIR}/integration_test/integration_test.framework", "${BUILT_PRODUCTS_DIR}/isar_flutter_libs/isar_flutter_libs.framework", - "${BUILT_PRODUCTS_DIR}/lelantus/lelantus.framework", "${BUILT_PRODUCTS_DIR}/local_auth_darwin/local_auth_darwin.framework", "${BUILT_PRODUCTS_DIR}/package_info_plus/package_info_plus.framework", "${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework", @@ -380,7 +359,6 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/frostdart.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/integration_test.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/isar_flutter_libs.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/lelantus.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/local_auth_darwin.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info_plus.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework", @@ -497,7 +475,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", - "$(PROJECT_DIR)/../crypto_plugins/flutter_liblelantus/scripts/ios/mobileliblelantus", "$(PROJECT_DIR)", ); HEADER_SEARCH_PATHS = ( @@ -516,7 +493,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_native_splash/flutter_native_splash.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_secure_storage/flutter_secure_storage.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/integration_test/integration_test.framework/Headers\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/lelantus/lelantus.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/local_auth/local_auth.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/package_info_plus/package_info_plus.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/path_provider_ios/path_provider_ios.framework/Headers\"", @@ -679,7 +655,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", - "$(PROJECT_DIR)/../crypto_plugins/flutter_liblelantus/scripts/ios/mobileliblelantus", "$(PROJECT_DIR)", ); HEADER_SEARCH_PATHS = ( @@ -698,7 +673,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_native_splash/flutter_native_splash.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_secure_storage/flutter_secure_storage.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/integration_test/integration_test.framework/Headers\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/lelantus/lelantus.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/local_auth/local_auth.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/package_info_plus/package_info_plus.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/path_provider_ios/path_provider_ios.framework/Headers\"", @@ -753,7 +727,6 @@ FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", - "$(PROJECT_DIR)/../crypto_plugins/flutter_liblelantus/scripts/ios/mobileliblelantus/**", "$(PROJECT_DIR)", ); HEADER_SEARCH_PATHS = ( @@ -772,7 +745,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_native_splash/flutter_native_splash.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_secure_storage/flutter_secure_storage.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/integration_test/integration_test.framework/Headers\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/lelantus/lelantus.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/local_auth/local_auth.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/package_info_plus/package_info_plus.framework/Headers\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/path_provider_ios/path_provider_ios.framework/Headers\"", diff --git a/scripts/app_config/templates/linux/CMakeLists.txt b/scripts/app_config/templates/linux/CMakeLists.txt index 25750ef4f..94d6e7f5e 100644 --- a/scripts/app_config/templates/linux/CMakeLists.txt +++ b/scripts/app_config/templates/linux/CMakeLists.txt @@ -137,9 +137,6 @@ install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../crypto_plugins/flutter_libepiccash/scripts/linux/build/rust/target/x86_64-unknown-linux-gnu/release/libepic_cash_wallet.so" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../crypto_plugins/flutter_liblelantus/scripts/linux/build/libmobileliblelantus.so" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/linux/build/jsoncpp/build/src/lib_json/libjsoncpp.so.1.7.4" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../scripts/linux/build/jsoncpp/build/src/lib_json/libjsoncpp.so.1" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" diff --git a/scripts/app_config/templates/macos/Runner.xcodeproj/project.pbxproj b/scripts/app_config/templates/macos/Runner.xcodeproj/project.pbxproj index 6db80d9b0..c0fe37d8a 100644 --- a/scripts/app_config/templates/macos/Runner.xcodeproj/project.pbxproj +++ b/scripts/app_config/templates/macos/Runner.xcodeproj/project.pbxproj @@ -27,8 +27,6 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - B98151812A674022009D013C /* mobileliblelantus.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B98151802A674022009D013C /* mobileliblelantus.framework */; }; - B98151822A67402A009D013C /* mobileliblelantus.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = B98151802A674022009D013C /* mobileliblelantus.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; B98151842A674143009D013C /* libsqlite3.0.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = B98151832A674143009D013C /* libsqlite3.0.tbd */; }; BFD0376C00E1FFD46376BB9D /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9206484E84CB0AD93E3E68CA /* Pods_RunnerTests.framework */; }; F1FA2C4E2BA4B49F00BDA1BB /* frostdart.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F1FA2C4D2BA4B49F00BDA1BB /* frostdart.dylib */; settings = {ATTRIBUTES = (Weak, ); }; }; @@ -62,7 +60,6 @@ dstSubfolderSpec = 10; files = ( F1FA2C512BA4B51E00BDA1BB /* frostdart.dylib in Bundle Framework */, - B98151822A67402A009D013C /* mobileliblelantus.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -94,7 +91,6 @@ 9206484E84CB0AD93E3E68CA /* Pods_RunnerTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_RunnerTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; ACB8E553D75AA4AC9A7656CE /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; - B98151802A674022009D013C /* mobileliblelantus.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = mobileliblelantus.framework; path = ../crypto_plugins/flutter_liblelantus/scripts/macos/mobileliblelantus/mobileliblelantus.framework; sourceTree = ""; }; B98151832A674143009D013C /* libsqlite3.0.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.0.tbd; path = usr/lib/libsqlite3.0.tbd; sourceTree = SDKROOT; }; BF5E76865ACB46314AC27D8F /* Pods-RunnerTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.debug.xcconfig"; path = "Target Support Files/Pods-RunnerTests/Pods-RunnerTests.debug.xcconfig"; sourceTree = ""; }; E6036BF01BF05EA773C76D22 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -116,7 +112,6 @@ buildActionMask = 2147483647; files = ( B98151842A674143009D013C /* libsqlite3.0.tbd in Frameworks */, - B98151812A674022009D013C /* mobileliblelantus.framework in Frameworks */, F1FA2C4E2BA4B49F00BDA1BB /* frostdart.dylib in Frameworks */, F653CA022D33E8B60E11A9F3 /* Pods_Runner.framework in Frameworks */, ); @@ -206,7 +201,6 @@ children = ( F1FA2C4D2BA4B49F00BDA1BB /* frostdart.dylib */, B98151832A674143009D013C /* libsqlite3.0.tbd */, - B98151802A674022009D013C /* mobileliblelantus.framework */, E6036BF01BF05EA773C76D22 /* Pods_Runner.framework */, 9206484E84CB0AD93E3E68CA /* Pods_RunnerTests.framework */, ); @@ -602,7 +596,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_local_notifications\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_secure_storage_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/isar_flutter_libs\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/lelantus\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/package_info_plus\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/path_provider_foundation\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/share_plus\"", @@ -610,7 +603,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/url_launcher_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/wakelock_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/window_size\"", - "\"${PROJECT_DIR}/../crypto_plugins/flutter_liblelantus/scripts/macos/mobileliblelantus\"", ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -760,7 +752,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_local_notifications\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_secure_storage_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/isar_flutter_libs\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/lelantus\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/package_info_plus\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/path_provider_foundation\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/share_plus\"", @@ -768,7 +759,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/url_launcher_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/wakelock_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/window_size\"", - "\"${PROJECT_DIR}/../crypto_plugins/flutter_liblelantus/scripts/macos/mobileliblelantus\"", ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( @@ -809,7 +799,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_local_notifications\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/flutter_secure_storage_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/isar_flutter_libs\"", - "\"${PODS_CONFIGURATION_BUILD_DIR}/lelantus\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/package_info_plus\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/path_provider_foundation\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/share_plus\"", @@ -817,7 +806,6 @@ "\"${PODS_CONFIGURATION_BUILD_DIR}/url_launcher_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/wakelock_macos\"", "\"${PODS_CONFIGURATION_BUILD_DIR}/window_size\"", - "\"${PROJECT_DIR}/../crypto_plugins/flutter_liblelantus/scripts/macos/mobileliblelantus\"", ); INFOPLIST_FILE = Runner/Info.plist; LD_RUNPATH_SEARCH_PATHS = ( diff --git a/scripts/app_config/templates/pubspec.template b/scripts/app_config/templates/pubspec.template index 9b007143e..6a8c1f552 100644 --- a/scripts/app_config/templates/pubspec.template +++ b/scripts/app_config/templates/pubspec.template @@ -24,9 +24,6 @@ dependencies: mutex: ^3.0.0 web_socket_channel: ^2.4.0 - lelantus: - path: ./crypto_plugins/flutter_liblelantus - frostdart: path: ./crypto_plugins/frostdart diff --git a/scripts/app_config/templates/windows/CMakeLists.txt b/scripts/app_config/templates/windows/CMakeLists.txt index b9add856d..650a25d76 100644 --- a/scripts/app_config/templates/windows/CMakeLists.txt +++ b/scripts/app_config/templates/windows/CMakeLists.txt @@ -83,9 +83,6 @@ install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../crypto_plugins/flutter_libepiccash/scripts/windows/build/libepic_cash_wallet.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) -install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/../crypto_plugins/flutter_liblelantus/scripts/windows/build/libmobileliblelantus.dll" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" - COMPONENT Runtime) - if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" diff --git a/scripts/ios/build_all.sh b/scripts/ios/build_all.sh index c47228cdc..b6f93e35f 100755 --- a/scripts/ios/build_all.sh +++ b/scripts/ios/build_all.sh @@ -10,8 +10,6 @@ rustup target add x86_64-apple-ios rustup target add aarch64-apple-ios rustup target add x86_64-apple-ios -(cd ../../crypto_plugins/flutter_liblelantus/scripts/ios && ./build_all.sh ) - # libepiccash requires old rust source ../rust_version.sh set_rust_version_for_libepiccash diff --git a/scripts/ios/build_all_campfire.sh b/scripts/ios/build_all_campfire.sh index c47228cdc..b6f93e35f 100755 --- a/scripts/ios/build_all_campfire.sh +++ b/scripts/ios/build_all_campfire.sh @@ -10,8 +10,6 @@ rustup target add x86_64-apple-ios rustup target add aarch64-apple-ios rustup target add x86_64-apple-ios -(cd ../../crypto_plugins/flutter_liblelantus/scripts/ios && ./build_all.sh ) - # libepiccash requires old rust source ../rust_version.sh set_rust_version_for_libepiccash diff --git a/scripts/ios/build_all_duo.sh b/scripts/ios/build_all_duo.sh index 3e3a73119..ea00ed599 100755 --- a/scripts/ios/build_all_duo.sh +++ b/scripts/ios/build_all_duo.sh @@ -12,8 +12,6 @@ rustup target add x86_64-apple-ios rustup target add aarch64-apple-ios rustup target add x86_64-apple-ios -(cd ../../crypto_plugins/flutter_liblelantus/scripts/ios && ./build_all.sh ) - # libepiccash requires old rust source ../rust_version.sh set_rust_version_for_libepiccash diff --git a/scripts/linux/build_all.sh b/scripts/linux/build_all.sh index 011d972b3..a2e6c3d85 100755 --- a/scripts/linux/build_all.sh +++ b/scripts/linux/build_all.sh @@ -8,7 +8,6 @@ set -x -e # flutter-elinux build linux --dart-define="IS_ARM=true" mkdir -p build ./build_secure_storage_deps.sh -(cd ../../crypto_plugins/flutter_liblelantus/scripts/linux && ./build_all.sh ) # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/linux/build_all_campfire.sh b/scripts/linux/build_all_campfire.sh index 011d972b3..a2e6c3d85 100755 --- a/scripts/linux/build_all_campfire.sh +++ b/scripts/linux/build_all_campfire.sh @@ -8,7 +8,6 @@ set -x -e # flutter-elinux build linux --dart-define="IS_ARM=true" mkdir -p build ./build_secure_storage_deps.sh -(cd ../../crypto_plugins/flutter_liblelantus/scripts/linux && ./build_all.sh ) # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/linux/build_all_duo.sh b/scripts/linux/build_all_duo.sh index aa804e73e..b9c18f6b2 100755 --- a/scripts/linux/build_all_duo.sh +++ b/scripts/linux/build_all_duo.sh @@ -10,8 +10,7 @@ set -x -e # flutter-elinux pub get # flutter-elinux build linux --dart-define="IS_ARM=true" mkdir -p build -./build_secure_storage_deps.sh & -(cd ../../crypto_plugins/flutter_liblelantus/scripts/linux && ./build_all.sh ) +./build_secure_storage_deps.sh # libepiccash requires old rust source ../rust_version.sh diff --git a/scripts/macos/build_all.sh b/scripts/macos/build_all.sh index 37dda0e64..5cfed585f 100755 --- a/scripts/macos/build_all.sh +++ b/scripts/macos/build_all.sh @@ -10,7 +10,6 @@ set_rust_version_for_libepiccash # set rust (back) to a more recent stable release after building epiccash set_rust_to_everything_else -(cd ../../crypto_plugins/flutter_liblelantus/scripts/macos && ./build_all.sh ) (cd ../../crypto_plugins/frostdart/scripts/macos && ./build_all.sh ) wait diff --git a/scripts/macos/build_all_campfire.sh b/scripts/macos/build_all_campfire.sh index 59a93ef26..e13ad106d 100755 --- a/scripts/macos/build_all_campfire.sh +++ b/scripts/macos/build_all_campfire.sh @@ -10,7 +10,6 @@ set_rust_version_for_libepiccash # set rust (back) to a more recent stable release after building epiccash set_rust_to_everything_else -(cd ../../crypto_plugins/flutter_liblelantus/scripts/macos && ./build_all.sh ) (cd ../../crypto_plugins/frostdart/scripts/macos && ./build_all.sh ) wait diff --git a/scripts/macos/build_all_duo.sh b/scripts/macos/build_all_duo.sh index 960f5a44a..a520cafc2 100755 --- a/scripts/macos/build_all_duo.sh +++ b/scripts/macos/build_all_duo.sh @@ -12,7 +12,6 @@ set_rust_version_for_libepiccash # set rust (back) to a more recent stable release after building epiccash set_rust_to_everything_else -(cd ../../crypto_plugins/flutter_liblelantus/scripts/macos && ./build_all.sh ) (cd ../../crypto_plugins/frostdart/scripts/macos && ./build_all.sh ) wait diff --git a/scripts/windows/build_all.sh b/scripts/windows/build_all.sh index cf3ad76d9..338394410 100755 --- a/scripts/windows/build_all.sh +++ b/scripts/windows/build_all.sh @@ -11,7 +11,6 @@ set_rust_version_for_libepiccash # set rust (back) to a more recent stable release after building epiccash set_rust_to_everything_else -(cd ../../crypto_plugins/flutter_liblelantus/scripts/windows && ./build_all.sh ) (cd ../../crypto_plugins/frostdart/scripts/windows && ./build_all.sh ) ./build_secp256k1_wsl.sh diff --git a/scripts/windows/build_all_campfire.sh b/scripts/windows/build_all_campfire.sh index cf3ad76d9..338394410 100755 --- a/scripts/windows/build_all_campfire.sh +++ b/scripts/windows/build_all_campfire.sh @@ -11,7 +11,6 @@ set_rust_version_for_libepiccash # set rust (back) to a more recent stable release after building epiccash set_rust_to_everything_else -(cd ../../crypto_plugins/flutter_liblelantus/scripts/windows && ./build_all.sh ) (cd ../../crypto_plugins/frostdart/scripts/windows && ./build_all.sh ) ./build_secp256k1_wsl.sh diff --git a/scripts/windows/build_all_duo.sh b/scripts/windows/build_all_duo.sh index e54986e7d..e70eb145d 100755 --- a/scripts/windows/build_all_duo.sh +++ b/scripts/windows/build_all_duo.sh @@ -13,7 +13,6 @@ set_rust_version_for_libepiccash # set rust (back) to a more recent stable release after building epiccash set_rust_to_everything_else -(cd ../../crypto_plugins/flutter_liblelantus/scripts/windows && ./build_all.sh ) (cd ../../crypto_plugins/frostdart/scripts/windows && ./build_all.sh ) ./build_secp256k1_wsl.sh diff --git a/scripts/windows/deps.sh b/scripts/windows/deps.sh index c9975b457..f68011a69 100644 --- a/scripts/windows/deps.sh +++ b/scripts/windows/deps.sh @@ -1,8 +1,6 @@ #!/bin/bash cd ../../crypto_plugins/flutter_libepiccash/scripts/windows && ./deps.sh -cd ../../crypto_plugins/flutter_liblelantus/scripts/windows && ./mxedeps.sh -# cd ../../crypto_plugins/flutter_libmonero/scripts/windows && ./monerodeps.sh && ./mxedeps.sh sudo apt install libgtk2.0-dev wait diff --git a/test/models/lelantus_fee_data_test.dart b/test/models/lelantus_fee_data_test.dart deleted file mode 100644 index a6e2ebb9b..000000000 --- a/test/models/lelantus_fee_data_test.dart +++ /dev/null @@ -1,10 +0,0 @@ -import 'package:flutter_test/flutter_test.dart'; -import 'package:stackwallet/models/lelantus_fee_data.dart'; - -void main() { - test("LelantusFeeData constructor", () { - final lfData = LelantusFeeData(10000, 3794, [1, 2, 1, 0, 1]); - expect(lfData.toString(), - "{changeToMint: 10000, fee: 3794, spendCoinIndexes: [1, 2, 1, 0, 1]}"); - }); -} From f3d923e91928d0a5ef2b45a0a167b8a0266ca848 Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 29 May 2025 13:15:08 -0600 Subject: [PATCH 3/7] ios fix --- ios/Podfile.lock | 16 +++++++++++++--- macos/Podfile.lock | 13 +++++++++++-- .../ios/Runner.xcodeproj/project.pbxproj | 14 ++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 13a199bd8..3f6bee8e7 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -11,6 +11,8 @@ PODS: - ReachabilitySwift - cs_monero_flutter_libs_ios (0.0.1): - Flutter + - cs_salvium_flutter_libs_ios (0.0.1): + - Flutter - device_info_plus (0.0.1): - Flutter - devicelocale (0.0.1): @@ -85,6 +87,8 @@ PODS: - "sqlite3 (3.46.0+1)": - "sqlite3/common (= 3.46.0+1)" - "sqlite3/common (3.46.0+1)" + - "sqlite3/dbstatvtab (3.46.0+1)": + - sqlite3/common - "sqlite3/fts5 (3.46.0+1)": - sqlite3/common - "sqlite3/perf-threadsafe (3.46.0+1)": @@ -93,7 +97,8 @@ PODS: - sqlite3/common - sqlite3_flutter_libs (0.0.1): - Flutter - - sqlite3 (~> 3.46.0) + - "sqlite3 (~> 3.46.0+1)" + - sqlite3/dbstatvtab - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree @@ -115,6 +120,7 @@ DEPENDENCIES: - coinlib_flutter (from `.symlinks/plugins/coinlib_flutter/darwin`) - connectivity_plus (from `.symlinks/plugins/connectivity_plus/ios`) - cs_monero_flutter_libs_ios (from `.symlinks/plugins/cs_monero_flutter_libs_ios/ios`) + - cs_salvium_flutter_libs_ios (from `.symlinks/plugins/cs_salvium_flutter_libs_ios/ios`) - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) - devicelocale (from `.symlinks/plugins/devicelocale/ios`) - file_picker (from `.symlinks/plugins/file_picker/ios`) @@ -159,6 +165,8 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/connectivity_plus/ios" cs_monero_flutter_libs_ios: :path: ".symlinks/plugins/cs_monero_flutter_libs_ios/ios" + cs_salvium_flutter_libs_ios: + :path: ".symlinks/plugins/cs_salvium_flutter_libs_ios/ios" device_info_plus: :path: ".symlinks/plugins/device_info_plus/ios" devicelocale: @@ -211,6 +219,7 @@ SPEC CHECKSUMS: coinlib_flutter: 9275e8255ef67d3da33beb6e117d09ced4f46eb5 connectivity_plus: 07c49e96d7fc92bc9920617b83238c4d178b446a cs_monero_flutter_libs_ios: fd353631682247f72a36493ff060d4328d6f720d + cs_salvium_flutter_libs_ios: f9d6ce540cb34d8cb8641822cf02fa0695a8d405 device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d devicelocale: 35ba84dc7f45f527c3001535d8c8d104edd5d926 DKImagePickerController: b512c28220a2b8ac7419f21c491fc8534b7601ac @@ -234,13 +243,14 @@ SPEC CHECKSUMS: SDWebImage: 72f86271a6f3139cc7e4a89220946489d4b9a866 share_plus: c3fef564749587fc939ef86ffb283ceac0baf9f5 sqlite3: 292c3e1bfe89f64e51ea7fc7dab9182a017c8630 - sqlite3_flutter_libs: 0d611efdf6d1c9297d5ab03dab21b75aeebdae31 + sqlite3_flutter_libs: c00457ebd31e59fa6bb830380ddba24d44fbcd3b stack_wallet_backup: 5b8563aba5d8ffbf2ce1944331ff7294a0ec7c03 SwiftProtobuf: 6ef3f0e422ef90d6605ca20b21a94f6c1324d6b3 SwiftyGif: 6c3eafd0ce693cad58bb63d2b2fb9bacb8552780 tor_ffi_plugin: d80e291b649379c8176e1be739e49be007d4ef93 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe - wakelock_plus: 78ec7c5b202cab7761af8e2b2b3d0671be6c4ae1 + wakelock_plus: 373cfe59b235a6dd5837d0fb88791d2f13a90d56 + xelis_flutter: a6a1ee1f1e47f5aeb42dc4a5889358b79d8d90fc PODFILE CHECKSUM: 57c8aed26fba39d3ec9424816221f294a07c58eb diff --git a/macos/Podfile.lock b/macos/Podfile.lock index 3dba40491..64b655098 100644 --- a/macos/Podfile.lock +++ b/macos/Podfile.lock @@ -9,6 +9,8 @@ PODS: - ReachabilitySwift - cs_monero_flutter_libs_macos (0.0.1): - FlutterMacOS + - cs_salvium_flutter_libs_macos (0.0.1): + - FlutterMacOS - desktop_drop (0.0.1): - FlutterMacOS - device_info_plus (0.0.1): @@ -44,6 +46,8 @@ PODS: - "sqlite3 (3.46.0+1)": - "sqlite3/common (= 3.46.0+1)" - "sqlite3/common (3.46.0+1)" + - "sqlite3/dbstatvtab (3.46.0+1)": + - sqlite3/common - "sqlite3/fts5 (3.46.0+1)": - sqlite3/common - "sqlite3/perf-threadsafe (3.46.0+1)": @@ -52,7 +56,8 @@ PODS: - sqlite3/common - sqlite3_flutter_libs (0.0.1): - FlutterMacOS - - sqlite3 (~> 3.46.0) + - "sqlite3 (~> 3.46.0+1)" + - sqlite3/dbstatvtab - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree @@ -73,6 +78,7 @@ DEPENDENCIES: - coinlib_flutter (from `Flutter/ephemeral/.symlinks/plugins/coinlib_flutter/darwin`) - connectivity_plus (from `Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos`) - cs_monero_flutter_libs_macos (from `Flutter/ephemeral/.symlinks/plugins/cs_monero_flutter_libs_macos/macos`) + - cs_salvium_flutter_libs_macos (from `Flutter/ephemeral/.symlinks/plugins/cs_salvium_flutter_libs_macos/macos`) - desktop_drop (from `Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos`) - device_info_plus (from `Flutter/ephemeral/.symlinks/plugins/device_info_plus/macos`) - devicelocale (from `Flutter/ephemeral/.symlinks/plugins/devicelocale/macos`) @@ -110,6 +116,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/connectivity_plus/macos cs_monero_flutter_libs_macos: :path: Flutter/ephemeral/.symlinks/plugins/cs_monero_flutter_libs_macos/macos + cs_salvium_flutter_libs_macos: + :path: Flutter/ephemeral/.symlinks/plugins/cs_salvium_flutter_libs_macos/macos desktop_drop: :path: Flutter/ephemeral/.symlinks/plugins/desktop_drop/macos device_info_plus: @@ -160,6 +168,7 @@ SPEC CHECKSUMS: coinlib_flutter: 9275e8255ef67d3da33beb6e117d09ced4f46eb5 connectivity_plus: 18d3c32514c886e046de60e9c13895109866c747 cs_monero_flutter_libs_macos: b901f94d39d1338f706312b026aba928d23582d4 + cs_salvium_flutter_libs_macos: 3c7b30fb8c82ee0fb0195280ddcc10c65ab5e082 desktop_drop: 69eeff437544aa619c8db7f4481b3a65f7696898 device_info_plus: ce1b7762849d3ec103d0e0517299f2db7ad60720 devicelocale: 9f0f36ac651cabae2c33f32dcff4f32b61c38225 @@ -177,7 +186,7 @@ SPEC CHECKSUMS: ReachabilitySwift: 7f151ff156cea1481a8411701195ac6a984f4979 share_plus: 76dd39142738f7a68dd57b05093b5e8193f220f7 sqlite3: 292c3e1bfe89f64e51ea7fc7dab9182a017c8630 - sqlite3_flutter_libs: 1be4459672f8168ded2d8667599b8e3ca5e72b83 + sqlite3_flutter_libs: 5ca46c1a04eddfbeeb5b16566164aa7ad1616e7b stack_wallet_backup: 6ebc60b1bdcf11cf1f1cbad9aa78332e1e15778c tor_ffi_plugin: 2566c1ed174688cca560fa0c64b7a799c66f07cb url_launcher_macos: c82c93949963e55b228a30115bd219499a6fe404 diff --git a/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj b/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj index 5c1e9e238..300249f37 100644 --- a/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj +++ b/scripts/app_config/templates/ios/Runner.xcodeproj/project.pbxproj @@ -310,9 +310,11 @@ "${BUILT_PRODUCTS_DIR}/barcode_scan2/barcode_scan2.framework", "${BUILT_PRODUCTS_DIR}/coinlib_flutter/secp256k1.framework", "${BUILT_PRODUCTS_DIR}/connectivity_plus/connectivity_plus.framework", - "${PODS_ROOT}/../.symlinks/plugins/cs_monero_flutter_libs/ios/Frameworks/MoneroWallet.framework", - "${PODS_ROOT}/../.symlinks/plugins/cs_monero_flutter_libs/ios/Frameworks/WowneroWallet.framework", - "${BUILT_PRODUCTS_DIR}/cs_monero_flutter_libs/cs_monero_flutter_libs.framework", + "${PODS_ROOT}/../.symlinks/plugins/cs_monero_flutter_libs_ios/ios/Frameworks/MoneroWallet.framework", + "${PODS_ROOT}/../.symlinks/plugins/cs_monero_flutter_libs_ios/ios/Frameworks/WowneroWallet.framework", + "${BUILT_PRODUCTS_DIR}/cs_monero_flutter_libs_ios/cs_monero_flutter_libs_ios.framework", + "${PODS_ROOT}/../.symlinks/plugins/cs_salvium_flutter_libs_ios/ios/Frameworks/SalviumWallet.framework", + "${BUILT_PRODUCTS_DIR}/cs_salvium_flutter_libs_ios/cs_salvium_flutter_libs_ios.framework", "${BUILT_PRODUCTS_DIR}/device_info_plus/device_info_plus.framework", "${BUILT_PRODUCTS_DIR}/devicelocale/devicelocale.framework", "${BUILT_PRODUCTS_DIR}/file_picker/file_picker.framework", @@ -333,6 +335,7 @@ "${BUILT_PRODUCTS_DIR}/tor_ffi_plugin/tor_ffi_plugin.framework", "${BUILT_PRODUCTS_DIR}/url_launcher_ios/url_launcher_ios.framework", "${BUILT_PRODUCTS_DIR}/wakelock_plus/wakelock_plus.framework", + "${BUILT_PRODUCTS_DIR}/xelis_flutter/xelis_flutter.framework", ); name = "[CP] Embed Pods Frameworks"; outputPaths = ( @@ -348,7 +351,9 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/connectivity_plus.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/MoneroWallet.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WowneroWallet.framework", - "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/cs_monero_flutter_libs.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/cs_monero_flutter_libs_ios.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SalviumWallet.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/cs_salvium_flutter_libs_ios.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/device_info_plus.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/devicelocale.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/file_picker.framework", @@ -369,6 +374,7 @@ "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/tor_ffi_plugin.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/url_launcher_ios.framework", "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/wakelock_plus.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/xelis_flutter.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; From 58703ac6b5549e56fa5de4d8e591e8be47e27af3 Mon Sep 17 00:00:00 2001 From: julian Date: Thu, 29 May 2025 15:13:14 -0600 Subject: [PATCH 4/7] Add space on desktop --- .../frost_ms/new/select_new_frost_import_type_view.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart b/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart index e00f679cb..131e60004 100644 --- a/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart +++ b/lib/pages/add_wallet_views/frost_ms/new/select_new_frost_import_type_view.dart @@ -170,6 +170,7 @@ class _SelectNewFrostImportTypeViewState ).pushNamed(FrostStepScaffold.routeName); }, ), + if (Util.isDesktop) const SizedBox(height: 32), ], ), ), From 769a872be10aa3c265f2a0a33309b864e63efd7b Mon Sep 17 00:00:00 2001 From: Julian Date: Thu, 29 May 2025 16:16:38 -0600 Subject: [PATCH 5/7] ios cam permission dialog tweak --- lib/utilities/barcode_scanner_interface.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/utilities/barcode_scanner_interface.dart b/lib/utilities/barcode_scanner_interface.dart index 7579eedcf..87b079d03 100644 --- a/lib/utilities/barcode_scanner_interface.dart +++ b/lib/utilities/barcode_scanner_interface.dart @@ -44,7 +44,11 @@ Future checkCamPermDeniedMobileAndOpenAppSettings( }) async { if (Platform.isAndroid || Platform.isIOS) { final status = await Permission.camera.status; - if (status == PermissionStatus.permanentlyDenied && context.mounted) { + final androidShow = + Platform.isAndroid && status == PermissionStatus.permanentlyDenied; + final iosShow = Platform.isIOS && status == PermissionStatus.denied; + + if ((iosShow || androidShow) && context.mounted) { final trySettings = await showDialog( context: context, builder: From 0ff1ad0a9aab384b1420eaffd07e4baac744f720 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 30 May 2025 11:05:39 -0600 Subject: [PATCH 6/7] show prev gen frost info in backup view --- .../unlock_wallet_keys_desktop.dart | 127 ++++----- .../wallet_keys_desktop_popup.dart | 257 ++++++++++-------- lib/route_generator.dart | 16 +- 3 files changed, 214 insertions(+), 186 deletions(-) diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart index 3faf4ec80..4f1db4504 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/unlock_wallet_keys_desktop.dart @@ -37,10 +37,7 @@ import '../../../../widgets/stack_text_field.dart'; import 'wallet_keys_desktop_popup.dart'; class UnlockWalletKeysDesktop extends ConsumerStatefulWidget { - const UnlockWalletKeysDesktop({ - super.key, - required this.walletId, - }); + const UnlockWalletKeysDesktop({super.key, required this.walletId}); final String walletId; @@ -64,16 +61,12 @@ class _UnlockWalletKeysDesktopState unawaited( showDialog( context: context, - builder: (context) => const Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - LoadingIndicator( - width: 200, - height: 200, + builder: + (context) => const Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [LoadingIndicator(width: 200, height: 200)], ), - ], - ), ), ); @@ -89,17 +82,38 @@ class _UnlockWalletKeysDesktopState } final wallet = ref.read(pWallets).getWallet(widget.walletId); - ({String keys, String config})? frostData; + ({ + String myName, + String config, + String keys, + ({String config, String keys})? prevGen, + })? + frostWalletData; List? words; // TODO: [prio=low] handle wallets that don't have a mnemonic // All wallets currently are mnemonic based if (wallet is! MnemonicInterface) { if (wallet is BitcoinFrostWallet) { - frostData = ( - keys: (await wallet.getSerializedKeys())!, - config: (await wallet.getMultisigConfig())!, - ); + final futures = [ + wallet.getSerializedKeys(), + wallet.getMultisigConfig(), + wallet.getSerializedKeysPrevGen(), + wallet.getMultisigConfigPrevGen(), + ]; + + final results = await Future.wait(futures); + if (results.length == 4) { + frostWalletData = ( + myName: wallet.frostInfo.myName, + config: results[1]!, + keys: results[0]!, + prevGen: + results[2] == null || results[3] == null + ? null + : (config: results[3]!, keys: results[2]!), + ); + } } else { throw Exception("FIXME ~= see todo in code"); } @@ -129,7 +143,7 @@ class _UnlockWalletKeysDesktopState arguments: ( mnemonic: words ?? [], walletId: widget.walletId, - frostData: frostData, + frostData: frostWalletData, keyData: keyData, ), ); @@ -177,44 +191,25 @@ class _UnlockWalletKeysDesktopState mainAxisAlignment: MainAxisAlignment.end, children: [ DesktopDialogCloseButton( - onPressedOverride: Navigator.of( - context, - rootNavigator: true, - ).pop, + onPressedOverride: + Navigator.of(context, rootNavigator: true).pop, ), ], ), - const SizedBox( - height: 12, - ), - SvgPicture.asset( - Assets.svg.keys, - width: 100, - height: 58, - ), - const SizedBox( - height: 55, - ), - Text( - "Wallet keys", - style: STextStyles.desktopH2(context), - ), - const SizedBox( - height: 16, - ), + const SizedBox(height: 12), + SvgPicture.asset(Assets.svg.keys, width: 100, height: 58), + const SizedBox(height: 55), + Text("Wallet keys", style: STextStyles.desktopH2(context)), + const SizedBox(height: 16), Text( "Enter your password", style: STextStyles.desktopTextMedium(context).copyWith( color: Theme.of(context).extension()!.textDark3, ), ), - const SizedBox( - height: 24, - ), + const SizedBox(height: 24), Padding( - padding: const EdgeInsets.symmetric( - horizontal: 32, - ), + padding: const EdgeInsets.symmetric(horizontal: 32), child: ClipRRect( borderRadius: BorderRadius.circular( Constants.size.circularBorderRadius, @@ -223,9 +218,9 @@ class _UnlockWalletKeysDesktopState key: const Key("enterPasswordUnlockWalletKeysDesktopFieldKey"), focusNode: passwordFocusNode, controller: passwordController, - style: STextStyles.desktopTextMedium(context).copyWith( - height: 2, - ), + style: STextStyles.desktopTextMedium( + context, + ).copyWith(height: 2), obscureText: hidePassword, enableSuggestions: false, autocorrect: false, @@ -266,18 +261,17 @@ class _UnlockWalletKeysDesktopState hidePassword ? Assets.svg.eye : Assets.svg.eyeSlash, - color: Theme.of(context) - .extension()! - .textDark3, + color: + Theme.of( + context, + ).extension()!.textDark3, width: 24, height: 19, ), ), ), ), - const SizedBox( - width: 10, - ), + const SizedBox(width: 10), ], ), ), @@ -291,27 +285,18 @@ class _UnlockWalletKeysDesktopState ), ), ), - const SizedBox( - height: 55, - ), + const SizedBox(height: 55), Padding( - padding: const EdgeInsets.symmetric( - horizontal: 32, - ), + padding: const EdgeInsets.symmetric(horizontal: 32), child: Row( children: [ Expanded( child: SecondaryButton( label: "Cancel", - onPressed: Navigator.of( - context, - rootNavigator: true, - ).pop, + onPressed: Navigator.of(context, rootNavigator: true).pop, ), ), - const SizedBox( - width: 16, - ), + const SizedBox(width: 16), Expanded( child: PrimaryButton( label: "Continue", @@ -322,9 +307,7 @@ class _UnlockWalletKeysDesktopState ], ), ), - const SizedBox( - height: 32, - ), + const SizedBox(height: 32), ], ), ); diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart index bb8ba8089..2c31098a2 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/wallet_keys_desktop_popup.dart @@ -49,7 +49,13 @@ class WalletKeysDesktopPopup extends ConsumerWidget { final List words; final String walletId; - final ({String keys, String config})? frostData; + final ({ + String myName, + String config, + String keys, + ({String config, String keys})? prevGen, + })? + frostData; final ClipboardInterface clipboardInterface; final KeyDataInterface? keyData; @@ -66,9 +72,7 @@ class WalletKeysDesktopPopup extends ConsumerWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( - padding: const EdgeInsets.only( - left: 32, - ), + padding: const EdgeInsets.only(left: 32), child: Text( "Wallet keys", style: STextStyles.desktopH3(context), @@ -81,28 +85,93 @@ class WalletKeysDesktopPopup extends ConsumerWidget { ), ], ), - const SizedBox( - height: 6, - ), + const SizedBox(height: 6), frostData != null ? Column( - children: [ + children: [ + Text("Keys", style: STextStyles.desktopTextMedium(context)), + const SizedBox(height: 8), + Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: RoundedWhiteContainer( + borderColor: + Theme.of( + context, + ).extension()!.textFieldDefaultBG, + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 9, + ), + child: Row( + children: [ + Flexible( + child: SelectableText( + frostData!.keys, + style: STextStyles.desktopTextExtraExtraSmall( + context, + ), + textAlign: TextAlign.center, + ), + ), + const SizedBox(width: 10), + IconCopyButton(data: frostData!.keys), + // TODO [prio=low: Add QR code button and dialog. + ], + ), + ), + ), + ), + const SizedBox(height: 24), + Text("Config", style: STextStyles.desktopTextMedium(context)), + const SizedBox(height: 8), + Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 32), + child: RoundedWhiteContainer( + borderColor: + Theme.of( + context, + ).extension()!.textFieldDefaultBG, + padding: const EdgeInsets.symmetric( + horizontal: 12, + vertical: 9, + ), + child: Row( + children: [ + Flexible( + child: SelectableText( + frostData!.config, + style: STextStyles.desktopTextExtraExtraSmall( + context, + ), + textAlign: TextAlign.center, + ), + ), + const SizedBox(width: 10), + IconCopyButton(data: frostData!.config), + // TODO [prio=low: Add QR code button and dialog. + ], + ), + ), + ), + ), + if (frostData?.prevGen != null) const SizedBox(height: 24), + if (frostData?.prevGen != null) Text( - "Keys", + "Previous generation Keys", style: STextStyles.desktopTextMedium(context), ), - const SizedBox( - height: 8, - ), + if (frostData?.prevGen != null) const SizedBox(height: 8), + if (frostData?.prevGen != null) Center( child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 32, - ), + padding: const EdgeInsets.symmetric(horizontal: 32), child: RoundedWhiteContainer( - borderColor: Theme.of(context) - .extension()! - .textFieldDefaultBG, + borderColor: + Theme.of( + context, + ).extension()!.textFieldDefaultBG, padding: const EdgeInsets.symmetric( horizontal: 12, vertical: 9, @@ -118,37 +187,30 @@ class WalletKeysDesktopPopup extends ConsumerWidget { textAlign: TextAlign.center, ), ), - const SizedBox( - width: 10, - ), - IconCopyButton( - data: frostData!.keys, - ), + const SizedBox(width: 10), + IconCopyButton(data: frostData!.keys), // TODO [prio=low: Add QR code button and dialog. ], ), ), ), ), - const SizedBox( - height: 24, - ), + if (frostData?.prevGen != null) const SizedBox(height: 24), + if (frostData?.prevGen != null) Text( - "Config", + "Previous generation Config", style: STextStyles.desktopTextMedium(context), ), - const SizedBox( - height: 8, - ), + if (frostData?.prevGen != null) const SizedBox(height: 8), + if (frostData?.prevGen != null) Center( child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 32, - ), + padding: const EdgeInsets.symmetric(horizontal: 32), child: RoundedWhiteContainer( - borderColor: Theme.of(context) - .extension()! - .textFieldDefaultBG, + borderColor: + Theme.of( + context, + ).extension()!.textFieldDefaultBG, padding: const EdgeInsets.symmetric( horizontal: 12, vertical: 9, @@ -157,70 +219,58 @@ class WalletKeysDesktopPopup extends ConsumerWidget { children: [ Flexible( child: SelectableText( - frostData!.config, + frostData!.prevGen!.config, style: STextStyles.desktopTextExtraExtraSmall( context, ), textAlign: TextAlign.center, ), ), - const SizedBox( - width: 10, - ), - IconCopyButton( - data: frostData!.config, - ), + const SizedBox(width: 10), + IconCopyButton(data: frostData!.prevGen!.config), // TODO [prio=low: Add QR code button and dialog. ], ), ), ), ), - const SizedBox( - height: 24, - ), - ], - ) + const SizedBox(height: 24), + ], + ) : keyData != null - ? keyData is ViewOnlyWalletData - ? Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), - child: ViewOnlyWalletDataWidget( - data: keyData as ViewOnlyWalletData, - ), - ) - : CustomTabView( - titles: [ - if (words.isNotEmpty) "Mnemonic", - if (keyData is XPrivData) "XPriv(s)", - if (keyData is CWKeyData) "Keys", - ], - children: [ - if (words.isNotEmpty) - Padding( - padding: const EdgeInsets.only(top: 16), - child: _Mnemonic( - words: words, - ), - ), - if (keyData is XPrivData) - WalletXPrivs( - xprivData: keyData as XPrivData, - walletId: walletId, - ), - if (keyData is CWKeyData) - CNWalletKeys( - cwKeyData: keyData as CWKeyData, - walletId: walletId, - ), - ], - ) - : _Mnemonic( - words: words, + ? keyData is ViewOnlyWalletData + ? Padding( + padding: const EdgeInsets.symmetric(horizontal: 16), + child: ViewOnlyWalletDataWidget( + data: keyData as ViewOnlyWalletData, ), - const SizedBox( - height: 32, - ), + ) + : CustomTabView( + titles: [ + if (words.isNotEmpty) "Mnemonic", + if (keyData is XPrivData) "XPriv(s)", + if (keyData is CWKeyData) "Keys", + ], + children: [ + if (words.isNotEmpty) + Padding( + padding: const EdgeInsets.only(top: 16), + child: _Mnemonic(words: words), + ), + if (keyData is XPrivData) + WalletXPrivs( + xprivData: keyData as XPrivData, + walletId: walletId, + ), + if (keyData is CWKeyData) + CNWalletKeys( + cwKeyData: keyData as CWKeyData, + walletId: walletId, + ), + ], + ) + : _Mnemonic(words: words), + const SizedBox(height: 32), ], ), ); @@ -241,18 +291,11 @@ class _Mnemonic extends StatelessWidget { Widget build(BuildContext context) { return Column( children: [ - Text( - "Recovery phrase", - style: STextStyles.desktopTextMedium(context), - ), - const SizedBox( - height: 8, - ), + Text("Recovery phrase", style: STextStyles.desktopTextMedium(context)), + const SizedBox(height: 8), Center( child: Padding( - padding: const EdgeInsets.symmetric( - horizontal: 32, - ), + padding: const EdgeInsets.symmetric(horizontal: 32), child: Text( "Please write down your recovery phrase in the correct order and " "save it to keep your funds secure. You will also be asked to" @@ -262,13 +305,9 @@ class _Mnemonic extends StatelessWidget { ), ), ), - const SizedBox( - height: 24, - ), + const SizedBox(height: 24), Padding( - padding: const EdgeInsets.symmetric( - horizontal: 32, - ), + padding: const EdgeInsets.symmetric(horizontal: 32), child: MnemonicTable( words: words, isDesktop: true, @@ -276,13 +315,9 @@ class _Mnemonic extends StatelessWidget { Theme.of(context).extension()!.buttonBackSecondary, ), ), - const SizedBox( - height: 24, - ), + const SizedBox(height: 24), Padding( - padding: const EdgeInsets.symmetric( - horizontal: 32, - ), + padding: const EdgeInsets.symmetric(horizontal: 32), child: Row( children: [ Expanded( @@ -305,9 +340,7 @@ class _Mnemonic extends StatelessWidget { }, ), ), - const SizedBox( - width: 16, - ), + const SizedBox(width: 16), Expanded( child: PrimaryButton( label: "Show QR code", diff --git a/lib/route_generator.dart b/lib/route_generator.dart index 55f6964b3..7c0f4ea13 100644 --- a/lib/route_generator.dart +++ b/lib/route_generator.dart @@ -2336,7 +2336,13 @@ class RouteGenerator { is ({ List mnemonic, String walletId, - ({String keys, String config})? frostData, + ({ + String myName, + String config, + String keys, + ({String config, String keys})? prevGen, + })? + frostData, })) { return FadePageRoute( WalletKeysDesktopPopup( @@ -2350,7 +2356,13 @@ class RouteGenerator { is ({ List mnemonic, String walletId, - ({String keys, String config})? frostData, + ({ + String myName, + String config, + String keys, + ({String config, String keys})? prevGen, + })? + frostData, KeyDataInterface? keyData, })) { return FadePageRoute( From f4abb1f48e4768c5b017b285f320f318f43caab7 Mon Sep 17 00:00:00 2001 From: julian Date: Fri, 30 May 2025 11:15:08 -0600 Subject: [PATCH 7/7] frost spend fix --- crypto_plugins/frostdart | 2 +- .../wallet/impl/bitcoin_frost_wallet.dart | 532 ++++++++---------- 2 files changed, 239 insertions(+), 295 deletions(-) diff --git a/crypto_plugins/frostdart b/crypto_plugins/frostdart index 6f1310ecc..5e8a51592 160000 --- a/crypto_plugins/frostdart +++ b/crypto_plugins/frostdart @@ -1 +1 @@ -Subproject commit 6f1310eccd336fb3c8dc00b61e39a3f0f3a2b59a +Subproject commit 5e8a51592690650e7ac63fafa81017dfc51ae6d5 diff --git a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart index 2b5173b6b..3b0c36ac0 100644 --- a/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart +++ b/lib/wallets/wallet/impl/bitcoin_frost_wallet.dart @@ -37,12 +37,13 @@ const kFrostSecureStartingIndex = 1; class BitcoinFrostWallet extends Wallet with MultiAddressInterface { BitcoinFrostWallet(CryptoCurrencyNetwork network) - : super(BitcoinFrost(network) as T); + : super(BitcoinFrost(network) as T); - FrostWalletInfo get frostInfo => mainDB.isar.frostWalletInfo - .where() - .walletIdEqualTo(walletId) - .findFirstSync()!; + FrostWalletInfo get frostInfo => + mainDB.isar.frostWalletInfo + .where() + .walletIdEqualTo(walletId) + .findFirstSync()!; late ElectrumXClient electrumXClient; late CachedElectrumXClient electrumXCachedClient; @@ -59,11 +60,7 @@ class BitcoinFrostWallet extends Wallet Logging.instance.i("Generating new FROST wallet."); try { - final salt = frost - .multisigSalt( - multisigConfig: multisigConfig, - ) - .toHex; + final salt = frost.multisigSalt(multisigConfig: multisigConfig).toHex; final FrostWalletInfo frostWalletInfo = FrostWalletInfo( walletId: info.walletId, @@ -127,22 +124,24 @@ class BitcoinFrostWallet extends Wallet .map((e) => e.amount) .reduce((value, e) => value += e); - final utxos = await mainDB - .getUTXOs(walletId) - .filter() - .isBlockedEqualTo(false) - .findAll(); + final utxos = + await mainDB + .getUTXOs(walletId) + .filter() + .isBlockedEqualTo(false) + .findAll(); if (utxos.isEmpty) { throw Exception("No UTXOs found"); } else { final currentHeight = await chainHeight; utxos.removeWhere( - (e) => !e.isConfirmed( - currentHeight, - cryptoCurrency.minConfirms, - cryptoCurrency.minCoinbaseConfirms, - ), + (e) => + !e.isConfirmed( + currentHeight, + cryptoCurrency.minConfirms, + cryptoCurrency.minCoinbaseConfirms, + ), ); if (utxos.isEmpty) { throw Exception("No confirmed UTXOs found"); @@ -174,32 +173,32 @@ class BitcoinFrostWallet extends Wallet } } - final int network = cryptoCurrency.network == CryptoCurrencyNetwork.main - ? Network.Mainnet - : Network.Testnet; + final int network = + cryptoCurrency.network == CryptoCurrencyNetwork.main + ? Network.Mainnet + : Network.Testnet; final List< - ({ - UTXO utxo, - Uint8List scriptPubKey, - ({int account, int index, bool change}) addressDerivationData - })> inputs = []; + ({ + UTXO utxo, + Uint8List scriptPubKey, + ({int account, int index, bool change, bool secure}) + addressDerivationData, + }) + > + inputs = []; for (final utxo in utxosToUse) { - final dData = await getDerivationData( - utxo.address, - ); + final dData = await getDerivationData(utxo.address); final publicKey = cryptoCurrency.addressToPubkey( address: utxo.address!, ); - inputs.add( - ( - utxo: utxo, - scriptPubKey: publicKey, - addressDerivationData: dData, - ), - ); + inputs.add(( + utxo: utxo, + scriptPubKey: publicKey, + addressDerivationData: dData, + )); } await checkChangeAddressForTransactions(); final changeAddress = await getCurrentChangeAddress(); @@ -221,19 +220,15 @@ class BitcoinFrostWallet extends Wallet utxosRemaining.isNotEmpty) { // add extra utxo final utxo = utxosRemaining.take(1).first; - final dData = await getDerivationData( - utxo.address, - ); + final dData = await getDerivationData(utxo.address); final publicKey = cryptoCurrency.addressToPubkey( address: utxo.address!, ); - inputs.add( - ( - utxo: utxo, - scriptPubKey: publicKey, - addressDerivationData: dData, - ), - ); + inputs.add(( + utxo: utxo, + scriptPubKey: publicKey, + addressDerivationData: dData, + )); } else { rethrow; } @@ -246,9 +241,8 @@ class BitcoinFrostWallet extends Wallet } } - Future<({int account, int index, bool change})> getDerivationData( - String? address, - ) async { + Future<({int account, int index, bool change, bool secure})> + getDerivationData(String? address) async { if (address == null) { throw Exception("Missing address required for FROST signing"); } @@ -269,15 +263,14 @@ class BitcoinFrostWallet extends Wallet ); } if (components[1] != 0 && components[1] != 1) { - throw Exception( - "${components[1]} must be 1 or 0 for change", - ); + throw Exception("${components[1]} must be 1 or 0 for change"); } return ( account: components[0], change: components[1] == 1, index: components[2], + secure: addr.zSafeFrost ?? false, ); } catch (_) { rethrow; @@ -285,15 +278,13 @@ class BitcoinFrostWallet extends Wallet } Future< - ({ - Pointer machinePtr, - String preprocess, - })> frostAttemptSignConfig({ - required String config, - }) async { - final int network = cryptoCurrency.network == CryptoCurrencyNetwork.main - ? Network.Mainnet - : Network.Testnet; + ({Pointer machinePtr, String preprocess}) + > + frostAttemptSignConfig({required String config}) async { + final int network = + cryptoCurrency.network == CryptoCurrencyNetwork.main + ? Network.Mainnet + : Network.Testnet; final serializedKeys = await getSerializedKeys(); return Frost.attemptSignConfig( @@ -312,17 +303,13 @@ class BitcoinFrostWallet extends Wallet await _saveMultisigConfig(multisigConfig); await _updateThreshold( - frost.getThresholdFromKeys( - serializedKeys: serializedKeys, - ), + frost.getThresholdFromKeys(serializedKeys: serializedKeys), ); final myNameIndex = frost.getParticipantIndexFromKeys( serializedKeys: serializedKeys, ); - final participants = Frost.getParticipants( - multisigConfig: multisigConfig, - ); + final participants = Frost.getParticipants(multisigConfig: multisigConfig); final myName = participants[myNameIndex]; await _updateParticipants(participants); @@ -367,7 +354,11 @@ class BitcoinFrostWallet extends Wallet // return vSize * (feeRatePerKB / 1000).ceil(); // } - Amount _roughFeeEstimate(int inputCount, int outputCount, BigInt feeRatePerKB) { + Amount _roughFeeEstimate( + int inputCount, + int outputCount, + BigInt feeRatePerKB, + ) { return Amount( rawValue: BigInt.from( ((42 + (272 * inputCount) + (128 * outputCount)) / 4).ceil() * @@ -386,48 +377,26 @@ class BitcoinFrostWallet extends Wallet int get isarTransactionVersion => 2; @override - FilterOperation? get changeAddressFilterOperation => FilterGroup.and( - [ - FilterCondition.equalTo( - property: r"type", - value: info.mainAddressType, - ), - const FilterCondition.equalTo( - property: r"subType", - value: AddressSubType.change, - ), - const FilterCondition.equalTo( - property: r"zSafeFrost", - value: true, - ), - const FilterCondition.greaterThan( - property: r"derivationIndex", - value: 0, - ), - ], - ); + FilterOperation? get changeAddressFilterOperation => FilterGroup.and([ + FilterCondition.equalTo(property: r"type", value: info.mainAddressType), + const FilterCondition.equalTo( + property: r"subType", + value: AddressSubType.change, + ), + const FilterCondition.equalTo(property: r"zSafeFrost", value: true), + const FilterCondition.greaterThan(property: r"derivationIndex", value: 0), + ]); @override - FilterOperation? get receivingAddressFilterOperation => FilterGroup.and( - [ - FilterCondition.equalTo( - property: r"type", - value: info.mainAddressType, - ), - const FilterCondition.equalTo( - property: r"subType", - value: AddressSubType.receiving, - ), - const FilterCondition.equalTo( - property: r"zSafeFrost", - value: true, - ), - const FilterCondition.greaterThan( - property: r"derivationIndex", - value: 0, - ), - ], - ); + FilterOperation? get receivingAddressFilterOperation => FilterGroup.and([ + FilterCondition.equalTo(property: r"type", value: info.mainAddressType), + const FilterCondition.equalTo( + property: r"subType", + value: AddressSubType.receiving, + ), + const FilterCondition.equalTo(property: r"zSafeFrost", value: true), + const FilterCondition.greaterThan(property: r"derivationIndex", value: 0), + ]); @override Future updateTransactions() async { @@ -436,14 +405,16 @@ class BitcoinFrostWallet extends Wallet await _fetchAddressesForElectrumXScan(); // Separate receiving and change addresses. - final Set receivingAddresses = allAddressesOld - .where((e) => e.subType == AddressSubType.receiving) - .map((e) => e.value) - .toSet(); - final Set changeAddresses = allAddressesOld - .where((e) => e.subType == AddressSubType.change) - .map((e) => e.value) - .toSet(); + final Set receivingAddresses = + allAddressesOld + .where((e) => e.subType == AddressSubType.receiving) + .map((e) => e.value) + .toSet(); + final Set changeAddresses = + allAddressesOld + .where((e) => e.subType == AddressSubType.change) + .map((e) => e.value) + .toSet(); // Remove duplicates. final allAddressesSet = {...receivingAddresses, ...changeAddresses}; @@ -451,18 +422,20 @@ class BitcoinFrostWallet extends Wallet final currentHeight = await chainHeight; // Fetch history from ElectrumX. - final List> allTxHashes = - await _fetchHistory(allAddressesSet); + final List> allTxHashes = await _fetchHistory( + allAddressesSet, + ); final List> allTransactions = []; for (final txHash in allTxHashes) { - final storedTx = await mainDB.isar.transactionV2s - .where() - .walletIdEqualTo(walletId) - .filter() - .txidEqualTo(txHash["tx_hash"] as String) - .findFirst(); + final storedTx = + await mainDB.isar.transactionV2s + .where() + .walletIdEqualTo(walletId) + .filter() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); if (storedTx == null || !storedTx.isConfirmed( @@ -590,8 +563,9 @@ class BitcoinFrostWallet extends Wallet TransactionSubType subType = TransactionSubType.none; if (outputs.length > 1 && inputs.isNotEmpty) { for (int i = 0; i < outputs.length; i++) { - final List? scriptChunks = - outputs[i].scriptPubKeyAsm?.split(" "); + final List? scriptChunks = outputs[i].scriptPubKeyAsm?.split( + " ", + ); if (scriptChunks?.length == 2 && scriptChunks?[0] == "OP_RETURN") { final blindedPaymentCode = scriptChunks![1]; final bytes = blindedPaymentCode.toUint8ListFromHex; @@ -635,7 +609,8 @@ class BitcoinFrostWallet extends Wallet txid: txData["txid"] as String, height: txData["height"] as int?, version: txData["version"] as int, - timestamp: txData["blocktime"] as int? ?? + timestamp: + txData["blocktime"] as int? ?? DateTime.timestamp().millisecondsSinceEpoch ~/ 1000, inputs: List.unmodifiable(inputs), outputs: List.unmodifiable(outputs), @@ -698,9 +673,7 @@ class BitcoinFrostWallet extends Wallet final hex = txData.raw!; final txHash = await electrumXClient.broadcastTransaction(rawTx: hex); - Logging.instance.d( - "Sent txHash: $txHash", - ); + Logging.instance.d("Sent txHash: $txHash"); // mark utxos as used final usedUTXOs = txData.utxos!.map((e) => e.copyWith(used: true)); @@ -787,18 +760,21 @@ class BitcoinFrostWallet extends Wallet numberOfBlocksFast: f, numberOfBlocksAverage: m, numberOfBlocksSlow: s, - fast: Amount.fromDecimal( - fast, - fractionDigits: cryptoCurrency.fractionDigits, - ).raw, - medium: Amount.fromDecimal( - medium, - fractionDigits: cryptoCurrency.fractionDigits, - ).raw, - slow: Amount.fromDecimal( - slow, - fractionDigits: cryptoCurrency.fractionDigits, - ).raw, + fast: + Amount.fromDecimal( + fast, + fractionDigits: cryptoCurrency.fractionDigits, + ).raw, + medium: + Amount.fromDecimal( + medium, + fractionDigits: cryptoCurrency.fractionDigits, + ).raw, + slow: + Amount.fromDecimal( + slow, + fractionDigits: cryptoCurrency.fractionDigits, + ).raw, ); Logging.instance.i("fetched fees: $feeObject"); @@ -839,21 +815,14 @@ class BitcoinFrostWallet extends Wallet final coin = info.coin; GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.syncing, - walletId, - coin, - ), + WalletSyncStatusChangedEvent(WalletSyncStatus.syncing, walletId, coin), ); try { await refreshMutex.protect(() async { if (!isRescan) { - final salt = frost - .multisigSalt( - multisigConfig: multisigConfig!, - ) - .toHex; + final salt = + frost.multisigSalt(multisigConfig: multisigConfig!).toHex; final knownSalts = _getKnownSalts(); if (knownSalts.contains(salt)) { throw Exception("Known frost multisig salt found!"); @@ -875,20 +844,12 @@ class BitcoinFrostWallet extends Wallet const receiveChain = 0; const changeChain = 1; final List addresses})>> - receiveFutures = [ - _checkGapsLinearly( - serializedKeys, - receiveChain, - secure: true, - ), + receiveFutures = [ + _checkGapsLinearly(serializedKeys, receiveChain, secure: true), ]; final List addresses})>> - changeFutures = [ - _checkGapsLinearly( - serializedKeys, - changeChain, - secure: true, - ), + changeFutures = [ + _checkGapsLinearly(serializedKeys, changeChain, secure: true), ]; // io limitations may require running these linearly instead @@ -949,17 +910,16 @@ class BitcoinFrostWallet extends Wallet }); GlobalEventBus.instance.fire( - WalletSyncStatusChangedEvent( - WalletSyncStatus.synced, - walletId, - coin, - ), + WalletSyncStatusChangedEvent(WalletSyncStatus.synced, walletId, coin), ); unawaited(refresh()); } catch (e, s) { - Logging.instance - .f("recoverFromSerializedKeys failed: ", error: e, stackTrace: s); + Logging.instance.f( + "recoverFromSerializedKeys failed: ", + error: e, + stackTrace: s, + ); GlobalEventBus.instance.fire( WalletSyncStatusChangedEvent( WalletSyncStatus.unableToSync, @@ -978,21 +938,11 @@ class BitcoinFrostWallet extends Wallet const changeChain = 1; final List addresses})>> receiveFutures = - [ - _checkGapsLinearly( - serializedKeys, - receiveChain, - secure: false, - ), - ]; + [_checkGapsLinearly(serializedKeys, receiveChain, secure: false)]; final List addresses})>> changeFutures = [ // for legacy support secure is set to false to see // funds received on insecure addresses - _checkGapsLinearly( - serializedKeys, - changeChain, - secure: false, - ), + _checkGapsLinearly(serializedKeys, changeChain, secure: false), ]; // io limitations may require running these linearly instead @@ -1111,10 +1061,7 @@ class BitcoinFrostWallet extends Wallet rethrow; } - await info.updateCachedChainHeight( - newHeight: height, - isar: mainDB.isar, - ); + await info.updateCachedChainHeight(newHeight: height, isar: mainDB.isar); } @override @@ -1153,9 +1100,7 @@ class BitcoinFrostWallet extends Wallet for (int i = 0; i < fetchedUtxoList.length; i++) { for (int j = 0; j < fetchedUtxoList[i].length; j++) { - final utxo = await _parseUTXO( - jsonUTXO: fetchedUtxoList[i][j], - ); + final utxo = await _parseUTXO(jsonUTXO: fetchedUtxoList[i][j]); outputArray.add(utxo); } @@ -1163,8 +1108,11 @@ class BitcoinFrostWallet extends Wallet return await mainDB.updateUTXOs(walletId, outputArray); } catch (e, s) { - Logging.instance - .e("Output fetch unsuccessful: ", error: e, stackTrace: s); + Logging.instance.e( + "Output fetch unsuccessful: ", + error: e, + stackTrace: s, + ); return false; } } @@ -1172,13 +1120,9 @@ class BitcoinFrostWallet extends Wallet // =================== Secure storage ======================================== Future getSerializedKeys() async => - await secureStorageInterface.read( - key: "{$walletId}_serializedFROSTKeys", - ); + await secureStorageInterface.read(key: "{$walletId}_serializedFROSTKeys"); - Future _saveSerializedKeys( - String keys, - ) async { + Future _saveSerializedKeys(String keys) async { final current = await getSerializedKeys(); if (current == null) { @@ -1205,18 +1149,14 @@ class BitcoinFrostWallet extends Wallet ); Future getMultisigConfig() async => - await secureStorageInterface.read( - key: "{$walletId}_multisigConfig", - ); + await secureStorageInterface.read(key: "{$walletId}_multisigConfig"); Future getMultisigConfigPrevGen() async => await secureStorageInterface.read( key: "{$walletId}_multisigConfigPrevGen", ); - Future _saveMultisigConfig( - String multisigConfig, - ) async { + Future _saveMultisigConfig(String multisigConfig) async { final current = await getMultisigConfig(); if (current == null) { @@ -1248,21 +1188,16 @@ class BitcoinFrostWallet extends Wallet } } - Future _saveMultisigId( - Uint8List id, - ) async => + Future _saveMultisigId(Uint8List id) async => await secureStorageInterface.write( key: "{$walletId}_multisigIdFROST", value: id.toHex, ); - Future _recoveryString() async => await secureStorageInterface.read( - key: "{$walletId}_recoveryStringFROST", - ); + Future _recoveryString() async => + await secureStorageInterface.read(key: "{$walletId}_recoveryStringFROST"); - Future _saveRecoveryString( - String recoveryString, - ) async => + Future _saveRecoveryString(String recoveryString) async => await secureStorageInterface.write( key: "{$walletId}_recoveryStringFROST", value: recoveryString, @@ -1270,11 +1205,12 @@ class BitcoinFrostWallet extends Wallet // =================== DB ==================================================== - List _getKnownSalts() => mainDB.isar.frostWalletInfo - .where() - .walletIdEqualTo(walletId) - .knownSaltsProperty() - .findFirstSync()!; + List _getKnownSalts() => + mainDB.isar.frostWalletInfo + .where() + .walletIdEqualTo(walletId) + .knownSaltsProperty() + .findFirstSync()!; Future _updateKnownSalts(List knownSalts) async { final info = frostInfo; @@ -1287,11 +1223,12 @@ class BitcoinFrostWallet extends Wallet }); } - List _getParticipants() => mainDB.isar.frostWalletInfo - .where() - .walletIdEqualTo(walletId) - .participantsProperty() - .findFirstSync()!; + List _getParticipants() => + mainDB.isar.frostWalletInfo + .where() + .walletIdEqualTo(walletId) + .participantsProperty() + .findFirstSync()!; Future _updateParticipants(List participants) async { final info = frostInfo; @@ -1304,11 +1241,12 @@ class BitcoinFrostWallet extends Wallet }); } - int _getThreshold() => mainDB.isar.frostWalletInfo - .where() - .walletIdEqualTo(walletId) - .thresholdProperty() - .findFirstSync()!; + int _getThreshold() => + mainDB.isar.frostWalletInfo + .where() + .walletIdEqualTo(walletId) + .thresholdProperty() + .findFirstSync()!; Future _updateThreshold(int threshold) async { final info = frostInfo; @@ -1321,20 +1259,19 @@ class BitcoinFrostWallet extends Wallet }); } - String _getMyName() => mainDB.isar.frostWalletInfo - .where() - .walletIdEqualTo(walletId) - .myNameProperty() - .findFirstSync()!; + String _getMyName() => + mainDB.isar.frostWalletInfo + .where() + .walletIdEqualTo(walletId) + .myNameProperty() + .findFirstSync()!; Future _updateMyName(String myName) async { final info = frostInfo; await mainDB.isar.writeTxn(() async { await mainDB.isar.frostWalletInfo.delete(info.id); - await mainDB.isar.frostWalletInfo.put( - info.copyWith(myName: myName), - ); + await mainDB.isar.frostWalletInfo.put(info.copyWith(myName: myName)); }); } @@ -1356,20 +1293,21 @@ class BitcoinFrostWallet extends Wallet // TODO [prio=low]: Use ElectrumXInterface method. Future _updateElectrumX() async { - final failovers = nodeService - .failoverNodesFor(currency: cryptoCurrency) - .map( - (e) => ElectrumXNode( - address: e.host, - port: e.port, - name: e.name, - id: e.id, - useSSL: e.useSSL, - torEnabled: e.torEnabled, - clearnetEnabled: e.clearnetEnabled, - ), - ) - .toList(); + final failovers = + nodeService + .failoverNodesFor(currency: cryptoCurrency) + .map( + (e) => ElectrumXNode( + address: e.host, + port: e.port, + name: e.name, + id: e.id, + useSSL: e.useSSL, + torEnabled: e.torEnabled, + clearnetEnabled: e.clearnetEnabled, + ), + ) + .toList(); final newNode = await _getCurrentElectrumXNode(); try { @@ -1409,9 +1347,7 @@ class BitcoinFrostWallet extends Wallet return false; } - Future _parseUTXO({ - required Map jsonUTXO, - }) async { + Future _parseUTXO({required Map jsonUTXO}) async { final txn = await electrumXCachedClient.getTransaction( txHash: jsonUTXO["tx_hash"] as String, verbose: true, @@ -1430,7 +1366,7 @@ class BitcoinFrostWallet extends Wallet // scriptPubKey = output["scriptPubKey"]?["hex"] as String?; utxoOwnerAddress = output["scriptPubKey"]?["addresses"]?[0] as String? ?? - output["scriptPubKey"]?["address"] as String?; + output["scriptPubKey"]?["address"] as String?; } } @@ -1476,9 +1412,10 @@ class BitcoinFrostWallet extends Wallet await checkChangeAddressForTransactions(); } } catch (e, s) { - Logging.instance - .i("Exception rethrown from _checkChangeAddressForTransactions" - "($cryptoCurrency): $e\n$s"); + Logging.instance.i( + "Exception rethrown from _checkChangeAddressForTransactions" + "($cryptoCurrency): $e\n$s", + ); rethrow; } } @@ -1534,9 +1471,10 @@ class BitcoinFrostWallet extends Wallet @override Future generateNewChangeAddress() async { final current = await getCurrentChangeAddress(); - int index = current == null - ? kFrostSecureStartingIndex - : current.derivationIndex + 1; + int index = + current == null + ? kFrostSecureStartingIndex + : current.derivationIndex + 1; const chain = 1; // change address final serializedKeys = (await getSerializedKeys())!; @@ -1567,9 +1505,10 @@ class BitcoinFrostWallet extends Wallet @override Future generateNewReceivingAddress() async { final current = await getCurrentReceivingAddress(); - int index = current == null - ? kFrostSecureStartingIndex - : current.derivationIndex + 1; + int index = + current == null + ? kFrostSecureStartingIndex + : current.derivationIndex + 1; const chain = 0; // receiving address final serializedKeys = (await getSerializedKeys())!; @@ -1649,8 +1588,9 @@ class BitcoinFrostWallet extends Wallet } } - nextReceivingAddresses - .removeWhere((e) => e.derivationIndex > activeReceiveIndex); + nextReceivingAddresses.removeWhere( + (e) => e.derivationIndex > activeReceiveIndex, + ); if (nextReceivingAddresses.isNotEmpty) { await mainDB.updateOrPutAddresses(nextReceivingAddresses); await info.updateReceivingAddress( @@ -1658,8 +1598,9 @@ class BitcoinFrostWallet extends Wallet isar: mainDB.isar, ); } - nextChangeAddresses - .removeWhere((e) => e.derivationIndex > activeChangeIndex); + nextChangeAddresses.removeWhere( + (e) => e.derivationIndex > activeChangeIndex, + ); if (nextChangeAddresses.isNotEmpty) { await mainDB.updateOrPutAddresses(nextChangeAddresses); } @@ -1707,14 +1648,16 @@ class BitcoinFrostWallet extends Wallet account: account, change: change == 1, index: index, + secure: secure, ); final keys = frost.deserializeKeys(keys: serializedKeys); final addressString = frost.addressForKeys( - network: cryptoCurrency.network == CryptoCurrencyNetwork.main - ? Network.Mainnet - : Network.Testnet, + network: + cryptoCurrency.network == CryptoCurrencyNetwork.main + ? Network.Mainnet + : Network.Testnet, keys: keys, addressDerivationData: addressDerivationData, secure: secure, @@ -1726,9 +1669,10 @@ class BitcoinFrostWallet extends Wallet publicKey: cryptoCurrency.addressToPubkey(address: addressString), derivationIndex: index, derivationPath: DerivationPath()..value = "$account/$change/$index", - subType: change == 0 - ? AddressSubType.receiving - : change == 1 + subType: + change == 0 + ? AddressSubType.receiving + : change == 1 ? AddressSubType.change : AddressSubType.unknown, type: AddressType.frostMS, @@ -1770,9 +1714,7 @@ class BitcoinFrostWallet extends Wallet } // get address tx count - final count = await _fetchTxCount( - address: address, - ); + final count = await _fetchTxCount(address: address); // check and add appropriate addresses if (count > 0) { @@ -1792,25 +1734,24 @@ class BitcoinFrostWallet extends Wallet Future _fetchTxCount({required Address address}) async { final transactions = await electrumXClient.getHistory( - scripthash: cryptoCurrency.addressToScriptHash( - address: address.value, - ), + scripthash: cryptoCurrency.addressToScriptHash(address: address.value), ); return transactions.length; } Future> _fetchAddressesForElectrumXScan() async { - final allAddresses = await mainDB - .getAddresses(walletId) - .filter() - .not() - .group( - (q) => q - .typeEqualTo(AddressType.nonWallet) - .or() - .subTypeEqualTo(AddressSubType.nonWallet), - ) - .findAll(); + final allAddresses = + await mainDB + .getAddresses(walletId) + .filter() + .not() + .group( + (q) => q + .typeEqualTo(AddressType.nonWallet) + .or() + .subTypeEqualTo(AddressSubType.nonWallet), + ) + .findAll(); return allAddresses; } @@ -1839,8 +1780,11 @@ class BitcoinFrostWallet extends Wallet return allTxHashes; } catch (e, s) { - Logging.instance - .e("$runtimeType._fetchHistory: ", error: e, stackTrace: s); + Logging.instance.e( + "$runtimeType._fetchHistory: ", + error: e, + stackTrace: s, + ); rethrow; } }