mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 19:49:22 +00:00
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
This commit is contained in:
parent
cc61a25cd1
commit
382a0ff35d
3 changed files with 19 additions and 23 deletions
|
@ -152,11 +152,6 @@ void _setAutoGenerateSubaddressStatus(
|
||||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet,
|
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet,
|
||||||
SettingsStore settingsStore,
|
SettingsStore settingsStore,
|
||||||
) async {
|
) async {
|
||||||
final walletHasAddresses = await wallet.walletAddresses.addressesMap.length > 1;
|
|
||||||
if (settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized &&
|
|
||||||
walletHasAddresses) {
|
|
||||||
settingsStore.autoGenerateSubaddressStatus = AutoGenerateSubaddressStatus.disabled;
|
|
||||||
}
|
|
||||||
wallet.isEnabledAutoGenerateSubaddress =
|
wallet.isEnabledAutoGenerateSubaddress =
|
||||||
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled ||
|
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled ||
|
||||||
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized;
|
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.initialized;
|
||||||
|
|
|
@ -26,22 +26,23 @@ abstract class ContactListViewModelBase with Store {
|
||||||
isAutoGenerateEnabled =
|
isAutoGenerateEnabled =
|
||||||
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled {
|
settingsStore.autoGenerateSubaddressStatus == AutoGenerateSubaddressStatus.enabled {
|
||||||
walletInfoSource.values.forEach((info) {
|
walletInfoSource.values.forEach((info) {
|
||||||
if (isAutoGenerateEnabled && info.type == WalletType.monero && info.addressInfos != null) {
|
if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) && info.addressInfos != null) {
|
||||||
final key = info.addressInfos!.keys.first;
|
for (var key in info.addressInfos!.keys) {
|
||||||
final value = info.addressInfos![key];
|
final value = info.addressInfos![key];
|
||||||
final address = value?.first;
|
final address = value?.first;
|
||||||
if (address != null) {
|
if (address != null) {
|
||||||
final name = _createName(info.name, address.label);
|
final name = _createName(info.name, address.label, key: key);
|
||||||
walletContacts.add(WalletContact(
|
walletContacts.add(WalletContact(
|
||||||
address.address,
|
address.address,
|
||||||
name,
|
name,
|
||||||
walletTypeToCryptoCurrency(info.type),
|
walletTypeToCryptoCurrency(info.type),
|
||||||
));
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (info.addresses?.isNotEmpty == true && info.addresses!.length > 1) {
|
} else if (info.addresses?.isNotEmpty == true && info.addresses!.length > 1) {
|
||||||
if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type)) {
|
if ([WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type)) {
|
||||||
final address = info.address;
|
final address = info.address;
|
||||||
final name = _createName(info.name, "");
|
final name = _createName(info.name, "", key: 0);
|
||||||
walletContacts.add(WalletContact(
|
walletContacts.add(WalletContact(
|
||||||
address,
|
address,
|
||||||
name,
|
name,
|
||||||
|
@ -52,7 +53,7 @@ abstract class ContactListViewModelBase with Store {
|
||||||
if (label.isEmpty) {
|
if (label.isEmpty) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final name = _createName(info.name, label);
|
final name = _createName(info.name, label, key: null);
|
||||||
walletContacts.add(WalletContact(
|
walletContacts.add(WalletContact(
|
||||||
address,
|
address,
|
||||||
name,
|
name,
|
||||||
|
@ -65,7 +66,7 @@ abstract class ContactListViewModelBase with Store {
|
||||||
} else {
|
} else {
|
||||||
walletContacts.add(WalletContact(
|
walletContacts.add(WalletContact(
|
||||||
info.address,
|
info.address,
|
||||||
info.name,
|
_createName(info.name, "", key: [WalletType.monero, WalletType.wownero, WalletType.haven].contains(info.type) ? 0 : null),
|
||||||
walletTypeToCryptoCurrency(info.type),
|
walletTypeToCryptoCurrency(info.type),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -76,10 +77,9 @@ abstract class ContactListViewModelBase with Store {
|
||||||
initialFire: true);
|
initialFire: true);
|
||||||
}
|
}
|
||||||
|
|
||||||
String _createName(String walletName, String label) {
|
String _createName(String walletName, String label, {int? key = null}) {
|
||||||
return label.isNotEmpty
|
final actualLabel = label.replaceAll(RegExp(r'active', caseSensitive: false), S.current.active).replaceAll(RegExp(r'silent payments', caseSensitive: false), S.current.silent_payments);
|
||||||
? '$walletName (${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();
|
||||||
: walletName;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final bool isAutoGenerateEnabled;
|
final bool isAutoGenerateEnabled;
|
||||||
|
|
|
@ -84,6 +84,7 @@ import 'package:cw_core/node.dart';
|
||||||
import 'package:cw_core/output_info.dart';
|
import 'package:cw_core/output_info.dart';
|
||||||
import 'package:cw_core/pending_transaction.dart';
|
import 'package:cw_core/pending_transaction.dart';
|
||||||
import 'package:cw_core/receive_page_option.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/transaction_priority.dart';
|
||||||
import 'package:cw_core/unspent_coins_info.dart';
|
import 'package:cw_core/unspent_coins_info.dart';
|
||||||
import 'package:cw_core/unspent_transaction_output.dart';
|
import 'package:cw_core/unspent_transaction_output.dart';
|
||||||
|
|
Loading…
Reference in a new issue