Skip to content

Commit

Permalink
Generic fixes (#1342)
Browse files Browse the repository at this point in the history
* handle balance exceptions in estimating All exchange

* Fix trades not showing
  • Loading branch information
OmarHatem28 authored Mar 21, 2024
1 parent ecb4f32 commit af7fe05
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
4 changes: 3 additions & 1 deletion cw_bitcoin/lib/electrum_wallet_addresses.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ abstract class ElectrumWalletAddressesBase extends WalletAddresses with Store {
Future<void> updateAddressesInBox() async {
try {
addressesMap.clear();
addressesMap[address] = '';
_addresses.forEach((addressRecord) {
addressesMap[addressRecord.address] = addressRecord.name;
});
await saveAddressesInBox();
} catch (e) {
print(e.toString());
Expand Down
30 changes: 17 additions & 13 deletions lib/bitcoin/cw_bitcoin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,23 @@ class CWBitcoin extends Bitcoin {

final p2shAddr = sk.getPublic().toP2pkhInP2sh();
final p2wpkhAddr = sk.getPublic().toP2wpkhAddress();
final estimatedTx = await electrumWallet.estimateTxFeeAndInputsToUse(
0,
true,
// Deposit address + change address
[p2shAddr, p2wpkhAddr],
[
BitcoinOutput(address: p2shAddr, value: BigInt.zero),
BitcoinOutput(address: p2wpkhAddr, value: BigInt.zero)
],
null,
priority as BitcoinTransactionPriority);

return estimatedTx.amount;
try {
final estimatedTx = await electrumWallet.estimateTxFeeAndInputsToUse(
0,
true,
// Deposit address + change address
[p2shAddr, p2wpkhAddr],
[
BitcoinOutput(address: p2shAddr, value: BigInt.zero),
BitcoinOutput(address: p2wpkhAddr, value: BigInt.zero)
],
null,
priority as BitcoinTransactionPriority);

return estimatedTx.amount;
} catch (_) {
return 0;
}
}

@override
Expand Down

0 comments on commit af7fe05

Please sign in to comment.