Merge pull request #5849 from chimp1984/add-limit-to-tradestats

Add checks for trade statistics
This commit is contained in:
Christoph Atteneder 2021-11-21 17:39:30 +01:00 committed by GitHub
commit e50cd42478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,12 +17,14 @@
package bisq.core.trade.statistics;
import bisq.core.locale.CurrencyUtil;
import bisq.core.monetary.Altcoin;
import bisq.core.monetary.AltcoinExchangeRate;
import bisq.core.monetary.Price;
import bisq.core.monetary.Volume;
import bisq.core.offer.Offer;
import bisq.core.offer.bisq_v1.OfferPayload;
import bisq.core.payment.payload.PaymentMethod;
import bisq.core.trade.model.bisq_v1.Trade;
import bisq.core.trade.model.bsq_swap.BsqSwapTrade;
import bisq.core.util.JsonUtil;
@ -430,13 +432,23 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
}
public boolean isValid() {
if (currency == null) {
return false;
}
long maxTradeLimit = Coin.COIN.multiply(2).value;
try {
maxTradeLimit = PaymentMethod.getPaymentMethodById(getPaymentMethod()).getMaxTradeLimitAsCoin(currency).value;
} catch (Exception ignore) {
}
return amount > 0 &&
amount <= maxTradeLimit &&
price > 0 &&
date > 0 &&
paymentMethod != null &&
!paymentMethod.isEmpty() &&
currency != null &&
!currency.isEmpty();
!currency.isEmpty() &&
(CurrencyUtil.getCryptoCurrency(currency).isPresent() ||
CurrencyUtil.getFiatCurrency(currency).isPresent());
}
@Override