mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-01 12:04:21 +01:00
Merge branch 'main' into CW-621-Open-external-sites-in-default-browser
This commit is contained in:
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
import 'package:cake_wallet/entities/auto_generate_subaddress_status.dart';
|
||||
import 'package:cake_wallet/entities/contact_base.dart';
|
||||
import 'package:cake_wallet/entities/wallet_contact.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cw_core/wallet_info.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
@@ -40,16 +41,19 @@ abstract class ContactListViewModelBase with Store {
|
||||
});
|
||||
} else if (info.addresses?.isNotEmpty == true) {
|
||||
info.addresses!.forEach((address, label) {
|
||||
if (label.isEmpty) {
|
||||
return;
|
||||
}
|
||||
final name = _createName(info.name, label);
|
||||
walletContacts.add(WalletContact(
|
||||
address,
|
||||
name,
|
||||
walletTypeToCryptoCurrency(info.type),
|
||||
walletTypeToCryptoCurrency(info.type,
|
||||
isTestnet:
|
||||
info.network == null ? false : info.network!.toLowerCase().contains("testnet")),
|
||||
));
|
||||
// Only one contact address per wallet
|
||||
return;
|
||||
});
|
||||
} else if (info.address != null) {
|
||||
} else {
|
||||
walletContacts.add(WalletContact(
|
||||
info.address,
|
||||
info.name,
|
||||
@@ -64,7 +68,9 @@ abstract class ContactListViewModelBase with Store {
|
||||
}
|
||||
|
||||
String _createName(String walletName, String label) {
|
||||
return label.isNotEmpty ? '$walletName ($label)' : walletName;
|
||||
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;
|
||||
}
|
||||
|
||||
final bool isAutoGenerateEnabled;
|
||||
|
||||
@@ -60,6 +60,9 @@ abstract class BalanceViewModelBase with Store {
|
||||
@observable
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet;
|
||||
|
||||
@computed
|
||||
bool get hasSilentPayments => wallet.type == WalletType.bitcoin;
|
||||
|
||||
@computed
|
||||
double get price {
|
||||
final price = fiatConvertationStore.prices[appStore.wallet!.currency];
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:cake_wallet/ionia/ionia_service.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'cake_features_view_model.g.dart';
|
||||
|
||||
class CakeFeaturesViewModel = CakeFeaturesViewModelBase with _$CakeFeaturesViewModel;
|
||||
|
||||
abstract class CakeFeaturesViewModelBase with Store {
|
||||
final IoniaService _ioniaService;
|
||||
|
||||
CakeFeaturesViewModelBase(this._ioniaService);
|
||||
|
||||
Future<bool> isIoniaUserAuthenticated() async {
|
||||
return await _ioniaService.isLogined();
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:eth_sig_util/util/utils.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@@ -201,6 +202,14 @@ abstract class DashboardViewModelBase with Store {
|
||||
|
||||
return true;
|
||||
});
|
||||
|
||||
if (hasSilentPayments) {
|
||||
silentPaymentsScanningActive = bitcoin!.getScanningActive(wallet);
|
||||
|
||||
reaction((_) => wallet.syncStatus, (SyncStatus syncStatus) {
|
||||
silentPaymentsScanningActive = bitcoin!.getScanningActive(wallet);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@observable
|
||||
@@ -287,11 +296,36 @@ abstract class DashboardViewModelBase with Store {
|
||||
@observable
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>, TransactionInfo> wallet;
|
||||
|
||||
bool get hasRescan => wallet.type == WalletType.monero || wallet.type == WalletType.haven;
|
||||
@computed
|
||||
bool get isTestnet => wallet.type == WalletType.bitcoin && bitcoin!.isTestnet(wallet);
|
||||
|
||||
@computed
|
||||
bool get hasRescan =>
|
||||
wallet.type == WalletType.bitcoin ||
|
||||
wallet.type == WalletType.monero ||
|
||||
wallet.type == WalletType.haven;
|
||||
|
||||
@computed
|
||||
bool get hasSilentPayments => wallet.type == WalletType.bitcoin;
|
||||
|
||||
@computed
|
||||
bool get showSilentPaymentsCard => hasSilentPayments && settingsStore.silentPaymentsCardDisplay;
|
||||
|
||||
final KeyService keyService;
|
||||
final SharedPreferences sharedPreferences;
|
||||
|
||||
@observable
|
||||
bool silentPaymentsScanningActive = false;
|
||||
|
||||
@action
|
||||
void setSilentPaymentsScanning(bool active) {
|
||||
silentPaymentsScanningActive = active;
|
||||
|
||||
if (hasSilentPayments) {
|
||||
bitcoin!.setScanningActive(wallet, active);
|
||||
}
|
||||
}
|
||||
|
||||
BalanceViewModel balanceViewModel;
|
||||
|
||||
AppStore appStore;
|
||||
@@ -535,24 +569,29 @@ abstract class DashboardViewModelBase with Store {
|
||||
|
||||
Future<ServicesResponse> getServicesStatus() async {
|
||||
try {
|
||||
final res = await http.get(Uri.parse("https://service-api.cakewallet.com/v1/active-notices"));
|
||||
if (isEnabledBulletinAction) {
|
||||
final res = await http.get(Uri.parse("https://service-api.cakewallet.com/v1/active-notices"));
|
||||
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
throw res.body;
|
||||
if (res.statusCode < 200 || res.statusCode >= 300) {
|
||||
throw res.body;
|
||||
}
|
||||
|
||||
final oldSha = sharedPreferences.getString(PreferencesKey.serviceStatusShaKey);
|
||||
|
||||
final hash = await Cryptography.instance.sha256().hash(utf8.encode(res.body));
|
||||
final currentSha = bytesToHex(hash.bytes);
|
||||
|
||||
final hasUpdates = oldSha != currentSha;
|
||||
|
||||
return ServicesResponse.fromJson(
|
||||
json.decode(res.body) as Map<String, dynamic>,
|
||||
hasUpdates,
|
||||
currentSha,
|
||||
);
|
||||
}
|
||||
|
||||
final oldSha = sharedPreferences.getString(PreferencesKey.serviceStatusShaKey);
|
||||
|
||||
final hash = await Cryptography.instance.sha256().hash(utf8.encode(res.body));
|
||||
final currentSha = bytesToHex(hash.bytes);
|
||||
|
||||
final hasUpdates = oldSha != currentSha;
|
||||
|
||||
return ServicesResponse.fromJson(
|
||||
json.decode(res.body) as Map<String, dynamic>,
|
||||
hasUpdates,
|
||||
currentSha,
|
||||
);
|
||||
else {
|
||||
return ServicesResponse([], false, '');
|
||||
}
|
||||
} catch (_) {
|
||||
return ServicesResponse([], false, '');
|
||||
}
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import 'package:cake_wallet/ionia/ionia_service.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'market_place_view_model.g.dart';
|
||||
|
||||
class MarketPlaceViewModel = MarketPlaceViewModelBase with _$MarketPlaceViewModel;
|
||||
|
||||
abstract class MarketPlaceViewModelBase with Store {
|
||||
final IoniaService _ioniaService;
|
||||
|
||||
MarketPlaceViewModelBase(this._ioniaService);
|
||||
|
||||
|
||||
Future<bool> isIoniaUserAuthenticated() async {
|
||||
return await _ioniaService.isLogined();
|
||||
}
|
||||
}
|
||||
@@ -154,11 +154,11 @@ abstract class ExchangeViewModelBase extends WalletChangeListenerViewModel with
|
||||
ChangeNowExchangeProvider(settingsStore: _settingsStore),
|
||||
SideShiftExchangeProvider(),
|
||||
SimpleSwapExchangeProvider(),
|
||||
TrocadorExchangeProvider(
|
||||
useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates),
|
||||
ThorChainExchangeProvider(tradesStore: trades),
|
||||
if (FeatureFlag.isExolixEnabled) ExolixExchangeProvider(),
|
||||
QuantexExchangeProvider(),
|
||||
TrocadorExchangeProvider(
|
||||
useTorOnly: _useTorOnly, providerStates: _settingsStore.trocadorProviderStates),
|
||||
];
|
||||
|
||||
@observable
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'rescan_view_model.g.dart';
|
||||
@@ -8,11 +10,12 @@ class RescanViewModel = RescanViewModelBase with _$RescanViewModel;
|
||||
enum RescanWalletState { rescaning, none }
|
||||
|
||||
abstract class RescanViewModelBase with Store {
|
||||
RescanViewModelBase(this._wallet)
|
||||
: state = RescanWalletState.none,
|
||||
isButtonEnabled = false;
|
||||
RescanViewModelBase(this.wallet)
|
||||
: state = RescanWalletState.none,
|
||||
isButtonEnabled = false,
|
||||
doSingleScan = false;
|
||||
|
||||
final WalletBase _wallet;
|
||||
final WalletBase wallet;
|
||||
|
||||
@observable
|
||||
RescanWalletState state;
|
||||
@@ -20,11 +23,21 @@ abstract class RescanViewModelBase with Store {
|
||||
@observable
|
||||
bool isButtonEnabled;
|
||||
|
||||
@observable
|
||||
bool doSingleScan;
|
||||
|
||||
@computed
|
||||
bool get isSilentPaymentsScan => wallet.type == WalletType.bitcoin;
|
||||
|
||||
@action
|
||||
Future<void> rescanCurrentWallet({required int restoreHeight}) async {
|
||||
state = RescanWalletState.rescaning;
|
||||
await _wallet.rescan(height: restoreHeight);
|
||||
_wallet.transactionHistory.clear();
|
||||
if (wallet.type != WalletType.bitcoin) {
|
||||
wallet.rescan(height: restoreHeight);
|
||||
wallet.transactionHistory.clear();
|
||||
} else {
|
||||
bitcoin!.rescan(wallet, height: restoreHeight, doSingleScan: doSingleScan);
|
||||
}
|
||||
state = RescanWalletState.none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,8 +139,7 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
String get pendingTransactionFeeFiatAmount {
|
||||
try {
|
||||
if (pendingTransaction != null) {
|
||||
final currency =
|
||||
isEVMCompatibleChain(walletType) ? wallet.currency : selectedCryptoCurrency;
|
||||
final currency = pendingTransactionFeeCurrency(walletType);
|
||||
final fiat = calculateFiatAmount(
|
||||
price: _fiatConversationStore.prices[currency]!,
|
||||
cryptoAmount: pendingTransaction!.feeFormatted);
|
||||
@@ -153,6 +152,18 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
}
|
||||
}
|
||||
|
||||
CryptoCurrency pendingTransactionFeeCurrency(WalletType type) {
|
||||
switch (type) {
|
||||
case WalletType.ethereum:
|
||||
case WalletType.polygon:
|
||||
case WalletType.tron:
|
||||
case WalletType.solana:
|
||||
return wallet.currency;
|
||||
default:
|
||||
return selectedCryptoCurrency;
|
||||
}
|
||||
}
|
||||
|
||||
FiatCurrency get fiat => _settingsStore.fiatCurrency;
|
||||
|
||||
TransactionPriority get transactionPriority {
|
||||
@@ -218,7 +229,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
isFiatDisabled ? '' : pendingTransactionFeeFiatAmount + ' ' + fiat.title;
|
||||
|
||||
@computed
|
||||
bool get isReadyForSend => wallet.syncStatus is SyncedSyncStatus;
|
||||
bool get isReadyForSend =>
|
||||
wallet.syncStatus is SyncedSyncStatus ||
|
||||
// If silent payments scanning, can still send payments
|
||||
(wallet.type == WalletType.bitcoin && wallet.syncStatus is SyncingSyncStatus);
|
||||
|
||||
@computed
|
||||
List<Template> get templates => sendTemplateViewModel.templates
|
||||
@@ -588,6 +602,10 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
walletType == WalletType.litecoin ||
|
||||
walletType == WalletType.bitcoinCash) {
|
||||
if (error is TransactionWrongBalanceException) {
|
||||
if (error.amount != null)
|
||||
return S.current
|
||||
.tx_wrong_balance_with_amount_exception(currency.toString(), error.amount.toString());
|
||||
|
||||
return S.current.tx_wrong_balance_exception(currency.toString());
|
||||
}
|
||||
if (error is TransactionNoInputsException) {
|
||||
@@ -614,9 +632,15 @@ abstract class SendViewModelBase extends WalletChangeListenerViewModel with Stor
|
||||
if (error is TransactionCommitFailedVoutNegative) {
|
||||
return S.current.tx_rejected_vout_negative;
|
||||
}
|
||||
if (error is TransactionCommitFailedBIP68Final) {
|
||||
return S.current.tx_rejected_bip68_final;
|
||||
}
|
||||
if (error is TransactionNoDustOnChangeException) {
|
||||
return S.current.tx_commit_exception_no_dust_on_change(error.min, error.max);
|
||||
}
|
||||
if (error is TransactionInputNotSupported) {
|
||||
return S.current.tx_invalid_input;
|
||||
}
|
||||
}
|
||||
|
||||
return errorMessage;
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'silent_payments_settings_view_model.g.dart';
|
||||
|
||||
class SilentPaymentsSettingsViewModel = SilentPaymentsSettingsViewModelBase
|
||||
with _$SilentPaymentsSettingsViewModel;
|
||||
|
||||
abstract class SilentPaymentsSettingsViewModelBase with Store {
|
||||
SilentPaymentsSettingsViewModelBase(this._settingsStore, this._wallet);
|
||||
|
||||
final SettingsStore _settingsStore;
|
||||
final WalletBase _wallet;
|
||||
|
||||
@computed
|
||||
bool get silentPaymentsCardDisplay => _settingsStore.silentPaymentsCardDisplay;
|
||||
|
||||
@computed
|
||||
bool get silentPaymentsAlwaysScan => _settingsStore.silentPaymentsAlwaysScan;
|
||||
|
||||
@action
|
||||
void setSilentPaymentsCardDisplay(bool value) {
|
||||
_settingsStore.silentPaymentsCardDisplay = value;
|
||||
}
|
||||
|
||||
@action
|
||||
void setSilentPaymentsAlwaysScan(bool value) {
|
||||
_settingsStore.silentPaymentsAlwaysScan = value;
|
||||
if (value) bitcoin!.setScanningActive(_wallet, true);
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,8 @@ abstract class UnspentCoinsItemBase with Store {
|
||||
required this.isChange,
|
||||
required this.amountRaw,
|
||||
required this.vout,
|
||||
required this.keyImage
|
||||
required this.keyImage,
|
||||
required this.isSilentPayment,
|
||||
});
|
||||
|
||||
@observable
|
||||
@@ -47,4 +48,7 @@ abstract class UnspentCoinsItemBase with Store {
|
||||
|
||||
@observable
|
||||
String? keyImage;
|
||||
|
||||
@observable
|
||||
bool isSilentPayment;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/utils/exception_handler.dart';
|
||||
import 'package:cake_wallet/view_model/unspent_coins/unspent_coins_item.dart';
|
||||
import 'package:cw_core/unspent_coins_info.dart';
|
||||
import 'package:cw_core/unspent_transaction_output.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:hive/hive.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
@@ -86,22 +88,33 @@ abstract class UnspentCoinsListViewModelBase with Store {
|
||||
@action
|
||||
void _updateUnspentCoinsInfo() {
|
||||
_items.clear();
|
||||
_items.addAll(_getUnspents().map((elem) {
|
||||
final info =
|
||||
getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
|
||||
|
||||
return UnspentCoinsItem(
|
||||
address: elem.address,
|
||||
amount: '${formatAmountToString(elem.value)} ${wallet.currency.title}',
|
||||
hash: elem.hash,
|
||||
isFrozen: info.isFrozen,
|
||||
note: info.note,
|
||||
isSending: info.isSending,
|
||||
amountRaw: elem.value,
|
||||
vout: elem.vout,
|
||||
keyImage: elem.keyImage,
|
||||
isChange: elem.isChange,
|
||||
);
|
||||
}));
|
||||
List<UnspentCoinsItem> unspents = [];
|
||||
_getUnspents().forEach((elem) {
|
||||
try {
|
||||
final info =
|
||||
getUnspentCoinInfo(elem.hash, elem.address, elem.value, elem.vout, elem.keyImage);
|
||||
|
||||
unspents.add(UnspentCoinsItem(
|
||||
address: elem.address,
|
||||
amount: '${formatAmountToString(elem.value)} ${wallet.currency.title}',
|
||||
hash: elem.hash,
|
||||
isFrozen: info.isFrozen,
|
||||
note: info.note,
|
||||
isSending: info.isSending,
|
||||
amountRaw: elem.value,
|
||||
vout: elem.vout,
|
||||
keyImage: elem.keyImage,
|
||||
isChange: elem.isChange,
|
||||
isSilentPayment: info.isSilentPayment ?? false,
|
||||
));
|
||||
} catch (e, s) {
|
||||
print(s);
|
||||
print(e.toString());
|
||||
ExceptionHandler.onError(FlutterErrorDetails(exception: e, stack: s));
|
||||
}
|
||||
});
|
||||
|
||||
_items.addAll(unspents);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import 'package:cake_wallet/utils/list_item.dart';
|
||||
|
||||
class WalletAddressListHeader extends ListItem {}
|
||||
class WalletAddressListHeader extends ListItem {
|
||||
final String? title;
|
||||
WalletAddressListHeader({this.title});
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@ class WalletAddressListItem extends ListItem {
|
||||
this.name,
|
||||
this.txCount,
|
||||
this.balance,
|
||||
this.isChange = false})
|
||||
: super();
|
||||
this.isChange = false,
|
||||
// Address that is only ever used once, shouldn't be used to receive funds, copy and paste, share etc
|
||||
this.isOneTimeReceiveAddress = false,
|
||||
}) : super();
|
||||
|
||||
final int? id;
|
||||
final bool isPrimary;
|
||||
@@ -18,7 +20,8 @@ class WalletAddressListItem extends ListItem {
|
||||
final int? txCount;
|
||||
final String? balance;
|
||||
final bool isChange;
|
||||
final bool? isOneTimeReceiveAddress;
|
||||
|
||||
@override
|
||||
String toString() => name ?? address;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -334,20 +334,55 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
}
|
||||
|
||||
if (isElectrumWallet) {
|
||||
final addressItems = bitcoin!.getSubAddresses(wallet).map((subaddress) {
|
||||
final isPrimary = subaddress.id == 0;
|
||||
if (bitcoin!.hasSelectedSilentPayments(wallet)) {
|
||||
final addressItems = bitcoin!.getSilentPaymentAddresses(wallet).map((address) {
|
||||
final isPrimary = address.id == 0;
|
||||
|
||||
return WalletAddressListItem(
|
||||
id: subaddress.id,
|
||||
return WalletAddressListItem(
|
||||
id: address.id,
|
||||
isPrimary: isPrimary,
|
||||
name: subaddress.name,
|
||||
address: subaddress.address,
|
||||
txCount: subaddress.txCount,
|
||||
name: address.name,
|
||||
address: address.address,
|
||||
txCount: address.txCount,
|
||||
balance: AmountConverter.amountIntToString(
|
||||
walletTypeToCryptoCurrency(type), subaddress.balance),
|
||||
isChange: subaddress.isChange);
|
||||
});
|
||||
addressList.addAll(addressItems);
|
||||
walletTypeToCryptoCurrency(type), address.balance),
|
||||
isChange: address.isChange,
|
||||
);
|
||||
});
|
||||
addressList.addAll(addressItems);
|
||||
addressList.add(WalletAddressListHeader(title: S.current.received));
|
||||
|
||||
final receivedAddressItems =
|
||||
bitcoin!.getSilentPaymentReceivedAddresses(wallet).map((address) {
|
||||
return WalletAddressListItem(
|
||||
id: address.id,
|
||||
isPrimary: false,
|
||||
name: address.name,
|
||||
address: address.address,
|
||||
txCount: address.txCount,
|
||||
balance: AmountConverter.amountIntToString(
|
||||
walletTypeToCryptoCurrency(type), address.balance),
|
||||
isChange: address.isChange,
|
||||
isOneTimeReceiveAddress: true,
|
||||
);
|
||||
});
|
||||
addressList.addAll(receivedAddressItems);
|
||||
} else {
|
||||
final addressItems = bitcoin!.getSubAddresses(wallet).map((subaddress) {
|
||||
final isPrimary = subaddress.id == 0;
|
||||
|
||||
return WalletAddressListItem(
|
||||
id: subaddress.id,
|
||||
isPrimary: isPrimary,
|
||||
name: subaddress.name,
|
||||
address: subaddress.address,
|
||||
txCount: subaddress.txCount,
|
||||
balance: AmountConverter.amountIntToString(
|
||||
walletTypeToCryptoCurrency(type), subaddress.balance),
|
||||
isChange: subaddress.isChange);
|
||||
});
|
||||
addressList.addAll(addressItems);
|
||||
}
|
||||
}
|
||||
|
||||
if (wallet.type == WalletType.ethereum) {
|
||||
@@ -416,9 +451,14 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
wallet.type == WalletType.litecoin ||
|
||||
wallet.type == WalletType.bitcoinCash;
|
||||
|
||||
@computed
|
||||
bool get isSilentPayments =>
|
||||
wallet.type == WalletType.bitcoin && bitcoin!.hasSelectedSilentPayments(wallet);
|
||||
|
||||
@computed
|
||||
bool get isAutoGenerateSubaddressEnabled =>
|
||||
_settingsStore.autoGenerateSubaddressStatus != AutoGenerateSubaddressStatus.disabled;
|
||||
_settingsStore.autoGenerateSubaddressStatus != AutoGenerateSubaddressStatus.disabled &&
|
||||
!isSilentPayments;
|
||||
|
||||
List<ListItem> _baseItems;
|
||||
|
||||
@@ -478,4 +518,11 @@ abstract class WalletAddressListViewModelBase extends WalletChangeListenerViewMo
|
||||
amount = '';
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
void deleteAddress(ListItem item) {
|
||||
if (wallet.type == WalletType.bitcoin && item is WalletAddressListItem) {
|
||||
bitcoin!.deleteSilentPaymentAddress(wallet, item.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ class WalletListItem {
|
||||
required this.key,
|
||||
this.isCurrent = false,
|
||||
this.isEnabled = true,
|
||||
this.isTestnet = false,
|
||||
});
|
||||
|
||||
final String name;
|
||||
@@ -14,4 +15,5 @@ class WalletListItem {
|
||||
final bool isCurrent;
|
||||
final dynamic key;
|
||||
final bool isEnabled;
|
||||
final bool isTestnet;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ abstract class WalletListViewModelBase with Store {
|
||||
key: info.key,
|
||||
isCurrent: info.name == _appStore.wallet?.name && info.type == _appStore.wallet?.type,
|
||||
isEnabled: availableWalletTypes.contains(info.type),
|
||||
isTestnet: info.network?.toLowerCase().contains('testnet') ?? false,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user