close open disputes on trade completion

This commit is contained in:
woodser 2022-12-26 13:44:36 +00:00
parent 2d7654b8d7
commit f2892d5157
6 changed files with 29 additions and 2 deletions

View file

@ -928,6 +928,14 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
.findAny();
}
public List<Dispute> findDisputes(String tradeId) {
T disputeList = getDisputeList();
if (disputeList == null) return new ArrayList<Dispute>();
return disputeList.stream()
.filter(e -> e.getTradeId().equals(tradeId))
.collect(Collectors.toList());
}
public Optional<Dispute> findDisputeById(String disputeId) {
T disputeList = getDisputeList();
if (disputeList == null) {

View file

@ -92,6 +92,7 @@ public final class ArbitrationManager extends DisputeManager<ArbitrationDisputeL
PriceFeedService priceFeedService) {
super(p2PService, tradeWalletService, walletService, connectionService, notificationService, tradeManager, closedTradableManager,
openOfferManager, keyRing, arbitrationDisputeListService, config, priceFeedService);
HavenoUtils.arbitrationManager = this; // store static reference
}

View file

@ -22,6 +22,7 @@ import bisq.common.crypto.PubKeyRing;
import bisq.common.crypto.Sig;
import bisq.core.offer.Offer;
import bisq.core.offer.OfferPayload;
import bisq.core.support.dispute.arbitration.ArbitrationManager;
import bisq.core.support.dispute.arbitration.arbitrator.Arbitrator;
import bisq.core.trade.messages.InitTradeRequest;
import bisq.core.trade.messages.PaymentReceivedMessage;
@ -60,6 +61,9 @@ public class HavenoUtils {
private static BigInteger CENTINEROS_AU_MULTIPLIER = new BigInteger("10000");
private static BigInteger XMR_AU_MULTIPLIER = new BigInteger("1000000000000");
// TODO: better way to share reference?
public static ArbitrationManager arbitrationManager;
public static BigInteger coinToAtomicUnits(Coin coin) {
return centinerosToAtomicUnits(coin.value);
}

View file

@ -28,6 +28,7 @@ import bisq.core.payment.payload.PaymentAccountPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.proto.CoreProtoResolver;
import bisq.core.proto.network.CoreNetworkProtoResolver;
import bisq.core.support.dispute.Dispute;
import bisq.core.support.dispute.mediation.MediationResultState;
import bisq.core.support.dispute.refund.RefundResultState;
import bisq.core.support.messages.ChatMessage;
@ -1047,6 +1048,10 @@ public abstract class Trade implements Tradable, Model {
if (disputeState.ordinal() > getDisputeState().ordinal()) setDisputeState(disputeState);
}
public List<Dispute> getDisputes() {
return HavenoUtils.arbitrationManager.findDisputes(getId());
}
public void setMediationResultState(MediationResultState mediationResultState) {
this.mediationResultState = mediationResultState;
mediationResultStateProperty.set(mediationResultState);

View file

@ -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);

View file

@ -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"));