From 82f64a42642516d1abed58c12be4018129c6e813 Mon Sep 17 00:00:00 2001 From: Omar Hatem Date: Thu, 29 Aug 2024 00:52:11 +0300 Subject: [PATCH] revert subaddress fix (#1656) add show/hide passphrase --- cw_monero/lib/api/transaction_history.dart | 27 ++-------- cw_monero/lib/monero_subaddress_list.dart | 9 ++-- cw_monero/lib/monero_wallet.dart | 5 -- cw_monero/lib/monero_wallet_addresses.dart | 20 -------- cw_wownero/lib/api/transaction_history.dart | 23 ++------- cw_wownero/lib/wownero_subaddress_list.dart | 4 -- cw_wownero/lib/wownero_wallet.dart | 6 --- cw_wownero/lib/wownero_wallet_addresses.dart | 18 ------- .../advanced_privacy_settings_page.dart | 51 +++++++++++-------- scripts/android/app_env.sh | 4 +- scripts/ios/app_env.sh | 4 +- scripts/linux/app_env.sh | 2 +- scripts/macos/app_env.sh | 4 +- 13 files changed, 51 insertions(+), 126 deletions(-) diff --git a/cw_monero/lib/api/transaction_history.dart b/cw_monero/lib/api/transaction_history.dart index 1f00b082f..b416e1b4e 100644 --- a/cw_monero/lib/api/transaction_history.dart +++ b/cw_monero/lib/api/transaction_history.dart @@ -45,8 +45,6 @@ List getAllTransactions() { confirmations: 0, blockheight: 0, accountIndex: i, - addressIndex: 0, - addressIndexList: [0], paymentId: "", amount: fullBalance - availBalance, isSpend: false, @@ -247,30 +245,19 @@ Future createTransactionMultDest( class Transaction { final String displayLabel; - String get subaddressLabel => monero.Wallet_getSubaddressLabel( + String subaddressLabel = monero.Wallet_getSubaddressLabel(wptr!, accountIndex: 0, addressIndex: 0); + late final String address = monero.Wallet_address( wptr!, - accountIndex: accountIndex, - addressIndex: addressIndex, + accountIndex: 0, + addressIndex: 0, ); - String get address => monero.Wallet_address( - wptr!, - accountIndex: accountIndex, - addressIndex: addressIndex, - ); - List get addressList => List.generate(addressIndexList.length, (index) => - monero.Wallet_address( - wptr!, - accountIndex: accountIndex, - addressIndex: addressIndexList[index], - )); final String description; final int fee; final int confirmations; late final bool isPending = confirmations < 10; final int blockheight; - final int addressIndex; + final int addressIndex = 0; final int accountIndex; - final List addressIndexList; final String paymentId; final int amount; final bool isSpend; @@ -316,8 +303,6 @@ class Transaction { amount = monero.TransactionInfo_amount(txInfo), paymentId = monero.TransactionInfo_paymentId(txInfo), accountIndex = monero.TransactionInfo_subaddrAccount(txInfo), - addressIndex = int.tryParse(monero.TransactionInfo_subaddrIndex(txInfo).split(", ")[0]) ?? 0, - addressIndexList = monero.TransactionInfo_subaddrIndex(txInfo).split(", ").map((e) => int.tryParse(e) ?? 0).toList(), blockheight = monero.TransactionInfo_blockHeight(txInfo), confirmations = monero.TransactionInfo_confirmations(txInfo), fee = monero.TransactionInfo_fee(txInfo), @@ -331,8 +316,6 @@ class Transaction { required this.confirmations, required this.blockheight, required this.accountIndex, - required this.addressIndexList, - required this.addressIndex, required this.paymentId, required this.amount, required this.isSpend, diff --git a/cw_monero/lib/monero_subaddress_list.dart b/cw_monero/lib/monero_subaddress_list.dart index fe85bef3b..c35afb282 100644 --- a/cw_monero/lib/monero_subaddress_list.dart +++ b/cw_monero/lib/monero_subaddress_list.dart @@ -1,7 +1,6 @@ import 'package:cw_core/subaddress.dart'; import 'package:cw_monero/api/coins_info.dart'; import 'package:cw_monero/api/subaddress_list.dart' as subaddress_list; -import 'package:cw_monero/api/wallet.dart'; import 'package:flutter/services.dart'; import 'package:mobx/mobx.dart'; @@ -104,9 +103,6 @@ abstract class MoneroSubaddressListBase with Store { required List usedAddresses, }) async { _usedAddresses.addAll(usedAddresses); - final _all = _usedAddresses.toSet().toList(); - _usedAddresses.clear(); - _usedAddresses.addAll(_all); if (_isUpdating) { return; } @@ -128,7 +124,7 @@ abstract class MoneroSubaddressListBase with Store { Future> _getAllUnusedAddresses( {required int accountIndex, required String label}) async { final allAddresses = subaddress_list.getAllSubaddresses(); - if (allAddresses.isEmpty || _usedAddresses.contains(allAddresses.first.address)) { + if (allAddresses.isEmpty || _usedAddresses.contains(allAddresses.last)) { final isAddressUnused = await _newSubaddress(accountIndex: accountIndex, label: label); if (!isAddressUnused) { return await _getAllUnusedAddresses(accountIndex: accountIndex, label: label); @@ -147,7 +143,8 @@ abstract class MoneroSubaddressListBase with Store { label.toLowerCase() == 'Primary account'.toLowerCase() ? 'Primary address' : label); - }).toList().reversed.toList(); + }) + .toList(); } Future _newSubaddress({required int accountIndex, required String label}) async { diff --git a/cw_monero/lib/monero_wallet.dart b/cw_monero/lib/monero_wallet.dart index 8dc3fdf86..8773d694d 100644 --- a/cw_monero/lib/monero_wallet.dart +++ b/cw_monero/lib/monero_wallet.dart @@ -86,9 +86,6 @@ abstract class MoneroWalletBase extends WalletBase isEnabledAutoGenerateSubaddress, (bool enabled) { _updateSubAddress(enabled, account: walletAddresses.account); }); - _onTxHistoryChangeReaction = reaction((_) => transactionHistory, (__) { - _updateSubAddress(isEnabledAutoGenerateSubaddress, account: walletAddresses.account); - }); } static const int _autoSaveInterval = 30; @@ -131,7 +128,6 @@ abstract class MoneroWalletBase extends WalletBase get usedAddresses { - final txs = getAllTransactions(); - final adds = _originalUsedAddresses.toList(); - for (var i = 0; i < txs.length; i++) { - for (var j = 0; j < txs[i].addressList.length; j++) { - adds.add(txs[i].addressList[j]); - } - } - return adds.toSet(); - } - - Set _originalUsedAddresses = Set(); - - @override - set usedAddresses(Set _usedAddresses) { - _originalUsedAddresses = _usedAddresses; - } - @override Future init() async { accountList.update(); diff --git a/cw_wownero/lib/api/transaction_history.dart b/cw_wownero/lib/api/transaction_history.dart index 020c47df6..a1e1e3c9b 100644 --- a/cw_wownero/lib/api/transaction_history.dart +++ b/cw_wownero/lib/api/transaction_history.dart @@ -45,8 +45,6 @@ List getAllTransactions() { confirmations: 0, blockheight: 0, accountIndex: i, - addressIndex: 0, - addressIndexList: [0], paymentId: "", amount: fullBalance - availBalance, isSpend: false, @@ -245,26 +243,19 @@ Future createTransactionMultDest( class Transaction { final String displayLabel; - String get subaddressLabel => wownero.Wallet_getSubaddressLabel(wptr!, accountIndex: 0, addressIndex: 0); - String get address => wownero.Wallet_address( + String subaddressLabel = wownero.Wallet_getSubaddressLabel(wptr!, accountIndex: 0, addressIndex: 0); + late final String address = wownero.Wallet_address( wptr!, - accountIndex: accountIndex, - addressIndex: addressIndex, + accountIndex: 0, + addressIndex: 0, ); - List get addressList => List.generate(addressIndexList.length, (index) => - wownero.Wallet_address( - wptr!, - accountIndex: accountIndex, - addressIndex: addressIndexList[index], - )); final String description; final int fee; final int confirmations; late final bool isPending = confirmations < 3; final int blockheight; - final int addressIndex; + final int addressIndex = 0; final int accountIndex; - final List addressIndexList; final String paymentId; final int amount; final bool isSpend; @@ -310,8 +301,6 @@ class Transaction { amount = wownero.TransactionInfo_amount(txInfo), paymentId = wownero.TransactionInfo_paymentId(txInfo), accountIndex = wownero.TransactionInfo_subaddrAccount(txInfo), - addressIndex = int.tryParse(wownero.TransactionInfo_subaddrIndex(txInfo).split(", ")[0]) ?? 0, - addressIndexList = wownero.TransactionInfo_subaddrIndex(txInfo).split(", ").map((e) => int.tryParse(e) ?? 0).toList(), blockheight = wownero.TransactionInfo_blockHeight(txInfo), confirmations = wownero.TransactionInfo_confirmations(txInfo), fee = wownero.TransactionInfo_fee(txInfo), @@ -325,8 +314,6 @@ class Transaction { required this.confirmations, required this.blockheight, required this.accountIndex, - required this.addressIndex, - required this.addressIndexList, required this.paymentId, required this.amount, required this.isSpend, diff --git a/cw_wownero/lib/wownero_subaddress_list.dart b/cw_wownero/lib/wownero_subaddress_list.dart index 5c026cc86..61fd09ef9 100644 --- a/cw_wownero/lib/wownero_subaddress_list.dart +++ b/cw_wownero/lib/wownero_subaddress_list.dart @@ -1,7 +1,6 @@ import 'package:cw_core/subaddress.dart'; import 'package:cw_wownero/api/coins_info.dart'; import 'package:cw_wownero/api/subaddress_list.dart' as subaddress_list; -import 'package:cw_wownero/api/wallet.dart'; import 'package:flutter/services.dart'; import 'package:mobx/mobx.dart'; @@ -104,9 +103,6 @@ abstract class WowneroSubaddressListBase with Store { required List usedAddresses, }) async { _usedAddresses.addAll(usedAddresses); - final _all = _usedAddresses.toSet().toList(); - _usedAddresses.clear(); - _usedAddresses.addAll(_all); if (_isUpdating) { return; } diff --git a/cw_wownero/lib/wownero_wallet.dart b/cw_wownero/lib/wownero_wallet.dart index ab7691dd6..c3f4bcb69 100644 --- a/cw_wownero/lib/wownero_wallet.dart +++ b/cw_wownero/lib/wownero_wallet.dart @@ -82,10 +82,6 @@ abstract class WowneroWalletBase reaction((_) => isEnabledAutoGenerateSubaddress, (bool enabled) { _updateSubAddress(enabled, account: walletAddresses.account); }); - - _onTxHistoryChangeReaction = reaction((_) => transactionHistory, (__) { - _updateSubAddress(isEnabledAutoGenerateSubaddress, account: walletAddresses.account); - }); } static const int _autoSaveInterval = 30; @@ -127,7 +123,6 @@ abstract class WowneroWalletBase wownero_wallet.SyncListener? _listener; ReactionDisposer? _onAccountChangeReaction; - ReactionDisposer? _onTxHistoryChangeReaction; bool _isTransactionUpdating; bool _hasSyncAfterStartup; Timer? _autoSaveTimer; @@ -163,7 +158,6 @@ abstract class WowneroWalletBase void close() async { _listener?.stop(); _onAccountChangeReaction?.reaction.dispose(); - _onTxHistoryChangeReaction?.reaction.dispose(); _autoSaveTimer?.cancel(); } diff --git a/cw_wownero/lib/wownero_wallet_addresses.dart b/cw_wownero/lib/wownero_wallet_addresses.dart index b36c0e9ec..9eeb182eb 100644 --- a/cw_wownero/lib/wownero_wallet_addresses.dart +++ b/cw_wownero/lib/wownero_wallet_addresses.dart @@ -3,7 +3,6 @@ import 'package:cw_core/address_info.dart'; import 'package:cw_core/subaddress.dart'; import 'package:cw_core/wallet_addresses.dart'; import 'package:cw_core/wallet_info.dart'; -import 'package:cw_wownero/api/transaction_history.dart'; import 'package:cw_wownero/api/wallet.dart'; import 'package:cw_wownero/wownero_account_list.dart'; import 'package:cw_wownero/wownero_subaddress_list.dart'; @@ -37,24 +36,7 @@ abstract class WowneroWalletAddressesBase extends WalletAddresses with Store { WowneroSubaddressList subaddressList; WowneroAccountList accountList; - @override - Set get usedAddresses { - final txs = getAllTransactions(); - final adds = _originalUsedAddresses.toList(); - for (var i = 0; i < txs.length; i++) { - for (var j = 0; j < txs[i].addressList.length; j++) { - adds.add(txs[i].addressList[j]); - } - } - return adds.toSet(); - } - Set _originalUsedAddresses = Set(); - - @override - set usedAddresses(Set _usedAddresses) { - _originalUsedAddresses = _usedAddresses; - } @override Future init() async { accountList.update(); diff --git a/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart b/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart index ff8ec3dd2..7173778cc 100644 --- a/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart +++ b/lib/src/screens/new_wallet/advanced_privacy_settings_page.dart @@ -70,6 +70,8 @@ class _AdvancedPrivacySettingsBodyState extends State<_AdvancedPrivacySettingsBo final _formKey = GlobalKey(); bool? testnetValue; + bool obscurePassphrase = true; + @override void initState() { passphraseController.text = widget.seedTypeViewModel.passphrase ?? ''; @@ -138,27 +140,36 @@ class _AdvancedPrivacySettingsBodyState extends State<_AdvancedPrivacySettingsBo ); }), if (!widget.isFromRestore) ...[ - Observer(builder: (_) { - if (widget.privacySettingsViewModel.hasSeedPhraseLengthOption) - return SettingsPickerCell( - title: S.current.seed_phrase_length, - items: SeedPhraseLength.values, - selectedItem: widget.privacySettingsViewModel.seedPhraseLength, - onItemSelected: (SeedPhraseLength length) { - widget.privacySettingsViewModel.setSeedPhraseLength(length); - }, - ); - return Container(); - }), - if (widget.privacySettingsViewModel.hasPassphraseOption) - Padding( - padding: EdgeInsets.all(24), - child: BaseTextFormField( - hintText: S.current.passphrase, - controller: passphraseController, - obscureText: true, + Observer(builder: (_) { + if (widget.privacySettingsViewModel.hasSeedPhraseLengthOption) + return SettingsPickerCell( + title: S.current.seed_phrase_length, + items: SeedPhraseLength.values, + selectedItem: widget.privacySettingsViewModel.seedPhraseLength, + onItemSelected: (SeedPhraseLength length) { + widget.privacySettingsViewModel.setSeedPhraseLength(length); + }, + ); + return Container(); + }), + if (widget.privacySettingsViewModel.hasPassphraseOption) + Padding( + padding: EdgeInsets.all(24), + child: BaseTextFormField( + hintText: S.current.passphrase, + controller: passphraseController, + obscureText: obscurePassphrase, + suffixIcon: GestureDetector( + onTap: () => setState(() { + obscurePassphrase = !obscurePassphrase; + }), + child: Icon( + Icons.remove_red_eye, + color: obscurePassphrase ? Colors.black54 : Colors.black26, + ), + ), + ), ), - ), ], Observer(builder: (_) { return Column( diff --git a/scripts/android/app_env.sh b/scripts/android/app_env.sh index 59919dcf8..a60077e82 100644 --- a/scripts/android/app_env.sh +++ b/scripts/android/app_env.sh @@ -16,14 +16,14 @@ APP_ANDROID_TYPE=$1 MONERO_COM_NAME="Monero.com" MONERO_COM_VERSION="1.16.5" -MONERO_COM_BUILD_NUMBER=99 +MONERO_COM_BUILD_NUMBER=100 MONERO_COM_BUNDLE_ID="com.monero.app" MONERO_COM_PACKAGE="com.monero.app" MONERO_COM_SCHEME="monero.com" CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_VERSION="4.19.5" -CAKEWALLET_BUILD_NUMBER=226 +CAKEWALLET_BUILD_NUMBER=227 CAKEWALLET_BUNDLE_ID="com.cakewallet.cake_wallet" CAKEWALLET_PACKAGE="com.cakewallet.cake_wallet" CAKEWALLET_SCHEME="cakewallet" diff --git a/scripts/ios/app_env.sh b/scripts/ios/app_env.sh index 70530f4e6..9df4b685e 100644 --- a/scripts/ios/app_env.sh +++ b/scripts/ios/app_env.sh @@ -14,12 +14,12 @@ APP_IOS_TYPE=$1 MONERO_COM_NAME="Monero.com" MONERO_COM_VERSION="1.16.5" -MONERO_COM_BUILD_NUMBER=97 +MONERO_COM_BUILD_NUMBER=98 MONERO_COM_BUNDLE_ID="com.cakewallet.monero" CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_VERSION="4.19.5" -CAKEWALLET_BUILD_NUMBER=264 +CAKEWALLET_BUILD_NUMBER=266 CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" HAVEN_NAME="Haven" diff --git a/scripts/linux/app_env.sh b/scripts/linux/app_env.sh index 7f1b11f3f..1c89c6e8a 100755 --- a/scripts/linux/app_env.sh +++ b/scripts/linux/app_env.sh @@ -15,7 +15,7 @@ fi CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_VERSION="1.9.5" -CAKEWALLET_BUILD_NUMBER=32 +CAKEWALLET_BUILD_NUMBER=33 if ! [[ " ${TYPES[*]} " =~ " ${APP_LINUX_TYPE} " ]]; then echo "Wrong app type." diff --git a/scripts/macos/app_env.sh b/scripts/macos/app_env.sh index 165feafe1..a6afac2cb 100755 --- a/scripts/macos/app_env.sh +++ b/scripts/macos/app_env.sh @@ -17,12 +17,12 @@ fi MONERO_COM_NAME="Monero.com" MONERO_COM_VERSION="1.6.5" -MONERO_COM_BUILD_NUMBER=30 +MONERO_COM_BUILD_NUMBER=31 MONERO_COM_BUNDLE_ID="com.cakewallet.monero" CAKEWALLET_NAME="Cake Wallet" CAKEWALLET_VERSION="1.12.5" -CAKEWALLET_BUILD_NUMBER=86 +CAKEWALLET_BUILD_NUMBER=88 CAKEWALLET_BUNDLE_ID="com.fotolockr.cakewallet" if ! [[ " ${TYPES[*]} " =~ " ${APP_MACOS_TYPE} " ]]; then