improve error message when offer's arbitrator is not registered

This commit is contained in:
woodser 2025-05-25 08:57:32 -04:00 committed by GitHub
parent 050e6b907a
commit 4c30e4625b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 25 additions and 21 deletions

View file

@ -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<NodeAddress> 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);
}

View file

@ -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()) {

View file

@ -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.

View file

@ -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).

View file

@ -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).