diff --git a/lib/reactions/on_current_wallet_change.dart b/lib/reactions/on_current_wallet_change.dart index 6f1ba1d8c..6630f1dfc 100644 --- a/lib/reactions/on_current_wallet_change.dart +++ b/lib/reactions/on_current_wallet_change.dart @@ -152,11 +152,6 @@ void _setAutoGenerateSubaddressStatus( WalletBase, TransactionInfo> wallet, SettingsStore settingsStore, ) async { - final walletHasAddresses = await wallet.walletAddresses.addressesMap.length > 1; - if (settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized && - walletHasAddresses) { - settingsStore.autoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.disabled; - } wallet.isEnabledAutoGenerateSubaddress = settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled || settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized; diff --git a/lib/view_model/contact_list/contact_list_view_model.dart b/lib/view_model/contact_list/contact_list_view_model.dart index df6cbdb9f..4089d988b 100644 --- a/lib/view_model/contact_list/contact_list_view_model.dart +++ b/lib/view_model/contact_list/contact_list_view_model.dart @@ -26,22 +26,23 @@ abstract class ContactListViewModelBase with Store { isAutoGenerateEnabled = settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled { walletInfoSource.values.forEach((info) { - if (isAutoGenerateEnabled && info.type == WalletType.monero && info.addressInfos != null) { - final key = info.addressInfos!.keys.first; - final value = info.addressInfos![key]; - final address = value?.first; - if (address != null) { - final name = _createName(info.name, address.label); - walletContacts.add(WalletContact( - address.address, - name, - walletTypeToCryptoCurrency(info.type), - )); + if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) && info.addressInfos != null) { + for (var key in info.addressInfos!.keys) { + final value = info.addressInfos![key]; + final address = value?.first; + if (address != null) { + final name = _createName(info.name, address.label, key: key); + walletContacts.add(WalletContact( + address.address, + name, + walletTypeToCryptoCurrency(info.type), + )); + } } } else if (info.addresses?.isNotEmpty == true && info.addresses!.length > 1) { if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type)) { final address = info.address; - final name = _createName(info.name, ""); + final name = _createName(info.name, "", key: 0); walletContacts.add(WalletContact( address, name, @@ -52,7 +53,7 @@ abstract class ContactListViewModelBase with Store { if (label.isEmpty) { return; } - final name = _createName(info.name, label); + final name = _createName(info.name, label, key: null); walletContacts.add(WalletContact( address, name, @@ -65,7 +66,7 @@ abstract class ContactListViewModelBase with Store { } else { walletContacts.add(WalletContact( info.address, - info.name, + _createName(info.name, "", key: [WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) ? 0 : null), walletTypeToCryptoCurrency(info.type), )); } @@ -76,10 +77,9 @@ abstract class ContactListViewModelBase with Store { initialFire: true); } - String _createName(String walletName, String label) { - return label.isNotEmpty - ? '$walletName (${label.replaceAll(RegExp(r'active', caseSensitive: false), S.current.active).replaceAll(RegExp(r'silent payments', caseSensitive: false), S.current.silent_payments)})' - : walletName; + String _createName(String walletName, String label, {int? key = null}) { + final actualLabel = label.replaceAll(RegExp(r'active', caseSensitive: false), S.current.active).replaceAll(RegExp(r'silent payments', caseSensitive: false), S.current.silent_payments); + return '$walletName${key == null ? "" : " [#${key}]"} ${actualLabel.isNotEmpty ? "($actualLabel)" : ""}'.trim(); } final bool isAutoGenerateEnabled; diff --git a/tool/configure.dart b/tool/configure.dart index c3d84c4f6..0c0f491a5 100644 --- a/tool/configure.dart +++ b/tool/configure.dart @@ -84,6 +84,7 @@ import 'package:cw_core/node.dart'; import 'package:cw_core/output_info.dart'; import 'package:cw_core/pending_transaction.dart'; import 'package:cw_core/receive_page_option.dart'; +import 'package:cw_core/transaction_info.dart'; import 'package:cw_core/transaction_priority.dart'; import 'package:cw_core/unspent_coins_info.dart'; import 'package:cw_core/unspent_transaction_output.dart';