set arbitrator payment account payloads on dispute opened

This commit is contained in:
woodser 2025-01-24 09:31:19 -05:00
parent e4714aab89
commit a6af1550a4
2 changed files with 13 additions and 4 deletions

View File

@ -537,15 +537,21 @@ public abstract class DisputeManager<T extends DisputeList<Dispute>> extends Sup
throw e; throw e;
} }
// try to validate payment account // try to validate payment accounts
try { 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) { } catch (Exception e) {
log.error(ExceptionUtils.getStackTrace(e)); log.error(ExceptionUtils.getStackTrace(e));
trade.prependErrorMessage(e.getMessage()); trade.prependErrorMessage(e.getMessage());
throw e; 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 // get sender
TradePeer sender; TradePeer sender;
if (reOpen) { // re-open can come from either peer if (reOpen) { // re-open can come from either peer

View File

@ -41,9 +41,12 @@ import static com.google.common.base.Preconditions.checkNotNull;
@Slf4j @Slf4j
public class DisputeValidation { 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 (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 { public static void validateDisputeData(Dispute dispute) throws ValidationException {