diff --git a/core/src/main/java/haveno/core/offer/OfferFilterService.java b/core/src/main/java/haveno/core/offer/OfferFilterService.java index e64a1ee6eb..298fb51bcd 100644 --- a/core/src/main/java/haveno/core/offer/OfferFilterService.java +++ b/core/src/main/java/haveno/core/offer/OfferFilterService.java @@ -127,6 +127,9 @@ public class OfferFilterService { if (isMyInsufficientTradeLimit(offer)) { return Result.IS_MY_INSUFFICIENT_TRADE_LIMIT; } + if (!hasValidArbitrator(offer)) { + return Result.ARBITRATOR_NOT_VALIDATED; + } if (!hasValidSignature(offer)) { return Result.SIGNATURE_NOT_VALIDATED; } @@ -215,27 +218,28 @@ public class OfferFilterService { return result; } - private boolean hasValidSignature(Offer offer) { + private boolean hasValidArbitrator(Offer offer) { + Arbitrator arbitrator = getArbitrator(offer); + return arbitrator != null; + } - // get accepted arbitrator by address + private Arbitrator getArbitrator(Offer offer) { + + // get arbitrator by address Arbitrator arbitrator = user.getAcceptedArbitratorByAddress(offer.getOfferPayload().getArbitratorSigner()); + if (arbitrator != null) return arbitrator; - // accepted arbitrator is null if we are the signing arbitrator - if (arbitrator == null && offer.getOfferPayload().getArbitratorSigner() != null) { - Arbitrator thisArbitrator = user.getRegisteredArbitrator(); - if (thisArbitrator != null && thisArbitrator.getNodeAddress().equals(offer.getOfferPayload().getArbitratorSigner())) { - if (thisArbitrator.getNodeAddress().equals(p2PService.getNetworkNode().getNodeAddress())) arbitrator = thisArbitrator; // TODO: unnecessary to compare arbitrator and p2pservice address? - } else { - - // // otherwise log warning that arbitrator is unregistered - // List arbitratorAddresses = user.getAcceptedArbitrators().stream().map(Arbitrator::getNodeAddress).collect(Collectors.toList()); - // if (!arbitratorAddresses.isEmpty()) { - // log.warn("No arbitrator is registered with offer's signer. offerId={}, arbitrator signer={}, accepted arbitrators={}", offer.getId(), offer.getOfferPayload().getArbitratorSigner(), arbitratorAddresses); - // } - } - } + // check if we are the signing arbitrator + Arbitrator thisArbitrator = user.getRegisteredArbitrator(); + if (thisArbitrator != null && thisArbitrator.getNodeAddress().equals(offer.getOfferPayload().getArbitratorSigner())) return thisArbitrator; - if (arbitrator == null) return false; // invalid arbitrator + // cannot get arbitrator + return null; + } + + private boolean hasValidSignature(Offer offer) { + Arbitrator arbitrator = getArbitrator(offer); + if (arbitrator == null) return false; return HavenoUtils.isArbitratorSignatureValid(offer.getOfferPayload(), arbitrator); } diff --git a/core/src/main/java/haveno/core/offer/OpenOfferManager.java b/core/src/main/java/haveno/core/offer/OpenOfferManager.java index a928494c1d..710cb92d54 100644 --- a/core/src/main/java/haveno/core/offer/OpenOfferManager.java +++ b/core/src/main/java/haveno/core/offer/OpenOfferManager.java @@ -1189,7 +1189,7 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe } else if (openOffer.getOffer().getOfferPayload().getArbitratorSignature() == null) { throw new IllegalArgumentException("Offer " + openOffer.getId() + " has no arbitrator signature"); } else if (arbitrator == null) { - throw new IllegalArgumentException("Offer " + openOffer.getId() + " signed by unavailable arbitrator"); + throw new IllegalArgumentException("Offer " + openOffer.getId() + " signed by unregistered arbitrator"); } else if (!HavenoUtils.isArbitratorSignatureValid(openOffer.getOffer().getOfferPayload(), arbitrator)) { throw new IllegalArgumentException("Offer " + openOffer.getId() + " has invalid arbitrator signature"); } else if (openOffer.getOffer().getOfferPayload().getReserveTxKeyImages() == null || openOffer.getOffer().getOfferPayload().getReserveTxKeyImages().isEmpty() || openOffer.getReserveTxHash() == null || openOffer.getReserveTxHash().isEmpty()) { diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 9d500aefe5..8133a7b0f0 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -458,7 +458,7 @@ offerbook.warning.requireUpdateToNewVersion=Your version of Haveno is not compat offerbook.warning.offerWasAlreadyUsedInTrade=You cannot take this offer because you already took it earlier. \ It could be that your previous take-offer attempt resulted in a failed trade. -offerbook.warning.arbitratorNotValidated=This offer cannot be taken because the arbitrator is invalid. +offerbook.warning.arbitratorNotValidated=This offer cannot be taken because the arbitrator is not registered. offerbook.warning.signatureNotValidated=This offer cannot be taken because the arbitrator's signature is invalid. offerbook.warning.reserveFundsSpent=This offer cannot be taken because the reserved funds were already spent. diff --git a/core/src/main/resources/i18n/displayStrings_cs.properties b/core/src/main/resources/i18n/displayStrings_cs.properties index 16b6a05bba..8ca69463ca 100644 --- a/core/src/main/resources/i18n/displayStrings_cs.properties +++ b/core/src/main/resources/i18n/displayStrings_cs.properties @@ -442,7 +442,7 @@ offerbook.warning.requireUpdateToNewVersion=Vaše verze Haveno již není kompat offerbook.warning.offerWasAlreadyUsedInTrade=Tuto nabídku nemůžete přijmout, protože jste ji již dříve využili. \ Je možné, že váš předchozí pokus o přijetí nabídky vyústil v neúspěšný obchod. -offerbook.warning.arbitratorNotValidated=Tuto nabídku nelze přijmout, protože rozhodce je neplatný +offerbook.warning.arbitratorNotValidated=Tuto nabídku nelze přijmout, protože arbitr není registrován. offerbook.warning.signatureNotValidated=Tuto nabídku nelze přijmout, protože rozhodce má neplatný podpis offerbook.info.sellAtMarketPrice=Budete prodávat za tržní cenu (aktualizováno každou minutu). diff --git a/core/src/main/resources/i18n/displayStrings_tr.properties b/core/src/main/resources/i18n/displayStrings_tr.properties index 28034c72a3..d796e21e20 100644 --- a/core/src/main/resources/i18n/displayStrings_tr.properties +++ b/core/src/main/resources/i18n/displayStrings_tr.properties @@ -439,7 +439,7 @@ offerbook.warning.requireUpdateToNewVersion=Sizin Haveno sürümünüz artık ti offerbook.warning.offerWasAlreadyUsedInTrade=Bu teklifi alamazsınız çünkü daha önce aldınız. \ Önceki teklif alma girişiminiz başarısız bir ticaretle sonuçlanmış olabilir. -offerbook.warning.arbitratorNotValidated=Bu teklif, hakem geçersiz olduğu için alınamaz +offerbook.warning.arbitratorNotValidated=Bu teklif kabul edilemez çünkü hakem kayıtlı değil. offerbook.warning.signatureNotValidated=Bu teklif, hakemin imzası geçersiz olduğu için alınamaz offerbook.info.sellAtMarketPrice=Piyasa fiyatından satış yapacaksınız (her dakika güncellenir).