From f2892d51570d4652a144d451b1b02d30c1a94de1 Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 26 Dec 2022 13:44:36 +0000 Subject: [PATCH] close open disputes on trade completion --- .../bisq/core/support/dispute/DisputeManager.java | 8 ++++++++ .../dispute/arbitration/ArbitrationManager.java | 1 + core/src/main/java/bisq/core/trade/HavenoUtils.java | 4 ++++ core/src/main/java/bisq/core/trade/Trade.java | 5 +++++ .../protocol/tasks/ProcessPaymentReceivedMessage.java | 11 ++++++++++- .../pendingtrades/steps/buyer/BuyerStep4View.java | 2 +- 6 files changed, 29 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java index c56e374e52..73ce8184a6 100644 --- a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java @@ -928,6 +928,14 @@ public abstract class DisputeManager> extends Sup .findAny(); } + public List findDisputes(String tradeId) { + T disputeList = getDisputeList(); + if (disputeList == null) return new ArrayList(); + return disputeList.stream() + .filter(e -> e.getTradeId().equals(tradeId)) + .collect(Collectors.toList()); + } + public Optional findDisputeById(String disputeId) { T disputeList = getDisputeList(); if (disputeList == null) { diff --git a/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java b/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java index 148f6e911c..b757fd5063 100644 --- a/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java +++ b/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java @@ -92,6 +92,7 @@ public final class ArbitrationManager extends DisputeManager getDisputeState().ordinal()) setDisputeState(disputeState); } + public List getDisputes() { + return HavenoUtils.arbitrationManager.findDisputes(getId()); + } + public void setMediationResultState(MediationResultState mediationResultState) { this.mediationResultState = mediationResultState; mediationResultStateProperty.set(mediationResultState); diff --git a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java index 1d2a8f83ad..4b6af55823 100644 --- a/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java +++ b/core/src/main/java/bisq/core/trade/protocol/tasks/ProcessPaymentReceivedMessage.java @@ -18,6 +18,7 @@ package bisq.core.trade.protocol.tasks; import bisq.core.account.sign.SignedWitness; +import bisq.core.support.dispute.Dispute; import bisq.core.trade.ArbitratorTrade; import bisq.core.trade.HavenoUtils; import bisq.core.trade.Trade; @@ -55,10 +56,18 @@ public class ProcessPaymentReceivedMessage extends TradeTask { trade.getSeller().setUpdatedMultisigHex(message.getUpdatedMultisigHex()); trade.getBuyer().setUpdatedMultisigHex(message.getPaymentSentMessage().getUpdatedMultisigHex()); - // update to the latest peer address of our peer if the message is correct + // update to the latest peer address of our peer if message is correct trade.getSeller().setNodeAddress(processModel.getTempTradingPeerNodeAddress()); if (trade.getSeller().getNodeAddress().equals(trade.getBuyer().getNodeAddress())) trade.getBuyer().setNodeAddress(null); // tests can reuse addresses + // close open disputes + if (trade.getDisputeState().ordinal() >= Trade.DisputeState.DISPUTE_OPENED.ordinal()) { + trade.setDisputeStateIfProgress(Trade.DisputeState.DISPUTE_CLOSED); + for (Dispute dispute : trade.getDisputes()) { + dispute.setIsClosed(); + } + } + // process payout tx unless already unlocked if (!trade.isPayoutUnlocked()) processPayoutTx(message); diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep4View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep4View.java index c47e684544..f2f1515151 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep4View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep4View.java @@ -88,7 +88,7 @@ public class BuyerStep4View extends TradeStepView { TitledGroupBg completedTradeLabel = new TitledGroupBg(); if (trade.getDisputeState().isMediated()) { completedTradeLabel.setText(Res.get("portfolio.pending.step5_buyer.groupTitle.mediated")); - } else if (trade.getDisputeState().isArbitrated()) { + } else if (trade.getDisputeState().isArbitrated() && trade.getDisputes().get(0).getDisputeResultProperty().get() != null) { completedTradeLabel.setText(Res.get("portfolio.pending.step5_buyer.groupTitle.arbitrated")); } else { completedTradeLabel.setText(Res.get("portfolio.pending.step5_buyer.groupTitle"));