Various monero fixes (#1722)
* enable autogenerate subaddress on xmr in different place fix monero_com build fix autogenerate accounts in address book * Show account number for all wallets * generate addressbook with latest addresses regardless of isAutoGenerateEnabled
cyan committed
Oct 5, 2024 at 02:30 UTC
382a0ff35ddb21b70aa1cde33cb32f258e85d02e
3 files changed
+19
-23
lib/reactions/on_current_wallet_change.dart
-5
@@ -152,11 +152,6 @@ void _setAutoGenerateSubaddressStatus(
152
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet,
153
SettingsStore settingsStore,
154
) async {
155
- final walletHasAddresses = await wallet.walletAddresses.addressesMap.length > 1;
156
- if (settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized &&
157
- walletHasAddresses) {
158
- settingsStore.autoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.disabled;
159
- }
155
wallet.isEnabledAutoGenerateSubaddress =
156
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled ||
157
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized;
lib/view_model/contact_list/contact_list_view_model.dart
+18
-18
@@ -26,22 +26,23 @@ abstract class ContactListViewModelBase with Store {
26
isAutoGenerateEnabled =
27
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled {
28
walletInfoSource.values.forEach((info) {
29
- if (isAutoGenerateEnabled && info.type == WalletType.monero && info.addressInfos != null) {
30
- final key = info.addressInfos!.keys.first;
31
- final value = info.addressInfos![key];
32
- final address = value?.first;
33
- if (address != null) {
34
- final name = _createName(info.name, address.label);
35
- walletContacts.add(WalletContact(
36
- address.address,
37
- name,
38
- walletTypeToCryptoCurrency(info.type),
39
- ));
29
+ if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) && info.addressInfos != null) {
30
+ for (var key in info.addressInfos!.keys) {
31
+ final value = info.addressInfos![key];
32
+ final address = value?.first;
33
+ if (address != null) {
34
+ final name = _createName(info.name, address.label, key: key);
35
+ walletContacts.add(WalletContact(
36
+ address.address,
37
+ name,
38
+ walletTypeToCryptoCurrency(info.type),
39
+ ));
40
+ }
41
}
42
} else if (info.addresses?.isNotEmpty == true && info.addresses!.length > 1) {
43
if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type)) {
44
final address = info.address;
44
- final name = _createName(info.name, "");
45
+ final name = _createName(info.name, "", key: 0);
46
walletContacts.add(WalletContact(
47
address,
48
name,
@@ -52,7 +53,7 @@ abstract class ContactListViewModelBase with Store {
53
if (label.isEmpty) {
54
return;
55
}
55
- final name = _createName(info.name, label);
56
+ final name = _createName(info.name, label, key: null);
57
walletContacts.add(WalletContact(
58
address,
59
name,
@@ -65,7 +66,7 @@ abstract class ContactListViewModelBase with Store {
66
} else {
67
walletContacts.add(WalletContact(
68
info.address,
68
- info.name,
69
+ _createName(info.name, "", key: [WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) ? 0 : null),
70
walletTypeToCryptoCurrency(info.type),
71
));
72
}
@@ -76,10 +77,9 @@ abstract class ContactListViewModelBase with Store {
77
initialFire: true);
78
}
79
79
- String _createName(String walletName, String label) {
80
- return label.isNotEmpty
81
- ? '$walletName (${label.replaceAll(RegExp(r'active', caseSensitive: false), S.current.active).replaceAll(RegExp(r'silent payments', caseSensitive: false), S.current.silent_payments)})'
82
- : walletName;
80
+ String _createName(String walletName, String label, {int? key = null}) {
81
+ final actualLabel = label.replaceAll(RegExp(r'active', caseSensitive: false), S.current.active).replaceAll(RegExp(r'silent payments', caseSensitive: false), S.current.silent_payments);
82
+ return '$walletName${key == null ? "" : " [#${key}]"} ${actualLabel.isNotEmpty ? "($actualLabel)" : ""}'.trim();
83
}
84
85
final bool isAutoGenerateEnabled;
tool/configure.dart
+1
@@ -84,6 +84,7 @@ import 'package:cw_core/node.dart';
84
import 'package:cw_core/output_info.dart';
85
import 'package:cw_core/pending_transaction.dart';
86
import 'package:cw_core/receive_page_option.dart';
87
+import 'package:cw_core/transaction_info.dart';
88
import 'package:cw_core/transaction_priority.dart';
89
import 'package:cw_core/unspent_coins_info.dart';
90
import 'package:cw_core/unspent_transaction_output.dart';