firo balance bug fix

This commit is contained in:
julian 2023-03-28 08:10:29 -06:00
parent 70e257f5bf
commit b4a344ebad

View file

@ -2490,60 +2490,17 @@ class FiroWallet extends CoinServiceAPI with WalletCache, WalletDB, FiroHive {
}); });
} }
// final int utxosIntValue = utxos.satoshiBalance; _balancePrivate = Balance(
// final Decimal utxosValue = coin: coin,
// Format.satoshisToAmount(utxosIntValue, coin: coin); total: intLelantusBalance + unconfirmedLelantusBalance,
spendable: intLelantusBalance,
// List<Decimal> balances = List.empty(growable: true); blockedTotal: 0,
// pendingSpendable: unconfirmedLelantusBalance,
// Decimal lelantusBalance = );
// Format.satoshisToAmount(intLelantusBalance, coin: coin); await updateCachedBalanceSecondary(_balancePrivate!);
// balances.add(lelantusBalance); 0
//
// balances.add(lelantusBalance * price); 1
// Decimal _unconfirmedLelantusBalance =
// Format.satoshisToAmount(unconfirmedLelantusBalance, coin: coin);
// balances.add(lelantusBalance + utxosValue + _unconfirmedLelantusBalance); 2
//
// balances.add(
// (lelantusBalance + utxosValue + _unconfirmedLelantusBalance) * price); 3
// int availableSats =
// utxos.satoshiBalance - utxos.satoshiBalanceUnconfirmed;
// if (availableSats < 0) {
// availableSats = 0;
// }
// balances.add(Format.satoshisToAmount(availableSats, coin: coin)); 4
// wait for updated uxtos to get updated public balance // wait for updated uxtos to get updated public balance
await utxosUpdateFuture; await utxosUpdateFuture;
// todo: shared total between private and public balances?
_balancePrivate = Balance(
coin: coin,
total: intLelantusBalance + unconfirmedLelantusBalance + balance.total,
spendable: intLelantusBalance,
blockedTotal: 0,
pendingSpendable: unconfirmedLelantusBalance + balance.total,
);
await updateCachedBalanceSecondary(_balancePrivate!);
// _balance = Balance(
// coin: coin,
// total: utxos.satoshiBalance,
// spendable: availableSats,
// blockedTotal: 0,
// pendingSpendable: utxos.satoshiBalanceUnconfirmed,
// );
// Logging.instance.log("balances $balances", level: LogLevel.Info);
// await DB.instance.put<dynamic>(
// boxName: walletId,
// key: 'totalBalance',
// value: balances[2].toString());
// return balances;
} catch (e, s) { } catch (e, s) {
Logging.instance.log("Exception rethrown in getFullBalance(): $e\n$s", Logging.instance.log("Exception rethrown in getFullBalance(): $e\n$s",
level: LogLevel.Error); level: LogLevel.Error);