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 bd019e128f..c4561a7fdf 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 9131623953..4941fcf4f4 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