Skip to content

Commit

Permalink
set arbitrator payment account payloads on dispute opened
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Jan 25, 2025
1 parent e4714aa commit a6af155
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -537,15 +537,21 @@ protected void handleDisputeOpenedMessage(DisputeOpenedMessage message) {
throw e;
}

// try to validate payment account
// try to validate payment accounts
try {
DisputeValidation.validatePaymentAccountPayload(dispute); // TODO: add field to dispute details: valid, invalid, missing
DisputeValidation.validatePaymentAccountPayloads(dispute); // TODO: add field to dispute details: valid, invalid, missing
} catch (Exception e) {
log.error(ExceptionUtils.getStackTrace(e));
trade.prependErrorMessage(e.getMessage());
throw e;
}

// set arbitrator's payment account payloads
if (trade.isArbitrator()) {
if (trade.getBuyer().getPaymentAccountPayload() == null) trade.getBuyer().setPaymentAccountPayload(dispute.getBuyerPaymentAccountPayload());
if (trade.getSeller().getPaymentAccountPayload() == null) trade.getSeller().setPaymentAccountPayload(dispute.getSellerPaymentAccountPayload());
}

// get sender
TradePeer sender;
if (reOpen) { // re-open can come from either peer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@
@Slf4j
public class DisputeValidation {

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

public static void validateDisputeData(Dispute dispute) throws ValidationException {
Expand Down

0 comments on commit a6af155

Please sign in to comment.