From 5545bcde3814e977d7efd36c669e1cd31f06b28d Mon Sep 17 00:00:00 2001 From: woodser Date: Tue, 25 Apr 2023 17:27:14 -0400 Subject: [PATCH] take offer view shows pending trade wallet balance --- .../java/haveno/core/trade/TradeManager.java | 3 +-- .../desktop/main/offer/OfferDataModel.java | 24 +++++++++++-------- .../main/offer/takeoffer/TakeOfferView.java | 2 +- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/TradeManager.java b/core/src/main/java/haveno/core/trade/TradeManager.java index 47e8ca7d5a..aa6533c8f4 100644 --- a/core/src/main/java/haveno/core/trade/TradeManager.java +++ b/core/src/main/java/haveno/core/trade/TradeManager.java @@ -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 diff --git a/desktop/src/main/java/haveno/desktop/main/offer/OfferDataModel.java b/desktop/src/main/java/haveno/desktop/main/offer/OfferDataModel.java index a250c57399..f41bab09db 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/OfferDataModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/OfferDataModel.java @@ -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); + } + } } diff --git a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java index 7410f85cba..57bc1fc251 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/takeoffer/TakeOfferView.java @@ -673,7 +673,7 @@ public class TakeOfferView extends ActivatableViewAndModel