mirror of
https://github.com/haveno-dex/haveno.git
synced 2026-01-18 15:58:55 -05:00
Merge 87e5a887c6 into eb492d3ebd
This commit is contained in:
commit
beee784477
3 changed files with 19 additions and 1 deletions
|
|
@ -129,7 +129,7 @@ public class OfferBookService {
|
|||
replaceValidOffer(offer);
|
||||
announceOfferAdded(offer);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore illegal offers
|
||||
log.warn("Ignoring invalid offer {}: {}", offerPayload.getId(), e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
replaceInvalidOffer(offer); // offer can become valid later
|
||||
}
|
||||
|
|
@ -379,6 +379,12 @@ public class OfferBookService {
|
|||
throw new IllegalArgumentException("Offer with non-V3 node address is not allowed with offerId=" + offerPayload.getId());
|
||||
}
|
||||
|
||||
// validate market price margin
|
||||
double marketPriceMarginPct = offerPayload.getMarketPriceMarginPct();
|
||||
if (marketPriceMarginPct <= -1 || marketPriceMarginPct >= 1) {
|
||||
throw new IllegalArgumentException("Market price margin must be greater than -100% and less than 100% but was " + (marketPriceMarginPct * 100) + "% with offerId=" + offerPayload.getId());
|
||||
}
|
||||
|
||||
// validate against existing offers
|
||||
synchronized (validOffers) {
|
||||
int numOffersWithSharedKeyImages = 0;
|
||||
|
|
|
|||
|
|
@ -1629,6 +1629,15 @@ public class OpenOfferManager implements PeerManager.Listener, DecryptedDirectMe
|
|||
}
|
||||
}
|
||||
|
||||
// verify market price margin
|
||||
double marketPriceMarginPct = request.getOfferPayload().getMarketPriceMarginPct();
|
||||
if (marketPriceMarginPct <= -1 || marketPriceMarginPct >= 1) {
|
||||
errorMessage = "Market price margin must be greater than -100% and less than 100% but was " + (marketPriceMarginPct * 100) + "%";
|
||||
log.warn(errorMessage);
|
||||
sendAckMessage(request.getClass(), peer, request.getPubKeyRing(), request.getOfferId(), request.getUid(), false, errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// verify maker and taker fees
|
||||
boolean hasBuyerAsTakerWithoutDeposit = offer.getDirection() == OfferDirection.SELL && offer.isPrivateOffer() && offer.getChallengeHash() != null && offer.getChallengeHash().length() > 0 && offer.getTakerFeePct() == 0;
|
||||
if (hasBuyerAsTakerWithoutDeposit) {
|
||||
|
|
|
|||
|
|
@ -109,6 +109,9 @@ public class ValidateOffer extends Task<PlaceOfferModel> {
|
|||
if (!offer.isUseMarketBasedPrice()) checkArgument(offer.getPrice().isPositive(),
|
||||
"Price must be positive unless using market based price. price=" + offer.getPrice().toFriendlyString());
|
||||
|
||||
checkArgument(offer.getOfferPayload().getMarketPriceMarginPct() > -1 && offer.getOfferPayload().getMarketPriceMarginPct() < 1,
|
||||
"Market price margin must be greater than -100% and less than 100% but was " + (offer.getOfferPayload().getMarketPriceMarginPct() * 100) + "%");
|
||||
|
||||
checkArgument(offer.getDate().getTime() > 0,
|
||||
"Date must not be 0. date=" + offer.getDate().toString());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue