From 8c666dba92388700905779084c5d34d619d42db2 Mon Sep 17 00:00:00 2001 From: sqrrm Date: Sun, 1 Aug 2021 17:22:00 +0200 Subject: [PATCH] Avoid creating more than one refund payout Double clicking the close ticketbutton creates two payout transactions. This fix makes sure only one payout transaction is created for the dispute. Restarting the client allows for creating another refund transaction for the dispute if needed. --- .../java/bisq/core/support/dispute/Dispute.java | 2 ++ .../main/resources/i18n/displayStrings.properties | 3 +++ .../main/overlays/windows/DisputeSummaryWindow.java | 13 +++++++++++++ 3 files changed, 18 insertions(+) diff --git a/core/src/main/java/bisq/core/support/dispute/Dispute.java b/core/src/main/java/bisq/core/support/dispute/Dispute.java index 98ed154fbee..669f7d08540 100644 --- a/core/src/main/java/bisq/core/support/dispute/Dispute.java +++ b/core/src/main/java/bisq/core/support/dispute/Dispute.java @@ -148,6 +148,8 @@ public static protobuf.Dispute.State toProtoMessage(Dispute.State state) { private transient String uid; @Setter private transient long payoutTxConfirms = -1; + @Setter + private transient boolean payoutDone = false; private transient final BooleanProperty isClosedProperty = new SimpleBooleanProperty(); private transient final IntegerProperty badgeCountProperty = new SimpleIntegerProperty(); diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 0c7c1d863c5..a148833cbe9 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2626,6 +2626,9 @@ disputeSummaryWindow.close.txDetails=Spending: {0}\n\ disputeSummaryWindow.close.noPayout.headline=Close without any payout disputeSummaryWindow.close.noPayout.text=Do you want to close without doing any payout? +disputeSummaryWindow.close.alreadyPaid.headline=Payout already done +disputeSummaryWindow.close.alreadyPaid.text=Restart the client to do another payout for this dispute + emptyWalletWindow.headline={0} emergency wallet tool emptyWalletWindow.info=Please use that only in emergency case if you cannot access your fund from the UI.\n\n\ Please note that all open offers will be closed automatically when using this tool.\n\n\ diff --git a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java index a6ac3ce0ee0..61b46a394ff 100644 --- a/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java +++ b/desktop/src/main/java/bisq/desktop/main/overlays/windows/DisputeSummaryWindow.java @@ -673,6 +673,13 @@ private void addButtons(Contract contract) { } private void showPayoutTxConfirmation(Contract contract, DisputeResult disputeResult, ResultHandler resultHandler) { + if (dispute.isPayoutDone()) { + new Popup().headLine(Res.get("disputeSummaryWindow.close.alreadyPaid.headline")) + .confirmation(Res.get("disputeSummaryWindow.close.alreadyPaid.text")) + .closeButtonText(Res.get("shared.cancel")) + .show(); + } + Coin buyerPayoutAmount = disputeResult.getBuyerPayoutAmount(); String buyerPayoutAddressString = contract.getBuyerPayoutAddressString(); Coin sellerPayoutAmount = disputeResult.getSellerPayoutAmount(); @@ -734,6 +741,12 @@ private void doPayout(Coin buyerPayoutAmount, String buyerPayoutAddressString, String sellerPayoutAddressString, ResultHandler resultHandler) { + if (dispute.isPayoutDone()) { + log.error("Payout already processed, returning to avoid double payout for dispute of trade {}", + dispute.getTradeId()); + return; + } + dispute.setPayoutDone(true); try { Transaction tx = btcWalletService.createRefundPayoutTx(buyerPayoutAmount, sellerPayoutAmount,