Fix unavailable balance not refreshing after the app got opened

This commit is contained in:
Czarek Nakamoto 2024-12-31 14:35:30 +01:00
parent 26c1f0b85c
commit 899b41f40a
2 changed files with 6 additions and 1 deletions

View file

@ -503,6 +503,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
} }
Future<void> updateUnspent() async { Future<void> updateUnspent() async {
await transaction_history.txHistoryMutex.acquire();
try { try {
refreshCoins(walletAddresses.account!.id); refreshCoins(walletAddresses.account!.id);
@ -531,6 +532,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
if (unspentCoinsInfo.isEmpty) { if (unspentCoinsInfo.isEmpty) {
unspentCoins.forEach((coin) => _addCoinInfo(coin)); unspentCoins.forEach((coin) => _addCoinInfo(coin));
transaction_history.txHistoryMutex.release();
return; return;
} }
@ -555,7 +557,9 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
await _refreshUnspentCoinsInfo(); await _refreshUnspentCoinsInfo();
_askForUpdateBalance(); _askForUpdateBalance();
transaction_history.txHistoryMutex.release();
} catch (e, s) { } catch (e, s) {
transaction_history.txHistoryMutex.release();
printV(e.toString()); printV(e.toString());
onError?.call(FlutterErrorDetails( onError?.call(FlutterErrorDetails(
exception: e, exception: e,

View file

@ -12,6 +12,7 @@ import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_service.dart'; import 'package:cw_core/wallet_service.dart';
import 'package:cw_core/wallet_type.dart'; import 'package:cw_core/wallet_type.dart';
import 'package:cw_monero/api/account_list.dart'; import 'package:cw_monero/api/account_list.dart';
import 'package:cw_monero/api/transaction_history.dart';
import 'package:cw_monero/api/wallet_manager.dart' as monero_wallet_manager; import 'package:cw_monero/api/wallet_manager.dart' as monero_wallet_manager;
import 'package:cw_monero/api/wallet_manager.dart'; import 'package:cw_monero/api/wallet_manager.dart';
import 'package:cw_monero/ledger.dart'; import 'package:cw_monero/ledger.dart';
@ -159,7 +160,7 @@ class MoneroWalletService extends WalletService<
} }
await wallet.init(); await wallet.init();
await wallet.updateUnspent();
return wallet; return wallet;
} catch (e) { } catch (e) {
// TODO: Implement Exception for wallet list service. // TODO: Implement Exception for wallet list service.