Skip to content

Commit

Permalink
Merge pull request #5649 from sqrrm/refund-double-payout-fix
Browse files Browse the repository at this point in the history
Avoid creating more than one refund payout
  • Loading branch information
ripcurlx authored Aug 12, 2021
2 parents 374e76a + 8c666db commit 9db2c18
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/bisq/core/support/dispute/Dispute.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/i18n/displayStrings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 9db2c18

Please sign in to comment.