From dd65cdca13effc0fe899d637b115f806de08c83f Mon Sep 17 00:00:00 2001 From: woodser <13068859+woodser@users.noreply.github.com> Date: Thu, 29 May 2025 17:07:20 -0400 Subject: [PATCH] fix custom amounts for dispute result --- .../windows/DisputeSummaryWindow.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java b/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java index ebf1c25309..5004d240d8 100644 --- a/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java +++ b/desktop/src/main/java/haveno/desktop/main/overlays/windows/DisputeSummaryWindow.java @@ -25,6 +25,7 @@ import haveno.common.handlers.ResultHandler; import haveno.common.util.Tuple2; import haveno.common.util.Tuple3; import haveno.core.api.CoreDisputesService; +import haveno.core.api.CoreDisputesService.PayoutSuggestion; import haveno.core.locale.Res; import haveno.core.support.SupportType; import haveno.core.support.dispute.Dispute; @@ -138,6 +139,7 @@ public class DisputeSummaryWindow extends Overlay { public void show(Dispute dispute) { this.dispute = dispute; this.trade = tradeManager.getTrade(dispute.getTradeId()); + this.payoutSuggestion = null; rowIndex = -1; width = 1150; @@ -243,7 +245,6 @@ public class DisputeSummaryWindow extends Overlay { reasonWasPeerWasLateRadioButton.setDisable(true); reasonWasTradeAlreadySettledRadioButton.setDisable(true); - applyPayoutAmounts(tradeAmountToggleGroup.selectedToggleProperty().get()); applyTradeAmountRadioButtonStates(); } @@ -724,6 +725,10 @@ public class DisputeSummaryWindow extends Overlay { private void applyTradeAmountRadioButtonStates() { + if (payoutSuggestion == null) { + payoutSuggestion = getPayoutSuggestionFromDisputeResult(); + } + BigInteger buyerPayoutAmount = disputeResult.getBuyerPayoutAmountBeforeCost(); BigInteger sellerPayoutAmount = disputeResult.getSellerPayoutAmountBeforeCost(); @@ -748,4 +753,20 @@ public class DisputeSummaryWindow extends Overlay { break; } } + + // TODO: Persist the payout suggestion to DisputeResult like Bisq upstream? + // That would be a better design, but it's not currently needed. + private PayoutSuggestion getPayoutSuggestionFromDisputeResult() { + if (disputeResult.getBuyerPayoutAmountBeforeCost().equals(BigInteger.ZERO)) { + return PayoutSuggestion.SELLER_GETS_ALL; + } else if (disputeResult.getSellerPayoutAmountBeforeCost().equals(BigInteger.ZERO)) { + return PayoutSuggestion.BUYER_GETS_ALL; + } else if (disputeResult.getBuyerPayoutAmountBeforeCost().equals(trade.getAmount().add(trade.getBuyer().getSecurityDeposit()))) { + return PayoutSuggestion.BUYER_GETS_TRADE_AMOUNT; + } else if (disputeResult.getSellerPayoutAmountBeforeCost().equals(trade.getAmount().add(trade.getSeller().getSecurityDeposit()))) { + return PayoutSuggestion.SELLER_GETS_TRADE_AMOUNT; + } else { + return PayoutSuggestion.CUSTOM; + } + } }