Skip to content

Commit a6af155

Browse files
committed
set arbitrator payment account payloads on dispute opened
1 parent e4714aa commit a6af155

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

core/src/main/java/haveno/core/support/dispute/DisputeManager.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,15 +537,21 @@ protected void handleDisputeOpenedMessage(DisputeOpenedMessage message) {
537537
throw e;
538538
}
539539

540-
// try to validate payment account
540+
// try to validate payment accounts
541541
try {
542-
DisputeValidation.validatePaymentAccountPayload(dispute); // TODO: add field to dispute details: valid, invalid, missing
542+
DisputeValidation.validatePaymentAccountPayloads(dispute); // TODO: add field to dispute details: valid, invalid, missing
543543
} catch (Exception e) {
544544
log.error(ExceptionUtils.getStackTrace(e));
545545
trade.prependErrorMessage(e.getMessage());
546546
throw e;
547547
}
548548

549+
// set arbitrator's payment account payloads
550+
if (trade.isArbitrator()) {
551+
if (trade.getBuyer().getPaymentAccountPayload() == null) trade.getBuyer().setPaymentAccountPayload(dispute.getBuyerPaymentAccountPayload());
552+
if (trade.getSeller().getPaymentAccountPayload() == null) trade.getSeller().setPaymentAccountPayload(dispute.getSellerPaymentAccountPayload());
553+
}
554+
549555
// get sender
550556
TradePeer sender;
551557
if (reOpen) { // re-open can come from either peer

core/src/main/java/haveno/core/support/dispute/DisputeValidation.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@
4141
@Slf4j
4242
public class DisputeValidation {
4343

44-
public static void validatePaymentAccountPayload(Dispute dispute) throws ValidationException {
44+
public static void validatePaymentAccountPayloads(Dispute dispute) throws ValidationException {
4545
if (dispute.getSellerPaymentAccountPayload() == null) throw new ValidationException(dispute, "Seller's payment account payload is null in dispute opened for trade " + dispute.getTradeId());
46-
if (!Arrays.equals(dispute.getSellerPaymentAccountPayload().getHash(), dispute.getContract().getSellerPaymentAccountPayloadHash())) throw new ValidationException(dispute, "Hash of maker's payment account payload does not match contract");
46+
if (!Arrays.equals(dispute.getSellerPaymentAccountPayload().getHash(), dispute.getContract().getSellerPaymentAccountPayloadHash())) throw new ValidationException(dispute, "Hash of seller's payment account payload does not match contract");
47+
if (dispute.getBuyerPaymentAccountPayload() != null) {
48+
if (!Arrays.equals(dispute.getBuyerPaymentAccountPayload().getHash(), dispute.getContract().getBuyerPaymentAccountPayloadHash())) throw new ValidationException(dispute, "Hash of buyer's payment account payload does not match contract");
49+
}
4750
}
4851

4952
public static void validateDisputeData(Dispute dispute) throws ValidationException {

0 commit comments

Comments
 (0)