fix send and unspent screen

This commit is contained in:
Serhii 2023-08-15 13:53:52 +03:00
parent af58c45190
commit c1faead0ab
3 changed files with 13 additions and 14 deletions

View file

@ -667,11 +667,7 @@ abstract class ElectrumWalletBase
Future<ElectrumBalance> _fetchBalances() async {
final addresses = walletAddresses.addresses.toList();
final balanceFutures = <Future<Map<String, dynamic>>>[];
var counter = addresses.length;
if (walletInfo.type == WalletType.bitcoinCash) counter = 1; //TODO: BCH: remove this check when supported
for (var i = 0; i < counter; i++) {
for (var i = 0; i < addresses.length; i++) {
final addressRecord = addresses[i];
final sh = scriptHash(addressRecord.address, networkType: networkType);
final balanceFuture = electrumClient.getBalance(sh);

View file

@ -4,6 +4,7 @@ import 'package:cw_bitcoin/electrum.dart';
import 'package:cw_bitcoin/script_hash.dart';
import 'package:cw_core/wallet_addresses.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:mobx/mobx.dart';
part 'electrum_wallet_addresses.g.dart';
@ -108,7 +109,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
if (changeAddresses.isEmpty) {
final newAddresses = await _createNewAddresses(
gap,
(walletInfo.type != WalletType.bitcoinCash ? gap : 0), //TODO: BCH: Fix this
hd: sideHd,
startIndex: totalCountOfChangeAddresses > 0
? totalCountOfChangeAddresses - 1
@ -179,8 +180,8 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
} else {
addrs = await _createNewAddresses(
isHidden
? defaultChangeAddressesCount
: defaultReceiveAddressesCount,
? walletInfo.type != WalletType.bitcoinCash ? defaultChangeAddressesCount : 0 //TODO: BCH: Fix this
: walletInfo.type != WalletType.bitcoinCash ? defaultReceiveAddressesCount : 1, //TODO: BCH: Fix this
startIndex: 0,
hd: hd,
isHidden: isHidden);
@ -195,7 +196,7 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
}
final start = addrs.length;
final count = start + gap;
final count = start + (walletInfo.type != WalletType.bitcoinCash ? gap : 0); //TODO: BCH: Fix this
final batch = await _createNewAddresses(
count,
startIndex: start,
@ -222,8 +223,8 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
countOfReceiveAddresses += 1;
});
if (countOfReceiveAddresses < defaultReceiveAddressesCount) {
final addressesCount = defaultReceiveAddressesCount - countOfReceiveAddresses;
if (countOfReceiveAddresses < (walletInfo.type != WalletType.bitcoinCash ? defaultReceiveAddressesCount : 1)) { //TODO: BCH: Fix this
final addressesCount = (walletInfo.type != WalletType.bitcoinCash ? defaultReceiveAddressesCount : 1) - countOfReceiveAddresses;
final newAddresses = await _createNewAddresses(
addressesCount,
startIndex: countOfReceiveAddresses,
@ -232,8 +233,8 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
addresses.addAll(newAddresses);
}
if (countOfHiddenAddresses < defaultChangeAddressesCount) {
final addressesCount = defaultChangeAddressesCount - countOfHiddenAddresses;
if (countOfHiddenAddresses < (walletInfo.type != WalletType.bitcoinCash ? defaultChangeAddressesCount : 0)) { //TODO: BCH: Fix this
final addressesCount = (walletInfo.type != WalletType.bitcoinCash ? defaultChangeAddressesCount : 0) - countOfHiddenAddresses;
final newAddresses = await _createNewAddresses(
addressesCount,
startIndex: countOfHiddenAddresses,

View file

@ -174,7 +174,9 @@ abstract class SendViewModelBase with Store {
@computed
bool get isElectrumWallet =>
_wallet.type == WalletType.bitcoin || _wallet.type == WalletType.litecoin;
_wallet.type == WalletType.bitcoin ||
_wallet.type == WalletType.litecoin ||
_wallet.type == WalletType.bitcoinCash;
@observable
CryptoCurrency selectedCryptoCurrency;