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

@ -80,6 +80,9 @@ public final class DisputeResult implements NetworkPayload {
@Setter @Setter
@Nullable @Nullable
private ChatMessage chatMessage; private ChatMessage chatMessage;
@Setter
@Nullable
private byte[] arbitratorSignature;
private long buyerPayoutAmount; private long buyerPayoutAmount;
private long sellerPayoutAmount; private long sellerPayoutAmount;
@Setter @Setter
@ -111,6 +114,7 @@ public final class DisputeResult implements NetworkPayload {
boolean screenCast, boolean screenCast,
String summaryNotes, String summaryNotes,
@Nullable ChatMessage chatMessage, @Nullable ChatMessage chatMessage,
@Nullable byte[] arbitratorSignature,
@Nullable String arbitratorPayoutTxSigned, @Nullable String arbitratorPayoutTxSigned,
@Nullable String arbitratorUpdatedMultisigHex, @Nullable String arbitratorUpdatedMultisigHex,
long buyerPayoutAmount, long buyerPayoutAmount,
@ -127,6 +131,7 @@ public final class DisputeResult implements NetworkPayload {
this.screenCastProperty.set(screenCast); this.screenCastProperty.set(screenCast);
this.summaryNotesProperty.set(summaryNotes); this.summaryNotesProperty.set(summaryNotes);
this.chatMessage = chatMessage; this.chatMessage = chatMessage;
this.arbitratorSignature = arbitratorSignature;
this.arbitratorSignedPayoutTxHex = arbitratorPayoutTxSigned; this.arbitratorSignedPayoutTxHex = arbitratorPayoutTxSigned;
this.arbitratorUpdatedMultisigHex = arbitratorUpdatedMultisigHex; this.arbitratorUpdatedMultisigHex = arbitratorUpdatedMultisigHex;
this.buyerPayoutAmount = buyerPayoutAmount; this.buyerPayoutAmount = buyerPayoutAmount;
@ -151,6 +156,7 @@ public final class DisputeResult implements NetworkPayload {
proto.getScreenCast(), proto.getScreenCast(),
proto.getSummaryNotes(), proto.getSummaryNotes(),
proto.getChatMessage() == null ? null : ChatMessage.fromPayloadProto(proto.getChatMessage()), proto.getChatMessage() == null ? null : ChatMessage.fromPayloadProto(proto.getChatMessage()),
proto.getArbitratorSignature().toByteArray(),
ProtoUtil.stringOrNullFromProto(proto.getArbitratorSignedPayoutTxHex()), ProtoUtil.stringOrNullFromProto(proto.getArbitratorSignedPayoutTxHex()),
ProtoUtil.stringOrNullFromProto(proto.getArbitratorUpdatedMultisigHex()), ProtoUtil.stringOrNullFromProto(proto.getArbitratorUpdatedMultisigHex()),
proto.getBuyerPayoutAmount(), proto.getBuyerPayoutAmount(),
@ -175,6 +181,7 @@ public final class DisputeResult implements NetworkPayload {
.setCloseDate(closeDate) .setCloseDate(closeDate)
.setIsLoserPublisher(isLoserPublisher); .setIsLoserPublisher(isLoserPublisher);
Optional.ofNullable(arbitratorSignature).ifPresent(arbitratorSignature -> builder.setArbitratorSignature(ByteString.copyFrom(arbitratorSignature)));
Optional.ofNullable(arbitratorSignedPayoutTxHex).ifPresent(arbitratorPayoutTxSigned -> builder.setArbitratorSignedPayoutTxHex(arbitratorPayoutTxSigned)); Optional.ofNullable(arbitratorSignedPayoutTxHex).ifPresent(arbitratorPayoutTxSigned -> builder.setArbitratorSignedPayoutTxHex(arbitratorPayoutTxSigned));
Optional.ofNullable(arbitratorUpdatedMultisigHex).ifPresent(arbitratorUpdatedMultisigHex -> builder.setArbitratorUpdatedMultisigHex(arbitratorUpdatedMultisigHex)); Optional.ofNullable(arbitratorUpdatedMultisigHex).ifPresent(arbitratorUpdatedMultisigHex -> builder.setArbitratorUpdatedMultisigHex(arbitratorUpdatedMultisigHex));
Optional.ofNullable(arbitratorPubKey).ifPresent(arbitratorPubKey -> builder.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey))); Optional.ofNullable(arbitratorPubKey).ifPresent(arbitratorPubKey -> builder.setArbitratorPubKey(ByteString.copyFrom(arbitratorPubKey)));
@ -257,6 +264,7 @@ public final class DisputeResult implements NetworkPayload {
",\n screenCastProperty=" + screenCastProperty + ",\n screenCastProperty=" + screenCastProperty +
",\n summaryNotesProperty=" + summaryNotesProperty + ",\n summaryNotesProperty=" + summaryNotesProperty +
",\n chatMessage=" + chatMessage + ",\n chatMessage=" + chatMessage +
",\n arbitratorSignature=" + Utilities.bytesAsHexString(arbitratorSignature) +
",\n arbitratorPayoutTxSigned=" + arbitratorSignedPayoutTxHex + ",\n arbitratorPayoutTxSigned=" + arbitratorSignedPayoutTxHex +
",\n arbitratorUpdatedMultisigHex=" + arbitratorUpdatedMultisigHex + ",\n arbitratorUpdatedMultisigHex=" + arbitratorUpdatedMultisigHex +
",\n buyerPayoutAmount=" + buyerPayoutAmount + ",\n buyerPayoutAmount=" + buyerPayoutAmount +

View File

@ -213,6 +213,7 @@ public class AccountAgeWitnessServiceTest {
null, null,
null, null,
null, null,
null,
100000, 100000,
0, 0,
null, null,

View File

@ -23,10 +23,10 @@ import bisq.desktop.components.BisqTextArea;
import bisq.desktop.components.InputTextField; import bisq.desktop.components.InputTextField;
import bisq.desktop.main.overlays.Overlay; import bisq.desktop.main.overlays.Overlay;
import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.main.overlays.popups.Popup;
import bisq.desktop.main.support.dispute.DisputeSummaryVerification;
import bisq.desktop.util.DisplayUtils; import bisq.desktop.util.DisplayUtils;
import bisq.desktop.util.Layout; import bisq.desktop.util.Layout;
import bisq.core.btc.model.XmrAddressEntry;
import bisq.core.btc.wallet.TradeWalletService; import bisq.core.btc.wallet.TradeWalletService;
import bisq.core.btc.wallet.XmrWalletService; import bisq.core.btc.wallet.XmrWalletService;
import bisq.core.locale.Res; import bisq.core.locale.Res;
@ -801,58 +801,45 @@ public class DisputeSummaryWindow extends Overlay<DisputeSummaryWindow> {
return; return;
} }
// boolean isRefundAgent = disputeManager instanceof RefundManager; boolean isRefundAgent = disputeManager instanceof RefundManager;
disputeResult.setLoserPublisher(isLoserPublisherCheckBox.isSelected()); disputeResult.setLoserPublisher(isLoserPublisherCheckBox.isSelected());
disputeResult.setCloseDate(new Date()); disputeResult.setCloseDate(new Date());
dispute.setDisputeResult(disputeResult); dispute.setDisputeResult(disputeResult);
dispute.setIsClosed(); dispute.setIsClosed();
// DisputeResult.Reason reason = disputeResult.getReason(); DisputeResult.Reason reason = disputeResult.getReason();
summaryNotesTextArea.textProperty().unbindBidirectional(disputeResult.summaryNotesProperty()); 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 textToSign = Res.get("disputeSummaryWindow.close.msg",
// String agentNodeAddress = checkNotNull(disputeManager.getAgentNodeAddress(dispute)).getFullAddress(); DisplayUtils.formatDateTime(disputeResult.getCloseDate()),
// Contract contract = dispute.getContract(); role,
// String currencyCode = contract.getOfferPayload().getCurrencyCode(); agentNodeAddress,
// String amount = formatter.formatCoinWithCode(contract.getTradeAmount()); dispute.getShortTradeId(),
// currencyCode,
// amount,
// String textToSign = Res.get("disputeSummaryWindow.close.msg", formatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount()),
// DisplayUtils.formatDateTime(disputeResult.getCloseDate()), formatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount()),
// role, Res.get("disputeSummaryWindow.reason." + reason.name()),
// agentNodeAddress, disputeResult.summaryNotesProperty().get()
// 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 summaryText = Res.get("disputeSummaryWindow.close.msg", if (reason == DisputeResult.Reason.OPTION_TRADE &&
DisplayUtils.formatDateTime(disputeResult.getCloseDate()), dispute.getChatMessages().size() > 1 &&
formatter.formatCoinWithCode(disputeResult.getBuyerPayoutAmount()), dispute.getChatMessages().get(1).isSystemMessage()) {
formatter.formatCoinWithCode(disputeResult.getSellerPayoutAmount()), textToSign += "\n" + dispute.getChatMessages().get(1).getMessage() + "\n";
disputeResult.summaryNotesProperty().get()); }
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"); 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.crypto.Sig;
import bisq.common.util.Utilities; import bisq.common.util.Utilities;
import java.security.KeyPair;
import java.security.PublicKey; import java.security.PublicKey;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -48,24 +49,23 @@ public class DisputeSummaryVerification {
public static String signAndApply(DisputeManager<? extends DisputeList<Dispute>> disputeManager, public static String signAndApply(DisputeManager<? extends DisputeList<Dispute>> disputeManager,
DisputeResult disputeResult, DisputeResult disputeResult,
String textToSign) { String textToSign) {
throw new RuntimeException("DisputeSummaryVerification.signAndApply() not implemented");
// byte[] hash = Hash.getSha256Hash(textToSign); byte[] hash = Hash.getSha256Hash(textToSign);
// KeyPair signatureKeyPair = disputeManager.getSignatureKeyPair(); KeyPair signatureKeyPair = disputeManager.getSignatureKeyPair();
// String sigAsHex; String sigAsHex;
// try { try {
// byte[] signature = Sig.sign(signatureKeyPair.getPrivate(), hash); byte[] signature = Sig.sign(signatureKeyPair.getPrivate(), hash);
// sigAsHex = Utilities.encodeToHex(signature); sigAsHex = Utilities.encodeToHex(signature);
// disputeResult.setArbitratorSignature(signature); disputeResult.setArbitratorSignature(signature);
// } catch (CryptoException e) { } catch (CryptoException e) {
// sigAsHex = "Signing failed"; sigAsHex = "Signing failed";
// } }
//
// return Res.get("disputeSummaryWindow.close.msgWithSig", return Res.get("disputeSummaryWindow.close.msgWithSig",
// textToSign, textToSign,
// SEPARATOR1, SEPARATOR1,
// sigAsHex, sigAsHex,
// SEPARATOR2); SEPARATOR2);
} }
public static String verifySignature(String input, public static String verifySignature(String input,

View File

@ -964,7 +964,7 @@ message DisputeResult {
bool screen_cast = 7; bool screen_cast = 7;
string summary_notes = 8; string summary_notes = 8;
ChatMessage chat_message = 9; ChatMessage chat_message = 9;
reserved 10; // was bytes arbitrator_signature = 10; bytes arbitrator_signature = 10;
int64 buyer_payout_amount = 11; int64 buyer_payout_amount = 11;
int64 seller_payout_amount = 12; int64 seller_payout_amount = 12;
bytes arbitrator_pub_key = 13; bytes arbitrator_pub_key = 13;