mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
Merge branch 'master' into 2-api-bsq-swap-scratch
This commit is contained in:
commit
c177b3b834
7 changed files with 48 additions and 19 deletions
|
@ -27,7 +27,8 @@ configure(subprojects) {
|
|||
apply plugin: 'java'
|
||||
apply plugin: 'com.google.osdetector'
|
||||
|
||||
sourceCompatibility = 1.10
|
||||
sourceCompatibility = JavaVersion.VERSION_11
|
||||
targetCompatibility = JavaVersion.VERSION_11
|
||||
|
||||
ext { // in alphabetical order
|
||||
bcVersion = '1.63'
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package bisq.core.app;
|
||||
|
||||
import bisq.core.payment.TradeLimits;
|
||||
|
||||
import bisq.common.UserThread;
|
||||
import bisq.common.app.AppModule;
|
||||
import bisq.common.app.Version;
|
||||
|
@ -31,6 +33,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Slf4j
|
||||
public class BisqHeadlessAppMain extends BisqExecutable {
|
||||
protected HeadlessApp headlessApp;
|
||||
private TradeLimits tradeLimits;
|
||||
|
||||
public BisqHeadlessAppMain() {
|
||||
super("Bisq Daemon", "bisqd", "Bisq", Version.VERSION);
|
||||
|
@ -108,6 +111,9 @@ public class BisqHeadlessAppMain extends BisqExecutable {
|
|||
|
||||
@Override
|
||||
protected void startApplication() {
|
||||
// Pin that as it is used in PaymentMethods and verification in TradeStatistics
|
||||
tradeLimits = injector.getInstance(TradeLimits.class);
|
||||
|
||||
// We need to be in user thread! We mapped at launchApplication already...
|
||||
headlessApp.startApplication();
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import bisq.core.dao.DaoSetup;
|
|||
import bisq.core.dao.node.full.RpcService;
|
||||
import bisq.core.offer.OpenOfferManager;
|
||||
import bisq.core.offer.bsq_swap.OpenBsqSwapOfferService;
|
||||
import bisq.core.payment.TradeLimits;
|
||||
import bisq.core.support.dispute.arbitration.arbitrator.ArbitratorManager;
|
||||
|
||||
import bisq.network.p2p.NodeAddress;
|
||||
|
@ -62,6 +63,7 @@ public abstract class ExecutableForAppWithP2p extends BisqExecutable {
|
|||
private static final long SHUTDOWN_INTERVAL = TimeUnit.HOURS.toMillis(24);
|
||||
private volatile boolean stopped;
|
||||
private final long startTime = System.currentTimeMillis();
|
||||
private TradeLimits tradeLimits;
|
||||
|
||||
public ExecutableForAppWithP2p(String fullName, String scriptName, String appName, String version) {
|
||||
super(fullName, scriptName, appName, version);
|
||||
|
@ -76,6 +78,12 @@ public abstract class ExecutableForAppWithP2p extends BisqExecutable {
|
|||
UserThread.setExecutor(Executors.newSingleThreadExecutor(threadFactory));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startApplication() {
|
||||
// Pin that as it is used in PaymentMethods and verification in TradeStatistics
|
||||
tradeLimits = injector.getInstance(TradeLimits.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetupComplete() {
|
||||
log.info("onSetupComplete");
|
||||
|
|
|
@ -58,7 +58,9 @@ import java.time.LocalDateTime;
|
|||
import java.time.ZoneId;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
@ -80,6 +82,8 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||
|
||||
@JsonExclude
|
||||
private transient static final ZoneId ZONE_ID = ZoneId.systemDefault();
|
||||
@JsonExclude
|
||||
private transient static final long STRICT_FILTER_DATE = new GregorianCalendar(2021, Calendar.NOVEMBER, 1).getTime().getTime();
|
||||
|
||||
public static TradeStatistics3 from(Trade trade,
|
||||
@Nullable String referralId,
|
||||
|
@ -435,26 +439,37 @@ public final class TradeStatistics3 implements ProcessOncePersistableNetworkPayl
|
|||
if (currency == null) {
|
||||
return false;
|
||||
}
|
||||
long maxTradeLimit = Coin.COIN.multiply(2).value;
|
||||
try {
|
||||
// We cover only active payment methods. Retired ones will not be found by getActivePaymentMethodById.
|
||||
String paymentMethodId = getPaymentMethodId();
|
||||
Optional<PaymentMethod> optionalPaymentMethod = PaymentMethod.getActivePaymentMethod(paymentMethodId);
|
||||
if (optionalPaymentMethod.isPresent()) {
|
||||
maxTradeLimit = optionalPaymentMethod.get().getMaxTradeLimitAsCoin(currency).value;
|
||||
|
||||
boolean validMaxTradeLimit = true;
|
||||
boolean currencyFound = true;
|
||||
// We had historically higher trade limits and assets which are not in the currency list anymore, so we apply
|
||||
// the filter only for data after STRICT_FILTER_DATE.
|
||||
if (date > STRICT_FILTER_DATE) {
|
||||
long maxTradeLimit = Coin.COIN.multiply(2).value;
|
||||
try {
|
||||
// We cover only active payment methods. Retired ones will not be found by getActivePaymentMethodById.
|
||||
String paymentMethodId = getPaymentMethodId();
|
||||
Optional<PaymentMethod> optionalPaymentMethod = PaymentMethod.getActivePaymentMethod(paymentMethodId);
|
||||
if (optionalPaymentMethod.isPresent()) {
|
||||
maxTradeLimit = optionalPaymentMethod.get().getMaxTradeLimitAsCoin(currency).value;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("Error at isValid().", e);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("Error at isValid().", e);
|
||||
validMaxTradeLimit = amount <= maxTradeLimit;
|
||||
|
||||
currencyFound = CurrencyUtil.getCryptoCurrency(currency).isPresent() ||
|
||||
CurrencyUtil.getFiatCurrency(currency).isPresent();
|
||||
}
|
||||
|
||||
return amount > 0 &&
|
||||
amount <= maxTradeLimit &&
|
||||
validMaxTradeLimit &&
|
||||
price > 0 &&
|
||||
date > 0 &&
|
||||
paymentMethod != null &&
|
||||
!paymentMethod.isEmpty() &&
|
||||
!currency.isEmpty() &&
|
||||
(CurrencyUtil.getCryptoCurrency(currency).isPresent() ||
|
||||
CurrencyUtil.getFiatCurrency(currency).isPresent());
|
||||
currencyFound;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -90,12 +90,7 @@ public class BisqDaemonMain extends BisqHeadlessAppMain implements BisqSetup.Bis
|
|||
|
||||
@Override
|
||||
protected void startApplication() {
|
||||
// We need to be in user thread! We mapped at launchApplication already...
|
||||
headlessApp.startApplication();
|
||||
|
||||
// In headless mode we don't have an async behaviour so we trigger the setup by
|
||||
// calling onApplicationStarted.
|
||||
onApplicationStarted();
|
||||
super.startApplication();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -137,6 +137,8 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
|
|||
|
||||
@Override
|
||||
protected void startApplication() {
|
||||
super.startApplication();
|
||||
|
||||
Cookie cookie = injector.getInstance(User.class).getCookie();
|
||||
cookie.getAsOptionalBoolean(CookieKey.CLEAN_TOR_DIR_AT_RESTART).ifPresent(wasCleanTorDirSet -> {
|
||||
if (wasCleanTorDirSet) {
|
||||
|
|
|
@ -88,6 +88,8 @@ public class StatisticsMain extends ExecutableForAppWithP2p {
|
|||
|
||||
@Override
|
||||
protected void startApplication() {
|
||||
super.startApplication();
|
||||
|
||||
statistics.startApplication();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue