From 608166ce6441a4f5c17b003c691a3bb680edb1aa Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sat, 10 Oct 2020 15:55:19 -0500 Subject: [PATCH 1/3] When a refund agent closes a case we have checked that the trade protocol is the same between offer and refund agent. This would fail once we update trade protocol version when we release segwit. So this fixes that as it only checks if the version is not the old version (1) where refund agents have not been part of the system. Also checks for legacy arbitrator that it only can be used for version 1 cases. Not tested and not assumed that this code will be executed as old arbitrators would use the old app in case they need to still work on a old case. --- .../desktop/main/support/dispute/DisputeView.java | 11 +---------- .../dispute/agent/arbitration/ArbitratorView.java | 15 +++++++++++++++ .../dispute/agent/mediation/MediatorView.java | 3 +-- .../dispute/agent/refund/RefundAgentView.java | 13 +++++++++++++ 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java index f102f4e56c6..0987a29eec8 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java @@ -55,7 +55,6 @@ import bisq.network.p2p.NodeAddress; -import bisq.common.app.Version; import bisq.common.crypto.KeyRing; import bisq.common.crypto.PubKeyRing; import bisq.common.util.Utilities; @@ -475,15 +474,7 @@ protected void reOpenDisputeFromButton() { protected abstract void handleOnSelectDispute(Dispute dispute); - protected void onCloseDispute(Dispute dispute) { - long protocolVersion = dispute.getContract().getOfferPayload().getProtocolVersion(); - if (protocolVersion == Version.TRADE_PROTOCOL_VERSION) { - disputeSummaryWindow.onFinalizeDispute(() -> chatView.removeInputBox()) - .show(dispute); - } else { - new Popup().warning(Res.get("support.wrongVersion", protocolVersion)).show(); - } - } + protected abstract void onCloseDispute(Dispute dispute); protected void reOpenDispute() { if (selectedDispute != null) { diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java index 7c8c40b1417..23f90a35ed2 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java @@ -18,6 +18,7 @@ package bisq.desktop.main.support.dispute.agent.arbitration; import bisq.desktop.common.view.FxmlView; +import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.main.overlays.windows.ContractWindow; import bisq.desktop.main.overlays.windows.DisputeSummaryWindow; import bisq.desktop.main.overlays.windows.TradeDetailsWindow; @@ -26,6 +27,7 @@ import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.alert.PrivateNotificationManager; import bisq.core.dao.DaoFacade; +import bisq.core.locale.Res; import bisq.core.support.SupportType; import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.DisputeSession; @@ -84,4 +86,17 @@ protected SupportType getType() { protected DisputeSession getConcreteDisputeChatSession(Dispute dispute) { return new ArbitrationSession(dispute, disputeManager.isTrader(dispute)); } + + @Override + protected void onCloseDispute(Dispute dispute) { + long protocolVersion = dispute.getContract().getOfferPayload().getProtocolVersion(); + // Only cases with protocolVersion 1 are candidates for legacy arbitration. + // This code path is not tested and it is not assumed that it is still be used as old arbitrators would use + // their old Bisq version if sill cases are pending. + if (protocolVersion == 1) { + disputeSummaryWindow.onFinalizeDispute(() -> chatView.removeInputBox()).show(dispute); + } else { + new Popup().warning(Res.get("support.wrongVersion", protocolVersion)).show(); + } + } } diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java index 4dacc16ed2c..835a1034fcb 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/mediation/MediatorView.java @@ -112,7 +112,6 @@ protected DisputeSession getConcreteDisputeChatSession(Dispute dispute) { @Override protected void onCloseDispute(Dispute dispute) { - disputeSummaryWindow.onFinalizeDispute(() -> chatView.removeInputBox()) - .show(dispute); + disputeSummaryWindow.onFinalizeDispute(() -> chatView.removeInputBox()).show(dispute); } } diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java index 797e4849bd0..ef5ed5c1487 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/refund/RefundAgentView.java @@ -18,6 +18,7 @@ package bisq.desktop.main.support.dispute.agent.refund; import bisq.desktop.common.view.FxmlView; +import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.main.overlays.windows.ContractWindow; import bisq.desktop.main.overlays.windows.DisputeSummaryWindow; import bisq.desktop.main.overlays.windows.TradeDetailsWindow; @@ -26,6 +27,7 @@ import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.alert.PrivateNotificationManager; import bisq.core.dao.DaoFacade; +import bisq.core.locale.Res; import bisq.core.support.SupportType; import bisq.core.support.dispute.Dispute; import bisq.core.support.dispute.DisputeSession; @@ -84,4 +86,15 @@ protected SupportType getType() { protected DisputeSession getConcreteDisputeChatSession(Dispute dispute) { return new RefundSession(dispute, disputeManager.isTrader(dispute)); } + + @Override + protected void onCloseDispute(Dispute dispute) { + long protocolVersion = dispute.getContract().getOfferPayload().getProtocolVersion(); + // Refund agent was introduced with protocolVersion version 2. We do not support old trade protocol cases. + if (protocolVersion >= 2) { + disputeSummaryWindow.onFinalizeDispute(() -> chatView.removeInputBox()).show(dispute); + } else { + new Popup().warning(Res.get("support.wrongVersion", protocolVersion)).show(); + } + } } From 78dc0290aff359f8a46107beaea158bafee9fab7 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sat, 10 Oct 2020 20:20:04 -0500 Subject: [PATCH 2/3] Move onCloseDispute to DisputeAgentView --- .../java/bisq/desktop/main/support/dispute/DisputeView.java | 2 -- .../desktop/main/support/dispute/agent/DisputeAgentView.java | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java index 0987a29eec8..f00e52130d0 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/DisputeView.java @@ -474,8 +474,6 @@ protected void reOpenDisputeFromButton() { protected abstract void handleOnSelectDispute(Dispute dispute); - protected abstract void onCloseDispute(Dispute dispute); - protected void reOpenDispute() { if (selectedDispute != null) { selectedDispute.setIsClosed(false); diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java index b3111962fb4..aafb16d2185 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/DisputeAgentView.java @@ -215,6 +215,8 @@ protected void setupTable() { tableView.getColumns().add(getAlertColumn()); } + protected abstract void onCloseDispute(Dispute dispute); + /////////////////////////////////////////////////////////////////////////////////////////// // Private From f2b41d8b205eea629c035a9854c7ec0c7403b0fb Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Mon, 19 Oct 2020 18:33:08 -0500 Subject: [PATCH 3/3] Fix typo --- .../main/support/dispute/agent/arbitration/ArbitratorView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java index 23f90a35ed2..ba6f4b19952 100644 --- a/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java +++ b/desktop/src/main/java/bisq/desktop/main/support/dispute/agent/arbitration/ArbitratorView.java @@ -92,7 +92,7 @@ protected void onCloseDispute(Dispute dispute) { long protocolVersion = dispute.getContract().getOfferPayload().getProtocolVersion(); // Only cases with protocolVersion 1 are candidates for legacy arbitration. // This code path is not tested and it is not assumed that it is still be used as old arbitrators would use - // their old Bisq version if sill cases are pending. + // their old Bisq version if still cases are pending. if (protocolVersion == 1) { disputeSummaryWindow.onFinalizeDispute(() -> chatView.removeInputBox()).show(dispute); } else {