take offer view shows pending trade wallet balance

This commit is contained in:
woodser 2023-04-25 17:27:14 -04:00
parent 3f7489269f
commit 5545bcde38
3 changed files with 16 additions and 13 deletions

View File

@ -423,7 +423,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
// remove trade if protocol didn't initialize
if (getOpenTradeByUid(trade.getUid()).isPresent() && !trade.isDepositsPublished()) {
log.warn("Maybe removing persisted {} {} with uid={} because it did not finish initializing (state={})", trade.getClass().getSimpleName(), trade.getId(), trade.getUid(), trade.getState());
maybeRemoveTradeOnError(trade);
}
} catch (Exception e) {
@ -1205,7 +1204,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
}
private void removeTradeOnError(Trade trade) {
log.info("TradeManager.removeTradeOnError() " + trade.getId());
log.warn("TradeManager.removeTradeOnError() " + trade.getId());
synchronized (tradableList) {
// unreserve taker key images

View File

@ -65,15 +65,11 @@ public abstract class OfferDataModel extends ActivatableDataModel {
}
protected void updateBalance() {
BigInteger tradeWalletBalance = xmrWalletService.getBalanceForSubaddress(addressEntry.getSubaddressIndex());
updateBalances();
if (useSavingsWallet) {
BigInteger walletBalance = xmrWalletService.getBalance();
totalBalance = walletBalance.add(tradeWalletBalance);
if (totalToPay.get() != null) {
balance.set(totalToPay.get().min(totalBalance));
}
} else {
balance.set(tradeWalletBalance);
}
missingCoin.set(offerUtil.getBalanceShortage(totalToPay.get(), balance.get()));
isXmrWalletFunded.set(offerUtil.isBalanceSufficient(totalToPay.get(), balance.get()));
@ -83,15 +79,11 @@ public abstract class OfferDataModel extends ActivatableDataModel {
}
protected void updateAvailableBalance() {
BigInteger tradeWalletBalance = xmrWalletService.getAvailableBalanceForSubaddress(addressEntry.getSubaddressIndex());
updateBalances();
if (useSavingsWallet) {
BigInteger walletAvailableBalance = xmrWalletService.getAvailableBalance();
totalAvailableBalance = walletAvailableBalance.add(tradeWalletBalance);
if (totalToPay.get() != null) {
availableBalance.set(totalToPay.get().min(totalAvailableBalance));
}
} else {
availableBalance.set(tradeWalletBalance);
}
missingCoin.set(offerUtil.getBalanceShortage(totalToPay.get(), availableBalance.get()));
isXmrWalletFunded.set(offerUtil.isBalanceSufficient(totalToPay.get(), availableBalance.get()));
@ -99,4 +91,16 @@ public abstract class OfferDataModel extends ActivatableDataModel {
showWalletFundedNotification.set(true);
}
}
private void updateBalances() {
BigInteger tradeWalletBalance = xmrWalletService.getBalanceForSubaddress(addressEntry.getSubaddressIndex());
BigInteger tradeWalletAvailableBalance = xmrWalletService.getAvailableBalanceForSubaddress(addressEntry.getSubaddressIndex());
if (useSavingsWallet) {
totalBalance = xmrWalletService.getBalance();;
totalAvailableBalance = xmrWalletService.getAvailableBalance();
} else {
balance.set(tradeWalletBalance);
availableBalance.set(tradeWalletAvailableBalance);
}
}
}

View File

@ -673,7 +673,7 @@ public class TakeOfferView extends ActivatableViewAndModel<AnchorPane, TakeOffer
}
});
balanceSubscription = EasyBind.subscribe(model.dataModel.getAvailableBalance(), balanceTextField::setBalance);
balanceSubscription = EasyBind.subscribe(model.dataModel.getBalance(), balanceTextField::setBalance);
}
private void removeSubscriptions() {