From ce579b78ca0a58400f6af2c53834843779843b2a Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 22 Feb 2023 13:06:22 -0500 Subject: [PATCH] arbitrator sends same dispute payout tx to both peers on resolve w/ grpc fix npe in trade.get*DepositTx() --- .../main/java/bisq/core/api/CoreDisputesService.java | 11 +++++++---- .../bisq/core/support/dispute/DisputeManager.java | 12 +++++------- .../dispute/arbitration/ArbitrationManager.java | 4 ++-- core/src/main/java/bisq/core/trade/Trade.java | 5 ++--- .../main/overlays/windows/DisputeSummaryWindow.java | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/core/src/main/java/bisq/core/api/CoreDisputesService.java b/core/src/main/java/bisq/core/api/CoreDisputesService.java index e10ea648f9..c3c97eaec2 100644 --- a/core/src/main/java/bisq/core/api/CoreDisputesService.java +++ b/core/src/main/java/bisq/core/api/CoreDisputesService.java @@ -170,14 +170,17 @@ public class CoreDisputesService { } applyPayoutAmountsToDisputeResult(payout, winningDispute, disputeResult, customWinnerAmount); - // close dispute ticket - closeDisputeTicket(arbitrationManager, winningDispute, disputeResult, null, () -> { + // create dispute payout tx + MoneroTxWallet disputePayoutTx = arbitrationManager.createDisputePayoutTx(trade, winningDispute.getContract(), disputeResult, false); + + // close winning dispute ticket + closeDisputeTicket(arbitrationManager, winningDispute, disputeResult, disputePayoutTx, () -> { arbitrationManager.requestPersistence(); }, (errMessage, err) -> { throw new IllegalStateException(errMessage, err); }); - // close peer's dispute ticket + // close loser's dispute ticket var peersDisputeOptional = arbitrationManager.getDisputesAsObservableList().stream() .filter(d -> tradeId.equals(d.getTradeId()) && winningDispute.getTraderId() != d.getTraderId()) .findFirst(); @@ -186,7 +189,7 @@ public class CoreDisputesService { var peerDisputeResult = createDisputeResult(peerDispute, winner, reason, summaryNotes, closeDate); peerDisputeResult.setBuyerPayoutAmount(disputeResult.getBuyerPayoutAmount()); peerDisputeResult.setSellerPayoutAmount(disputeResult.getSellerPayoutAmount()); - closeDisputeTicket(arbitrationManager, peerDispute, peerDisputeResult, null, () -> { + closeDisputeTicket(arbitrationManager, peerDispute, peerDisputeResult, disputePayoutTx, () -> { arbitrationManager.requestPersistence(); }, (errMessage, err) -> { throw new IllegalStateException(errMessage, err); diff --git a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java index 393eeffee9..5ef6406bea 100644 --- a/core/src/main/java/bisq/core/support/dispute/DisputeManager.java +++ b/core/src/main/java/bisq/core/support/dispute/DisputeManager.java @@ -708,7 +708,7 @@ public abstract class DisputeManager> extends Sup if (trade == null) throw new RuntimeException("Dispute trade " + dispute.getTradeId() + " does not exist"); // create dispute payout tx if not given - if (payoutTx == null) payoutTx = createDisputePayoutTx(trade, dispute, disputeResult, false); // can be null if already published or we don't have receiver's multisig hex + if (payoutTx == null) payoutTx = createDisputePayoutTx(trade, dispute.getContract(), disputeResult, false); // can be null if already published or we don't have receiver's multisig hex // persist result in dispute's chat message once boolean resending = disputeResult.getChatMessage() != null; @@ -814,15 +814,14 @@ public abstract class DisputeManager> extends Sup // Utils /////////////////////////////////////////////////////////////////////////////////////////// - public MoneroTxWallet createDisputePayoutTx(Trade trade, Dispute dispute, DisputeResult disputeResult, boolean skipMultisigImport) { + public MoneroTxWallet createDisputePayoutTx(Trade trade, Contract contract, DisputeResult disputeResult, boolean skipMultisigImport) { // sync and save wallet trade.syncWallet(); trade.saveWallet(); - // create unsigned dispute payout tx if not already published and arbitrator has trader's updated multisig info - TradePeer receiver = trade.getTradePeer(dispute.getTraderPubKeyRing()); - if (!trade.isPayoutPublished() && receiver.getUpdatedMultisigHex() != null) { + // create unsigned dispute payout tx if not already published + if (!trade.isPayoutPublished()) { MoneroWallet multisigWallet = trade.getWallet(); // import multisig hex @@ -840,10 +839,9 @@ public abstract class DisputeManager> extends Sup try { // trade wallet must be synced - if (trade.getWallet().isMultisigImportNeeded()) throw new RuntimeException("Arbitrator's wallet needs updated multisig hex to create payout tx which means a trader must have already broadcast the payout tx for trade " + dispute.getTradeId()); + if (trade.getWallet().isMultisigImportNeeded()) throw new RuntimeException("Arbitrator's wallet needs updated multisig hex to create payout tx which means a trader must have already broadcast the payout tx for trade " + trade.getId()); // collect winner and loser payout address and amounts - Contract contract = dispute.getContract(); String winnerPayoutAddress = disputeResult.getWinner() == Winner.BUYER ? (contract.isBuyerMakerAndSellerTaker() ? contract.getMakerPayoutAddressString() : contract.getTakerPayoutAddressString()) : (contract.isBuyerMakerAndSellerTaker() ? contract.getTakerPayoutAddressString() : contract.getMakerPayoutAddressString()); diff --git a/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java b/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java index a79ef638be..0607269dcf 100644 --- a/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java +++ b/core/src/main/java/bisq/core/support/dispute/arbitration/ArbitrationManager.java @@ -292,7 +292,7 @@ public final class ArbitrationManager extends DisputeManager { closeTicketButton.setOnAction(e -> { - // create payout tx - MoneroTxWallet payoutTx = arbitrationManager.createDisputePayoutTx(trade, dispute, disputeResult, false); + // get or create payout tx + MoneroTxWallet payoutTx = trade.isPayoutPublished() ? trade.getPayoutTx() : arbitrationManager.createDisputePayoutTx(trade, dispute.getContract(), disputeResult, false); // show confirmation if (dispute.getSupportType() == SupportType.ARBITRATION &&