mirror of
https://github.com/retoaccess1/haveno-reto.git
synced 2024-11-12 22:23:42 +01:00
take offer view shows pending trade wallet balance
This commit is contained in:
parent
3f7489269f
commit
5545bcde38
@ -423,7 +423,6 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
|
|
||||||
// remove trade if protocol didn't initialize
|
// remove trade if protocol didn't initialize
|
||||||
if (getOpenTradeByUid(trade.getUid()).isPresent() && !trade.isDepositsPublished()) {
|
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);
|
maybeRemoveTradeOnError(trade);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -1205,7 +1204,7 @@ public class TradeManager implements PersistedDataHost, DecryptedDirectMessageLi
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void removeTradeOnError(Trade trade) {
|
private void removeTradeOnError(Trade trade) {
|
||||||
log.info("TradeManager.removeTradeOnError() " + trade.getId());
|
log.warn("TradeManager.removeTradeOnError() " + trade.getId());
|
||||||
synchronized (tradableList) {
|
synchronized (tradableList) {
|
||||||
|
|
||||||
// unreserve taker key images
|
// unreserve taker key images
|
||||||
|
@ -65,15 +65,11 @@ public abstract class OfferDataModel extends ActivatableDataModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void updateBalance() {
|
protected void updateBalance() {
|
||||||
BigInteger tradeWalletBalance = xmrWalletService.getBalanceForSubaddress(addressEntry.getSubaddressIndex());
|
updateBalances();
|
||||||
if (useSavingsWallet) {
|
if (useSavingsWallet) {
|
||||||
BigInteger walletBalance = xmrWalletService.getBalance();
|
|
||||||
totalBalance = walletBalance.add(tradeWalletBalance);
|
|
||||||
if (totalToPay.get() != null) {
|
if (totalToPay.get() != null) {
|
||||||
balance.set(totalToPay.get().min(totalBalance));
|
balance.set(totalToPay.get().min(totalBalance));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
balance.set(tradeWalletBalance);
|
|
||||||
}
|
}
|
||||||
missingCoin.set(offerUtil.getBalanceShortage(totalToPay.get(), balance.get()));
|
missingCoin.set(offerUtil.getBalanceShortage(totalToPay.get(), balance.get()));
|
||||||
isXmrWalletFunded.set(offerUtil.isBalanceSufficient(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() {
|
protected void updateAvailableBalance() {
|
||||||
BigInteger tradeWalletBalance = xmrWalletService.getAvailableBalanceForSubaddress(addressEntry.getSubaddressIndex());
|
updateBalances();
|
||||||
if (useSavingsWallet) {
|
if (useSavingsWallet) {
|
||||||
BigInteger walletAvailableBalance = xmrWalletService.getAvailableBalance();
|
|
||||||
totalAvailableBalance = walletAvailableBalance.add(tradeWalletBalance);
|
|
||||||
if (totalToPay.get() != null) {
|
if (totalToPay.get() != null) {
|
||||||
availableBalance.set(totalToPay.get().min(totalAvailableBalance));
|
availableBalance.set(totalToPay.get().min(totalAvailableBalance));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
availableBalance.set(tradeWalletBalance);
|
|
||||||
}
|
}
|
||||||
missingCoin.set(offerUtil.getBalanceShortage(totalToPay.get(), availableBalance.get()));
|
missingCoin.set(offerUtil.getBalanceShortage(totalToPay.get(), availableBalance.get()));
|
||||||
isXmrWalletFunded.set(offerUtil.isBalanceSufficient(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);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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() {
|
private void removeSubscriptions() {
|
||||||
|
Loading…
Reference in New Issue
Block a user