mirror of
https://github.com/boldsuck/haveno.git
synced 2025-01-09 09:39:23 +00:00
fix popup for arbitrator to confirm dispute payout tx details
This commit is contained in:
parent
8460346feb
commit
024d5525e8
1 changed files with 19 additions and 17 deletions
|
@ -66,11 +66,12 @@ import javafx.scene.layout.GridPane;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import monero.daemon.model.MoneroTx;
|
import monero.wallet.model.MoneroDestination;
|
||||||
import monero.wallet.model.MoneroTxWallet;
|
import monero.wallet.model.MoneroTxWallet;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
import java.math.BigInteger;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -580,21 +581,17 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
||||||
Button cancelButton = tuple.second;
|
Button cancelButton = tuple.second;
|
||||||
|
|
||||||
closeTicketButton.setOnAction(e -> {
|
closeTicketButton.setOnAction(e -> {
|
||||||
|
|
||||||
// get or create dispute payout tx
|
|
||||||
MoneroTx payoutTx = null;
|
|
||||||
if (trade.isPayoutPublished()) payoutTx = trade.getPayoutTx();
|
|
||||||
else {
|
|
||||||
payoutTx = arbitrationManager.createDisputePayoutTx(trade, dispute.getContract(), disputeResult, false);
|
|
||||||
trade.getProcessModel().setUnsignedPayoutTx((MoneroTxWallet) payoutTx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// show confirmation
|
|
||||||
if (dispute.getSupportType() == SupportType.ARBITRATION &&
|
if (dispute.getSupportType() == SupportType.ARBITRATION &&
|
||||||
peersDisputeOptional.isPresent() &&
|
peersDisputeOptional.isPresent() &&
|
||||||
!peersDisputeOptional.get().isClosed()) {
|
!peersDisputeOptional.get().isClosed() &&
|
||||||
|
!trade.isPayoutPublished()) {
|
||||||
|
|
||||||
|
// create payout tx
|
||||||
|
MoneroTxWallet payoutTx = arbitrationManager.createDisputePayoutTx(trade, dispute.getContract(), disputeResult, false);
|
||||||
|
trade.getProcessModel().setUnsignedPayoutTx((MoneroTxWallet) payoutTx);
|
||||||
|
|
||||||
|
// show confirmation
|
||||||
showPayoutTxConfirmation(contract,
|
showPayoutTxConfirmation(contract,
|
||||||
disputeResult,
|
|
||||||
payoutTx,
|
payoutTx,
|
||||||
() -> doClose(closeTicketButton));
|
() -> doClose(closeTicketButton));
|
||||||
} else {
|
} else {
|
||||||
|
@ -609,12 +606,16 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPayoutTxConfirmation(Contract contract, DisputeResult disputeResult, MoneroTx payoutTx, ResultHandler resultHandler) {
|
private void showPayoutTxConfirmation(Contract contract, MoneroTxWallet payoutTx, ResultHandler resultHandler) {
|
||||||
BigInteger buyerPayoutAmount = disputeResult.getBuyerPayoutAmount();
|
|
||||||
|
// get buyer and seller destinations (order not preserved)
|
||||||
String buyerPayoutAddressString = contract.getBuyerPayoutAddressString();
|
String buyerPayoutAddressString = contract.getBuyerPayoutAddressString();
|
||||||
BigInteger sellerPayoutAmount = disputeResult.getSellerPayoutAmount();
|
|
||||||
String sellerPayoutAddressString = contract.getSellerPayoutAddressString();
|
String sellerPayoutAddressString = contract.getSellerPayoutAddressString();
|
||||||
BigInteger outputAmount = buyerPayoutAmount.add(sellerPayoutAmount);
|
List<MoneroDestination> destinations = payoutTx.getOutgoingTransfer().getDestinations();
|
||||||
|
boolean buyerFirst = destinations.get(0).getAddress().equals(buyerPayoutAddressString);
|
||||||
|
BigInteger buyerPayoutAmount = buyerFirst ? destinations.get(0).getAmount() : destinations.size() == 2 ? destinations.get(1).getAmount() : BigInteger.valueOf(0);
|
||||||
|
BigInteger sellerPayoutAmount = buyerFirst ? (destinations.size() == 2 ? destinations.get(1).getAmount() : BigInteger.valueOf(0)) : destinations.get(0).getAmount();
|
||||||
|
|
||||||
String buyerDetails = "";
|
String buyerDetails = "";
|
||||||
if (buyerPayoutAmount.compareTo(BigInteger.valueOf(0)) > 0) {
|
if (buyerPayoutAmount.compareTo(BigInteger.valueOf(0)) > 0) {
|
||||||
buyerDetails = Res.get("disputeSummaryWindow.close.txDetails.buyer",
|
buyerDetails = Res.get("disputeSummaryWindow.close.txDetails.buyer",
|
||||||
|
@ -627,6 +628,7 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
|
||||||
HavenoUtils.formatXmr(sellerPayoutAmount, true),
|
HavenoUtils.formatXmr(sellerPayoutAmount, true),
|
||||||
sellerPayoutAddressString);
|
sellerPayoutAddressString);
|
||||||
}
|
}
|
||||||
|
BigInteger outputAmount = buyerPayoutAmount.add(sellerPayoutAmount).add(payoutTx.getFee());
|
||||||
if (outputAmount.compareTo(BigInteger.valueOf(0)) > 0) {
|
if (outputAmount.compareTo(BigInteger.valueOf(0)) > 0) {
|
||||||
new Popup().width(900)
|
new Popup().width(900)
|
||||||
.headLine(Res.get("disputeSummaryWindow.close.txDetails.headline"))
|
.headLine(Res.get("disputeSummaryWindow.close.txDetails.headline"))
|
||||||
|
|
Loading…
Reference in a new issue