From 00ceeeba5f3876088e2e4920ee39212decd46d11 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 1 Aug 2024 16:58:45 -0400 Subject: [PATCH] do not allow arbitrators to open disputes --- .../core/support/dispute/DisputeManager.java | 10 +++++++- .../arbitration/ArbitrationManager.java | 25 ++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java index bd019e12..c4561a7f 100644 --- a/core/src/main/java/haveno/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/haveno/core/support/dispute/DisputeManager.java @@ -332,7 +332,15 @@ public abstract class DisputeManager> extends Sup // get trade Trade trade = tradeManager.getTrade(dispute.getTradeId()); if (trade == null) { - log.warn("Dispute trade {} does not exist", dispute.getTradeId()); + String errorMsg = "Dispute trade does not exist, tradeId=" + dispute.getTradeId(); + faultHandler.handleFault(errorMsg, new IllegalStateException(errorMsg)); + return; + } + + // arbitrator cannot open disputes + if (trade.isArbitrator()) { + String errorMsg = "Arbitrators cannot open disputes."; + faultHandler.handleFault(errorMsg, new IllegalStateException(errorMsg)); return; } diff --git a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java index 91316239..4941fcf4 100644 --- a/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java +++ b/core/src/main/java/haveno/core/support/dispute/arbitration/ArbitrationManager.java @@ -87,9 +87,11 @@ import monero.wallet.model.MoneroTxWallet; import java.io.IOException; import java.math.BigInteger; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import static com.google.common.base.Preconditions.checkNotNull; @@ -168,7 +170,28 @@ public final class ArbitrationManager extends DisputeManager toRemoves = new HashSet<>(); + List disputes = getDisputeList().getList(); + for (Dispute dispute : disputes) { + + // get dispute's trade + final Trade trade = tradeManager.getTrade(dispute.getTradeId()); + if (trade == null) { + log.warn("Dispute trade {} does not exist", dispute.getTradeId()); + return; + } + + // collect dispute if owned by arbitrator + if (dispute.getTraderPubKeyRing().equals(trade.getArbitrator().getPubKeyRing())) { + toRemoves.add(dispute); + } + } + for (Dispute toRemove : toRemoves) { + log.warn("Removing invalid dispute opened by arbitrator, disputeId={}", toRemove.getTradeId(), toRemove.getId()); + getDisputeList().remove(toRemove); + } } @Override