Generic fixes (#1342)

* handle balance exceptions in estimating All exchange * Fix trades not showing

Omar Hatem committed Mar 21, 2024 at 16:31 UTC af7fe0509969da18ae6f778210814bc020ca907e
2 files changed +20 -14
cw_bitcoin/lib/electrum_wallet_addresses.dart
+3 -1
@@ -220,7 +220,9 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
220 Future<void> updateAddressesInBox() async {
221 try {
222 addressesMap.clear();
223 - addressesMap[address] = '';
223 + _addresses.forEach((addressRecord) {
224 + addressesMap[addressRecord.address] = addressRecord.name;
225 + });
226 await saveAddressesInBox();
227 } catch (e) {
228 print(e.toString());
lib/bitcoin/cw_bitcoin.dart
+17 -13
@@ -127,19 +127,23 @@ class CWBitcoin extends Bitcoin {
127
128 final p2shAddr = sk.getPublic().toP2pkhInP2sh();
129 final p2wpkhAddr = sk.getPublic().toP2wpkhAddress();
130 - final estimatedTx = await electrumWallet.estimateTxFeeAndInputsToUse(
131 - 0,
132 - true,
133 - // Deposit address + change address
134 - [p2shAddr, p2wpkhAddr],
135 - [
136 - BitcoinOutput(address: p2shAddr, value: BigInt.zero),
137 - BitcoinOutput(address: p2wpkhAddr, value: BigInt.zero)
138 - ],
139 - null,
140 - priority as BitcoinTransactionPriority);
141 -
142 - return estimatedTx.amount;
130 + try {
131 + final estimatedTx = await electrumWallet.estimateTxFeeAndInputsToUse(
132 + 0,
133 + true,
134 + // Deposit address + change address
135 + [p2shAddr, p2wpkhAddr],
136 + [
137 + BitcoinOutput(address: p2shAddr, value: BigInt.zero),
138 + BitcoinOutput(address: p2wpkhAddr, value: BigInt.zero)
139 + ],
140 + null,
141 + priority as BitcoinTransactionPriority);
142 +
143 + return estimatedTx.amount;
144 + } catch (_) {
145 + return 0;
146 + }
147 }
148
149 @override