Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid creating more than one refund payout #5649

Merged
merged 1 commit into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The payoutDone guard works fine, and it issues the log warning about avoiding double payouts. However I cannot get this warning popup to show - so it seems redundant.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You get this warning if you try to do a payout on the same user twice without closing the counterparty ticket first.

.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