restore dispute summary message

This commit is contained in:
woodser 2021-11-10 04:47:37 -05:00
parent 673aa3a437
commit cd108387a2
5 changed files with 57 additions and 61 deletions

View file

@ -23,10 +23,10 @@ import bisq.desktop.components.BisqTextArea;
import bisq.desktop.components.InputTextField;
import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.support.dispute.DisputeSummaryVerification;
import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.Layout;
import bisq.core.btc.model.XmrAddressEntry;
import bisq.core.btc.wallet.TradeWalletService;
import bisq.core.btc.wallet.XmrWalletService;
import bisq.core.locale.Res;
@ -801,58 +801,45 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
return;
}
// boolean isRefundAgent = disputeManager instanceof RefundManager;
boolean isRefundAgent = disputeManager instanceof RefundManager;
disputeResult.setLoserPublisher(isLoserPublisherCheckBox.isSelected());
disputeResult.setCloseDate(new Date());
dispute.setDisputeResult(disputeResult);
dispute.setIsClosed();
// DisputeResult.Reason reason = disputeResult.getReason();
DisputeResult.Reason reason = disputeResult.getReason();
summaryNotesTextArea.textProperty().unbindBidirectional(disputeResult.summaryNotesProperty());
// TODO (woodser): not used for xmr? calls setArbitratorSignature()
String role = isRefundAgent ? Res.get("shared.refundAgent") : Res.get("shared.mediator");
String agentNodeAddress = checkNotNull(disputeManager.getAgentNodeAddress(dispute)).getFullAddress();
Contract contract = dispute.getContract();
String currencyCode = contract.getOfferPayload().getCurrencyCode();
String amount = formatter.formatCoinWithCode(contract.getTradeAmount());
// String role = isRefundAgent ? Res.get("shared.refundAgent") : Res.get("shared.mediator");
// String agentNodeAddress = checkNotNull(disputeManager.getAgentNodeAddress(dispute)).getFullAddress();
// Contract contract = dispute.getContract();
// String currencyCode = contract.getOfferPayload().getCurrencyCode();
// String amount = formatter.formatCoinWithCode(contract.getTradeAmount());
//
//
// String textToSign = Res.get("disputeSummaryWindow.close.msg",
// DisplayUtils.formatDateTime(disputeResult.getCloseDate()),
// role,
// agentNodeAddress,
// dispute.getShortTradeId(),
// currencyCode,
// amount,
// formatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount()),
// formatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount()),
// Res.get("disputeSummaryWindow.reason." + reason.name()),
// disputeResult.summaryNotesProperty().get()
// );
//
// if (reason == DisputeResult.Reason.OPTION_TRADE &&
// dispute.getChatMessages().size() > 1 &&
// dispute.getChatMessages().get(1).isSystemMessage()) {
// textToSign += "\n" + dispute.getChatMessages().get(1).getMessage() + "\n";
// }
//
// String summaryText = DisputeSummaryVerification.signAndApply(disputeManager, disputeResult, textToSign);
//
// if (isRefundAgent) {
// summaryText += Res.get("disputeSummaryWindow.close.nextStepsForRefundAgentArbitration");
// } else {
// summaryText += Res.get("disputeSummaryWindow.close.nextStepsForMediation");
// }
String textToSign = Res.get("disputeSummaryWindow.close.msg",
DisplayUtils.formatDateTime(disputeResult.getCloseDate()),
role,
agentNodeAddress,
dispute.getShortTradeId(),
currencyCode,
amount,
formatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount()),
formatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount()),
Res.get("disputeSummaryWindow.reason." + reason.name()),
disputeResult.summaryNotesProperty().get()
);
String summaryText = Res.get("disputeSummaryWindow.close.msg",
DisplayUtils.formatDateTime(disputeResult.getCloseDate()),
formatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount()),
formatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount()),
disputeResult.summaryNotesProperty().get());
if (reason == DisputeResult.Reason.OPTION_TRADE &&
dispute.getChatMessages().size() > 1 &&
dispute.getChatMessages().get(1).isSystemMessage()) {
textToSign += "\n" + dispute.getChatMessages().get(1).getMessage() + "\n";
}
if (dispute.isMediationDispute()) {
String summaryText = DisputeSummaryVerification.signAndApply(disputeManager, disputeResult, textToSign);
if (isRefundAgent) {
summaryText += Res.get("disputeSummaryWindow.close.nextStepsForRefundAgentArbitration");
} else {
summaryText += Res.get("disputeSummaryWindow.close.nextStepsForMediation");
}

View file

@ -33,6 +33,7 @@ import bisq.common.crypto.Hash;
import bisq.common.crypto.Sig;
import bisq.common.util.Utilities;
import java.security.KeyPair;
import java.security.PublicKey;
import lombok.extern.slf4j.Slf4j;
@ -48,24 +49,23 @@ public class DisputeSummaryVerification {
public static String signAndApply(DisputeManager<? extends DisputeList<Dispute>> disputeManager,
DisputeResult disputeResult,
String textToSign) {
throw new RuntimeException("DisputeSummaryVerification.signAndApply() not implemented");
// byte[] hash = Hash.getSha256Hash(textToSign);
// KeyPair signatureKeyPair = disputeManager.getSignatureKeyPair();
// String sigAsHex;
// try {
// byte[] signature = Sig.sign(signatureKeyPair.getPrivate(), hash);
// sigAsHex = Utilities.encodeToHex(signature);
// disputeResult.setArbitratorSignature(signature);
// } catch (CryptoException e) {
// sigAsHex = "Signing failed";
// }
//
// return Res.get("disputeSummaryWindow.close.msgWithSig",
// textToSign,
// SEPARATOR1,
// sigAsHex,
// SEPARATOR2);
byte[] hash = Hash.getSha256Hash(textToSign);
KeyPair signatureKeyPair = disputeManager.getSignatureKeyPair();
String sigAsHex;
try {
byte[] signature = Sig.sign(signatureKeyPair.getPrivate(), hash);
sigAsHex = Utilities.encodeToHex(signature);
disputeResult.setArbitratorSignature(signature);
} catch (CryptoException e) {
sigAsHex = "Signing failed";
}
return Res.get("disputeSummaryWindow.close.msgWithSig",
textToSign,
SEPARATOR1,
sigAsHex,
SEPARATOR2);
}
public static String verifySignature(String input,