diff --git a/core/src/main/java/haveno/core/trade/Trade.java b/core/src/main/java/haveno/core/trade/Trade.java index bd6b9a87b0..dafdae47a2 100644 --- a/core/src/main/java/haveno/core/trade/Trade.java +++ b/core/src/main/java/haveno/core/trade/Trade.java @@ -88,7 +88,6 @@ import javafx.collections.ObservableList; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; -import monero.common.MoneroError; import monero.common.MoneroRpcConnection; import monero.common.TaskLooper; import monero.daemon.MoneroDaemon; @@ -1181,43 +1180,12 @@ public abstract class Trade implements Tradable, Model { @Nullable public MoneroTx getTakerDepositTx() { - return getDepositTx(getTaker()); + return getTaker().getDepositTx(); } @Nullable public MoneroTx getMakerDepositTx() { - return getDepositTx(getMaker()); - } - - private MoneroTx getDepositTx(TradePeer trader) { - String depositId = trader.getDepositTxHash(); - if (depositId == null) return null; - try { - if (trader.getDepositTx() == null || !trader.getDepositTx().isConfirmed()) { - MoneroTx depositTx = getDepositTxFromWalletOrDaemon(depositId); - if (depositTx != null) trader.setDepositTx(depositTx); - } - return trader.getDepositTx(); - } catch (MoneroError e) { - log.error("Error getting {} deposit tx {}: {}", getPeerRole(trader), depositId, e.getMessage()); // TODO: peer.getRole() - throw e; - } - } - - private MoneroTx getDepositTxFromWalletOrDaemon(String txId) { - MoneroTx tx = null; - - // first check wallet - if (getWallet() != null) { - List filteredTxs = getWallet().getTxs(new MoneroTxQuery() - .setHash(txId) - .setIsConfirmed(isDepositsConfirmed() ? true : null)); // avoid checking pool if confirmed - if (filteredTxs.size() == 1) tx = filteredTxs.get(0); - } - - // then check daemon - if (tx == null) tx = xmrWalletService.getDaemonTxWithCache(txId); - return tx; + return getMaker().getDepositTx(); } public void addAndPersistChatMessage(ChatMessage chatMessage) { @@ -2231,7 +2199,7 @@ public abstract class Trade implements Tradable, Model { if (tx.getHash().equals(getMaker().getDepositTxHash())) getMaker().setDepositTx(tx); if (tx.getHash().equals(getTaker().getDepositTxHash())) getTaker().setDepositTx(tx); } - if (!txs.isEmpty()) depositTxsUpdateCounter.set(depositTxsUpdateCounter.get() + 1); + depositTxsUpdateCounter.set(depositTxsUpdateCounter.get() + 1); } private void forceRestartTradeWallet() { diff --git a/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java b/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java index 625e2d9d6b..70155b13c0 100644 --- a/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java +++ b/desktop/src/main/java/haveno/desktop/components/TxIdTextField.java @@ -199,18 +199,18 @@ public class TxIdTextField extends AnchorPane { tx = useCache ? xmrWalletService.getDaemonTxWithCache(txId) : xmrWalletService.getDaemonTx(txId); tx.setNumConfirmations(tx.isConfirmed() ? (height == null ? xmrWalletService.getConnectionService().getLastInfo().getHeight() : height) - tx.getHeight(): 0l); // TODO: don't set if tx.getNumConfirmations() works reliably on non-local testnet } else { - if (txId.equals(trade.getMaker().getDepositTxHash())) tx = trade.getMaker().getDepositTx(); - else if (txId.equals(trade.getTaker().getDepositTxHash())) tx = trade.getTaker().getDepositTx(); + if (txId.equals(trade.getMaker().getDepositTxHash())) tx = trade.getMakerDepositTx(); + else if (txId.equals(trade.getTaker().getDepositTxHash())) tx = trade.getTakerDepositTx(); } } catch (Exception e) { // do nothing } - updateConfidence(tx); + updateConfidence(tx, trade); } - private void updateConfidence(MoneroTx tx) { + private void updateConfidence(MoneroTx tx, Trade trade) { UserThread.execute(() -> { - GUIUtil.updateConfidence(tx, progressIndicatorTooltip, txConfidenceIndicator); + GUIUtil.updateConfidence(tx, trade, progressIndicatorTooltip, txConfidenceIndicator); if (txConfidenceIndicator.getProgress() != 0) { AnchorPane.setRightAnchor(txConfidenceIndicator, 0.0); } diff --git a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java index e47b709a0b..5f468fd118 100644 --- a/desktop/src/main/java/haveno/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/haveno/desktop/util/GUIUtil.java @@ -48,6 +48,7 @@ import haveno.core.payment.PaymentAccount; import haveno.core.payment.PaymentAccountList; import haveno.core.payment.payload.PaymentMethod; import haveno.core.trade.HavenoUtils; +import haveno.core.trade.Trade; import haveno.core.user.DontShowAgainLookup; import haveno.core.user.Preferences; import haveno.core.user.User; @@ -528,9 +529,21 @@ public class GUIUtil { public static void updateConfidence(MoneroTx tx, Tooltip tooltip, TxConfidenceIndicator txConfidenceIndicator) { + updateConfidence(tx, null, tooltip, txConfidenceIndicator); + } + + public static void updateConfidence(MoneroTx tx, + Trade trade, + Tooltip tooltip, + TxConfidenceIndicator txConfidenceIndicator) { if (tx == null || tx.getNumConfirmations() == null || !tx.isRelayed()) { - tooltip.setText(Res.get("confidence.unknown")); - txConfidenceIndicator.setProgress(-1); + if (trade != null && trade.isDepositsUnlocked()) { + tooltip.setText(Res.get("confidence.confirmed", ">=10")); + txConfidenceIndicator.setProgress(1.0); + } else { + tooltip.setText(Res.get("confidence.unknown")); + txConfidenceIndicator.setProgress(-1); + } } else { if (tx.isFailed()) { tooltip.setText(Res.get("confidence.invalid"));