diff --git a/build.gradle b/build.gradle index 39d5fa4f9b..0406ff8c47 100644 --- a/build.gradle +++ b/build.gradle @@ -491,51 +491,57 @@ configure(project(':monitor')) { configure(project(':pricenode')) { apply plugin: "org.springframework.boot" + apply plugin: 'io.spring.dependency-management' + + mainClassName = 'bisq.price.Main' + version = file("src/main/resources/version.txt").text.trim() jar.manifest.attributes( "Implementation-Title": project.name, "Implementation-Version": version) + ext['log4j2.version'] = '2.17.0' + dependencies { - compile project(":core") - - compileOnly "org.projectlombok:lombok:$lombokVersion" + implementation project(":common") + implementation project(":core") annotationProcessor "org.projectlombok:lombok:$lombokVersion" - + compileOnly "org.projectlombok:lombok:$lombokVersion" implementation "com.google.code.gson:gson:$gsonVersion" + implementation "com.google.guava:guava:$guavaVersion" implementation "commons-codec:commons-codec:$codecVersion" implementation "org.apache.httpcomponents:httpcore:$httpcoreVersion" implementation("org.apache.httpcomponents:httpclient:$httpclientVersion") { exclude(module: 'commons-codec') } - compile("org.knowm.xchange:xchange-bitbay:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-btcmarkets:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-binance:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-bitfinex:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-bitflyer:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-bitstamp:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-cexio:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-coinmate:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-coinmarketcap:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-coinone:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-exmo:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-hitbtc:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-huobi:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-independentreserve:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-kraken:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-luno:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-mercadobitcoin:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-paribu:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-poloniex:$knowmXchangeVersion") - compile("org.knowm.xchange:xchange-quoine:$knowmXchangeVersion") - compile("org.springframework.boot:spring-boot-starter-web:$springBootVersion") - compile("org.springframework.boot:spring-boot-starter-actuator") - testCompile "org.junit.jupiter:junit-jupiter-api:$jupiterVersion" - testCompile "org.junit.jupiter:junit-jupiter-params:$jupiterVersion" - testRuntime("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion") - testCompileOnly "org.projectlombok:lombok:$lombokVersion" + implementation("org.knowm.xchange:xchange-binance:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-bitbay:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-bitfinex:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-bitflyer:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-bitstamp:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-btcmarkets:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-cexio:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-coinmarketcap:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-coinmate:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-coinone:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-exmo:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-hitbtc:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-huobi:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-independentreserve:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-kraken:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-luno:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-mercadobitcoin:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-paribu:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-poloniex:$knowmXchangeVersion") + implementation("org.knowm.xchange:xchange-quoine:$knowmXchangeVersion") + implementation("org.springframework.boot:spring-boot-starter-web:$springBootVersion") testAnnotationProcessor "org.projectlombok:lombok:$lombokVersion" + testCompileOnly "org.projectlombok:lombok:$lombokVersion" + testImplementation "org.junit.jupiter:junit-jupiter-api:$jupiterVersion" + testImplementation "org.junit.jupiter:junit-jupiter-params:$jupiterVersion" + testImplementation "org.mockito:mockito-core:$mockitoVersion" + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:$jupiterVersion") } test { diff --git a/common/src/main/java/bisq/common/config/Config.java b/common/src/main/java/bisq/common/config/Config.java index 015f38846e..8b5189947b 100644 --- a/common/src/main/java/bisq/common/config/Config.java +++ b/common/src/main/java/bisq/common/config/Config.java @@ -110,9 +110,11 @@ public class Config { public static final String API_PORT = "apiPort"; public static final String PREVENT_PERIODIC_SHUTDOWN_AT_SEED_NODE = "preventPeriodicShutdownAtSeedNode"; public static final String REPUBLISH_MAILBOX_ENTRIES = "republishMailboxEntries"; + public static final String LEGACY_FEE_DATAMAP = "dataMap"; public static final String BTC_TX_FEE = "btcTxFee"; public static final String BTC_MIN_TX_FEE = "btcMinTxFee"; public static final String BTC_FEES_TS = "bitcoinFeesTs"; + public static final String BTC_FEE_INFO = "bitcoinFeeInfo"; public static final String BYPASS_MEMPOOL_VALIDATION = "bypassMempoolValidation"; public static final String PASSWORD_REQUIRED = "passwordRequired"; diff --git a/pricenode/README.md b/pricenode/README.md index d71dcda6e6..2c5330e56f 100644 --- a/pricenode/README.md +++ b/pricenode/README.md @@ -47,7 +47,6 @@ To manually test endpoints, run each of the following: curl http://localhost:8080/getAllMarketPrices curl http://localhost:8080/getFees curl http://localhost:8080/getParams -curl http://localhost:8080/getVersion curl http://localhost:8080/info ``` diff --git a/pricenode/haveno-pricenode.service b/pricenode/haveno-pricenode.service index 8123387228..8e2fa59a91 100644 --- a/pricenode/haveno-pricenode.service +++ b/pricenode/haveno-pricenode.service @@ -1,16 +1,16 @@ [Unit] -Description=Bisq Price Node +Description=Haveno Price Node After=network.target [Service] -SyslogIdentifier=bisq-pricenode -EnvironmentFile=/etc/default/bisq-pricenode.env -ExecStart=/bisq/bisq/bisq-pricenode 2 +SyslogIdentifier=Haveno-pricenode +EnvironmentFile=/etc/default/Haveno-pricenode.env +ExecStart=/Haveno/Haveno/Haveno-pricenode 2 ExecStop=/bin/kill -TERM ${MAINPID} Restart=on-failure -User=bisq -Group=bisq +User=Haveno +Group=Haveno PrivateTmp=true ProtectSystem=full diff --git a/pricenode/install_pricenode_debian.sh b/pricenode/install_pricenode_debian.sh index e94b205eaf..e2ba13092e 100755 --- a/pricenode/install_pricenode_debian.sh +++ b/pricenode/install_pricenode_debian.sh @@ -16,7 +16,7 @@ HAVENO_USER=haveno HAVENO_GROUP=haveno HAVENO_HOME=/haveno -HAVENO_REPO_URL=https://github.com/haveno-dex/haveno +HAVENO_REPO_URL=https://github.com/haveno-network/haveno HAVENO_REPO_NAME=haveno HAVENO_REPO_TAG=master HAVENO_LATEST_RELEASE=master diff --git a/pricenode/src/main/java/bisq/price/PriceProvider.java b/pricenode/src/main/java/bisq/price/PriceProvider.java index 2e2b3f1af2..20af8ef56c 100644 --- a/pricenode/src/main/java/bisq/price/PriceProvider.java +++ b/pricenode/src/main/java/bisq/price/PriceProvider.java @@ -78,13 +78,14 @@ public abstract class PriceProvider implements SmartLifecycle, Supplier { } private void refresh() { - long ts = System.currentTimeMillis(); - - cachedResult = doGet(); - - log.info("refresh took {} ms.", (System.currentTimeMillis() - ts)); - - onRefresh(); + try { + long ts = System.currentTimeMillis(); + cachedResult = doGet(); + log.info("refresh took {} ms.", (System.currentTimeMillis() - ts)); + onRefresh(); + } catch (Exception e) { + log.warn("Error refreshing price provider {}", getClass()); + } } protected abstract T doGet(); diff --git a/pricenode/src/main/java/bisq/price/mining/FeeRateProvider.java b/pricenode/src/main/java/bisq/price/mining/FeeRateProvider.java index c201848b03..62dabf3f1a 100644 --- a/pricenode/src/main/java/bisq/price/mining/FeeRateProvider.java +++ b/pricenode/src/main/java/bisq/price/mining/FeeRateProvider.java @@ -26,7 +26,8 @@ import java.time.Duration; */ public abstract class FeeRateProvider extends PriceProvider { - public static final long MIN_FEE_RATE = 10; // satoshi/vbyte + public static final long MIN_FEE_RATE_FOR_WITHDRAWAL = 2; // satoshi/vbyte + public static final long MIN_FEE_RATE_FOR_TRADING = 10; // satoshi/vbyte public static final long MAX_FEE_RATE = 1000; public FeeRateProvider(Duration refreshInterval) { diff --git a/pricenode/src/main/java/bisq/price/mining/FeeRateService.java b/pricenode/src/main/java/bisq/price/mining/FeeRateService.java index cbbec03c8e..509daacb04 100644 --- a/pricenode/src/main/java/bisq/price/mining/FeeRateService.java +++ b/pricenode/src/main/java/bisq/price/mining/FeeRateService.java @@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory; * High-level mining {@link FeeRate} operations. */ @Service -class FeeRateService { +public class FeeRateService { private final List providers; protected final Logger log = LoggerFactory.getLogger(this.getClass()); @@ -78,15 +78,15 @@ class FeeRateService { // Calculate the average long averageFeeRate = (amountOfFeeRates.intValue() > 0) ? sumOfAllFeeRates.longValue() / amountOfFeeRates.intValue() - : FeeRateProvider.MIN_FEE_RATE; + : FeeRateProvider.MIN_FEE_RATE_FOR_TRADING; long averageMinFeeRate = (amountOfFeeRates.intValue() > 0) ? sumOfAllMinFeeRates.longValue() / amountOfFeeRates.intValue() - : FeeRateProvider.MIN_FEE_RATE; + : FeeRateProvider.MIN_FEE_RATE_FOR_WITHDRAWAL; // Make sure the returned value is within the min-max range - averageFeeRate = Math.max(averageFeeRate, FeeRateProvider.MIN_FEE_RATE); + averageFeeRate = Math.max(averageFeeRate, FeeRateProvider.MIN_FEE_RATE_FOR_TRADING); averageFeeRate = Math.min(averageFeeRate, FeeRateProvider.MAX_FEE_RATE); - averageMinFeeRate = Math.max(averageMinFeeRate, FeeRateProvider.MIN_FEE_RATE); + averageMinFeeRate = Math.max(averageMinFeeRate, FeeRateProvider.MIN_FEE_RATE_FOR_WITHDRAWAL); averageMinFeeRate = Math.min(averageMinFeeRate, FeeRateProvider.MAX_FEE_RATE); // Prepare response: Add timestamp of now @@ -101,7 +101,7 @@ class FeeRateService { // Build response return new HashMap<>() {{ putAll(metadata); - put("dataMap", allFeeRates); + put(Config.LEGACY_FEE_DATAMAP, allFeeRates); }}; } } diff --git a/pricenode/src/main/java/bisq/price/mining/providers/MempoolFeeRateProvider.java b/pricenode/src/main/java/bisq/price/mining/providers/MempoolFeeRateProvider.java index 5e4b07fb1c..d885aa3d37 100644 --- a/pricenode/src/main/java/bisq/price/mining/providers/MempoolFeeRateProvider.java +++ b/pricenode/src/main/java/bisq/price/mining/providers/MempoolFeeRateProvider.java @@ -85,24 +85,24 @@ abstract class MempoolFeeRateProvider extends FeeRateProvider { log.error("Error retrieving bitcoin mining fee estimation: " + e.getMessage()); } - return new FeeRate("BTC", MIN_FEE_RATE, MIN_FEE_RATE, Instant.now().getEpochSecond()); + return new FeeRate("BTC", MIN_FEE_RATE_FOR_TRADING, MIN_FEE_RATE_FOR_WITHDRAWAL, Instant.now().getEpochSecond()); } private FeeRate getEstimatedFeeRate() { Set> feeRatePredictions = getFeeRatePredictions(); long estimatedFeeRate = feeRatePredictions.stream() - .filter(p -> p.getKey().equalsIgnoreCase("fastestFee")) + .filter(p -> p.getKey().equalsIgnoreCase("halfHourFee")) .map(Map.Entry::getValue) .findFirst() - .map(r -> Math.max(r, MIN_FEE_RATE)) + .map(r -> Math.max(r, MIN_FEE_RATE_FOR_TRADING)) .map(r -> Math.min(r, MAX_FEE_RATE)) - .orElse(MIN_FEE_RATE); + .orElse(MIN_FEE_RATE_FOR_TRADING); long minimumFee = feeRatePredictions.stream() .filter(p -> p.getKey().equalsIgnoreCase("minimumFee")) .map(Map.Entry::getValue) .findFirst() .map(r -> Math.multiplyExact(r, 2)) // multiply the minimumFee by 2 (per wiz) - .orElse(MIN_FEE_RATE); + .orElse(MIN_FEE_RATE_FOR_WITHDRAWAL); log.info("Retrieved estimated mining fee of {} sat/vB and minimumFee of {} sat/vB from {}", estimatedFeeRate, minimumFee, getMempoolApiHostname()); return new FeeRate("BTC", estimatedFeeRate, minimumFee, Instant.now().getEpochSecond()); } diff --git a/pricenode/src/main/java/bisq/price/spot/ExchangeRateController.java b/pricenode/src/main/java/bisq/price/spot/ExchangeRateController.java index bd2f198fb3..07846f1839 100644 --- a/pricenode/src/main/java/bisq/price/spot/ExchangeRateController.java +++ b/pricenode/src/main/java/bisq/price/spot/ExchangeRateController.java @@ -18,6 +18,9 @@ package bisq.price.spot; import bisq.price.PriceController; +import bisq.price.mining.FeeRateService; + +import bisq.common.config.Config; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @@ -28,13 +31,28 @@ import java.util.Map; class ExchangeRateController extends PriceController { private final ExchangeRateService exchangeRateService; + private final FeeRateService feeRateService; - public ExchangeRateController(ExchangeRateService exchangeRateService) { + public ExchangeRateController(ExchangeRateService exchangeRateService, FeeRateService feeRateService) { this.exchangeRateService = exchangeRateService; + this.feeRateService = feeRateService; } @GetMapping(path = "/getAllMarketPrices") public Map getAllMarketPrices() { - return exchangeRateService.getAllMarketPrices(); + Map retVal = exchangeRateService.getAllMarketPrices(); + + // add the fee info to results + feeRateService.getFees().forEach((key, value) -> { + retVal.put(translateFieldName(key), value); + }); + + return retVal; + } + + static String translateFieldName(String name) { + if (name.equals(Config.LEGACY_FEE_DATAMAP)) + name = Config.BTC_FEE_INFO; // name changed for clarity + return name; } } diff --git a/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java b/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java index cf46401599..c9b61fa79f 100644 --- a/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java +++ b/pricenode/src/main/java/bisq/price/spot/ExchangeRateProvider.java @@ -33,11 +33,14 @@ import org.knowm.xchange.service.marketdata.MarketDataService; import org.knowm.xchange.service.marketdata.params.CurrencyPairsParam; import org.knowm.xchange.service.marketdata.params.Params; +import org.springframework.core.env.Environment; + import java.time.Duration; import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Date; @@ -59,21 +62,56 @@ import java.util.stream.Stream; */ public abstract class ExchangeRateProvider extends PriceProvider> { - public static final Set SUPPORTED_CRYPTO_CURRENCIES = CurrencyUtil.getAllSortedCryptoCurrencies().stream() - .map(TradeCurrency::getCode) - .collect(Collectors.toSet()); - - public static final Set SUPPORTED_FIAT_CURRENCIES = CurrencyUtil.getAllSortedFiatCurrencies().stream() - .map(TradeCurrency::getCode) - .collect(Collectors.toSet()); - + private static Set SUPPORTED_CRYPTO_CURRENCIES = new HashSet<>(); + private static Set SUPPORTED_FIAT_CURRENCIES = new HashSet<>(); private final String name; private final String prefix; + private final Environment env; - public ExchangeRateProvider(String name, String prefix, Duration refreshInterval) { + public ExchangeRateProvider(Environment env, String name, String prefix, Duration refreshInterval) { super(refreshInterval); this.name = name; this.prefix = prefix; + this.env = env; + } + + public Set getSupportedFiatCurrencies() { + if (SUPPORTED_FIAT_CURRENCIES.isEmpty()) { // one-time initialization + List excludedFiatCurrencies = + Arrays.asList(env.getProperty("bisq.price.fiatcurrency.excluded", "") + .toUpperCase().trim().split("\\s*,\\s*")); + String validatedExclusionList = excludedFiatCurrencies.stream() + .filter(ccy -> !ccy.isEmpty()) + .filter(CurrencyUtil::isFiatCurrency) + .collect(Collectors.toList()).toString(); + SUPPORTED_FIAT_CURRENCIES = CurrencyUtil.getAllSortedFiatCurrencies().stream() + .map(TradeCurrency::getCode) + .filter(ccy -> !validatedExclusionList.contains(ccy.toUpperCase())) + .collect(Collectors.toSet()); + log.info("fiat currencies excluded: {}", validatedExclusionList); + log.info("fiat currencies supported: {}", SUPPORTED_FIAT_CURRENCIES.size()); + } + return SUPPORTED_FIAT_CURRENCIES; + } + + public Set getSupportedCryptoCurrencies() { + if (SUPPORTED_CRYPTO_CURRENCIES.isEmpty()) { // one-time initialization + List excludedCryptoCurrencies = + Arrays.asList(env.getProperty("bisq.price.cryptocurrency.excluded", "") + .toUpperCase().trim().split("\\s*,\\s*")); + String validatedExclusionList = excludedCryptoCurrencies.stream() + .filter(ccy -> !ccy.isEmpty()) + .filter(CurrencyUtil::isCryptoCurrency) + .collect(Collectors.toList()).toString(); + SUPPORTED_CRYPTO_CURRENCIES = CurrencyUtil.getAllSortedCryptoCurrencies().stream() + .map(TradeCurrency::getCode) + .filter(ccy -> !validatedExclusionList.contains(ccy.toUpperCase())) + .collect(Collectors.toSet()); + SUPPORTED_CRYPTO_CURRENCIES.add("XMR"); // XMR is skipped because it's a base currency + log.info("crypto currencies excluded: {}", validatedExclusionList); + log.info("crypto currencies supported: {}", SUPPORTED_CRYPTO_CURRENCIES.size()); + } + return SUPPORTED_CRYPTO_CURRENCIES; } public String getName() { @@ -87,7 +125,7 @@ public abstract class ExchangeRateProvider extends PriceProvider "USD".equals(e.getCurrency()) || "LTC".equals(e.getCurrency())) + .filter(e -> "USD".equals(e.getCurrency()) || "XMR".equals(e.getCurrency()) || "ETH".equals(e.getCurrency()) || "BCH".equals(e.getCurrency())) .forEach(e -> log.info("BTC/{}: {}", e.getCurrency(), e.getPrice())); } @@ -119,13 +157,13 @@ public abstract class ExchangeRateProvider extends PriceProvider desiredFiatPairs = allCurrencyPairsOnExchange.stream() .filter(cp -> cp.base.equals(Currency.BTC)) - .filter(cp -> SUPPORTED_FIAT_CURRENCIES.contains(cp.counter.getCurrencyCode())) + .filter(cp -> getSupportedFiatCurrencies().contains(cp.counter.getCurrencyCode())) .collect(Collectors.toList()); // Find the desired altcoin pairs (pair format is ALT-BTC) List desiredCryptoPairs = allCurrencyPairsOnExchange.stream() .filter(cp -> cp.counter.equals(Currency.BTC)) - .filter(cp -> SUPPORTED_CRYPTO_CURRENCIES.contains(cp.base.getCurrencyCode())) + .filter(cp -> getSupportedCryptoCurrencies().contains(cp.base.getCurrencyCode())) .collect(Collectors.toList()); // Retrieve in bulk all tickers offered by the exchange diff --git a/pricenode/src/main/java/bisq/price/spot/providers/BTCMarkets.java b/pricenode/src/main/java/bisq/price/spot/providers/BTCMarkets.java index cab63f4ddd..34e884898f 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/BTCMarkets.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/BTCMarkets.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.btcmarkets.BTCMarketsExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class BTCMarkets extends ExchangeRateProvider { - public BTCMarkets() { - super("BTCMARKETS", "btcmarkets", Duration.ofMinutes(1)); + public BTCMarkets(Environment env) { + super(env, "BTCMARKETS", "btcmarkets", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Binance.java b/pricenode/src/main/java/bisq/price/spot/providers/Binance.java index 0536ed6dcf..9107cc08ee 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Binance.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Binance.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.binance.BinanceExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Binance extends ExchangeRateProvider { - public Binance() { - super("BINANCE", "binance", Duration.ofMinutes(1)); + public Binance(Environment env) { + super(env, "BINANCE", "binance", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Bitbay.java b/pricenode/src/main/java/bisq/price/spot/providers/Bitbay.java index b87a57210e..552b0f737a 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Bitbay.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Bitbay.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.bitbay.BitbayExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Bitbay extends ExchangeRateProvider { - public Bitbay() { - super("BITBAY", "bitbay", Duration.ofMinutes(1)); + public Bitbay(Environment env) { + super(env, "BITBAY", "bitbay", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/BitcoinAverage.java b/pricenode/src/main/java/bisq/price/spot/providers/BitcoinAverage.java index 4c8553b702..dae71fc06f 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/BitcoinAverage.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/BitcoinAverage.java @@ -20,6 +20,7 @@ package bisq.price.spot.providers; import bisq.price.spot.ExchangeRate; import bisq.price.spot.ExchangeRateProvider; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -34,12 +35,12 @@ import java.util.Set; @Component class BitcoinAverage extends ExchangeRateProvider { - public BitcoinAverage() { + public BitcoinAverage(Environment env) { // Simulate a deactivated BitcoinAverage provider // We still need the class to exist and be registered as a provider though, // because the returned data structure must contain the "btcAverageTs" key // for backward compatibility with Bisq clients which hardcode that key - super("BA", "btcAverage", Duration.ofMinutes(100)); + super(env, "BA", "btcAverage", Duration.ofMinutes(100)); } /** diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Bitfinex.java b/pricenode/src/main/java/bisq/price/spot/providers/Bitfinex.java index da8bcbbc3a..9c93a574d3 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Bitfinex.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Bitfinex.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.bitfinex.BitfinexExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Bitfinex extends ExchangeRateProvider { - public Bitfinex() { - super("BITFINEX", "bitfinex", Duration.ofMinutes(1)); + public Bitfinex(Environment env) { + super(env, "BITFINEX", "bitfinex", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Bitflyer.java b/pricenode/src/main/java/bisq/price/spot/providers/Bitflyer.java index a905f28c16..cdf392ed70 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Bitflyer.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Bitflyer.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.bitflyer.BitflyerExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Bitflyer extends ExchangeRateProvider { - public Bitflyer() { - super("BITFLYER", "bitflyer", Duration.ofMinutes(1)); + public Bitflyer(Environment env) { + super(env, "BITFLYER", "bitflyer", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Bitpay.java b/pricenode/src/main/java/bisq/price/spot/providers/Bitpay.java deleted file mode 100644 index 12b3dc3e39..0000000000 --- a/pricenode/src/main/java/bisq/price/spot/providers/Bitpay.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package bisq.price.spot.providers; - -import bisq.price.spot.ExchangeRate; -import bisq.price.spot.ExchangeRateProvider; -import bisq.price.util.bitpay.BitpayMarketData; -import bisq.price.util.bitpay.BitpayTicker; - -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.RequestEntity; -import org.springframework.stereotype.Component; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.UriComponentsBuilder; - -import java.time.Duration; - -import java.math.BigDecimal; -import java.math.RoundingMode; - -import java.util.Arrays; -import java.util.Date; -import java.util.HashSet; -import java.util.Set; -import java.util.function.Predicate; -import java.util.stream.Stream; - -@Component -class Bitpay extends ExchangeRateProvider { - - private final RestTemplate restTemplate = new RestTemplate(); - - public Bitpay() { - super("BITPAY", "bitpay", Duration.ofMinutes(1)); - } - - @Override - public Set doGet() { - - Set result = new HashSet(); - - Predicate isDesiredFiatPair = t -> SUPPORTED_FIAT_CURRENCIES.contains(t.getCode()); - Predicate isDesiredCryptoPair = t -> SUPPORTED_CRYPTO_CURRENCIES.contains(t.getCode()); - - getTickers() - .filter(isDesiredFiatPair.or(isDesiredCryptoPair)) - .forEach(ticker -> { - boolean useInverseRate = false; - if (SUPPORTED_CRYPTO_CURRENCIES.contains(ticker.getCode())) { - // Use inverse rate for alts, because the API returns the - // conversion rate in the opposite direction than what we need - // API returns the BTC/Alt rate, we need the Alt/BTC rate - useInverseRate = true; - } - - BigDecimal rate = ticker.getRate(); - // Find the inverse rate, while using enough decimals to reflect very - // small exchange rates - BigDecimal inverseRate = (rate.compareTo(BigDecimal.ZERO) > 0) ? - BigDecimal.ONE.divide(rate, 8, RoundingMode.HALF_UP) : - BigDecimal.ZERO; - - result.add(new ExchangeRate( - ticker.getCode(), - (useInverseRate ? inverseRate : rate), - new Date(), - this.getName() - )); - }); - - return result; - } - - private Stream getTickers() { - BitpayMarketData marketData = restTemplate.exchange( - RequestEntity - .get(UriComponentsBuilder - .fromUriString("https://bitpay.com/rates").build() - .toUri()) - .build(), - new ParameterizedTypeReference() { - } - ).getBody(); - - return Arrays.stream(marketData.getData()); - } -} diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Bitstamp.java b/pricenode/src/main/java/bisq/price/spot/providers/Bitstamp.java index f9fb9f5937..355155a23a 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Bitstamp.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Bitstamp.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.bitstamp.BitstampExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Bitstamp extends ExchangeRateProvider { - public Bitstamp() { - super("BITSTAMP", "bitstamp", Duration.ofMinutes(1)); + public Bitstamp(Environment env) { + super(env, "BITSTAMP", "bitstamp", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/CoinGecko.java b/pricenode/src/main/java/bisq/price/spot/providers/CoinGecko.java index 01de3b6be0..49bb97a9d5 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/CoinGecko.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/CoinGecko.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import bisq.price.util.coingecko.CoinGeckoMarketData; import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.env.Environment; import org.springframework.http.RequestEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @@ -44,8 +45,8 @@ class CoinGecko extends ExchangeRateProvider { private final RestTemplate restTemplate = new RestTemplate(); - public CoinGecko() { - super("COINGECKO", "coingecko", Duration.ofMinutes(1)); + public CoinGecko(Environment env) { + super(env, "COINGECKO", "coingecko", Duration.ofMinutes(1)); } @Override @@ -56,8 +57,8 @@ class CoinGecko extends ExchangeRateProvider { Set result = new HashSet(); - Predicate isDesiredFiatPair = t -> SUPPORTED_FIAT_CURRENCIES.contains(t.getKey()); - Predicate isDesiredCryptoPair = t -> SUPPORTED_CRYPTO_CURRENCIES.contains(t.getKey()); + Predicate isDesiredFiatPair = t -> getSupportedFiatCurrencies().contains(t.getKey()); + Predicate isDesiredCryptoPair = t -> getSupportedCryptoCurrencies().contains(t.getKey()); getMarketData().getRates().entrySet().stream() .filter(isDesiredFiatPair.or(isDesiredCryptoPair)) @@ -65,7 +66,7 @@ class CoinGecko extends ExchangeRateProvider { .forEach((key, ticker) -> { boolean useInverseRate = false; - if (SUPPORTED_CRYPTO_CURRENCIES.contains(key)) { + if (getSupportedCryptoCurrencies().contains(key)) { // Use inverse rate for alts, because the API returns the // conversion rate in the opposite direction than what we need // API returns the BTC/Alt rate, we need the Alt/BTC rate diff --git a/pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java b/pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java index 64d5650814..ce882f5490 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/CoinMarketCap.java @@ -20,6 +20,7 @@ package bisq.price.spot.providers; import bisq.price.spot.ExchangeRate; import bisq.price.spot.ExchangeRateProvider; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -33,8 +34,8 @@ import java.util.Set; @Component class CoinMarketCap extends ExchangeRateProvider { - public CoinMarketCap() { - super("CMC", "coinmarketcap", Duration.ofMinutes(5)); // large data structure, so don't request it too often + public CoinMarketCap(Environment env) { + super(env, "CMC", "coinmarketcap", Duration.ofMinutes(5)); // large data structure, so don't request it too often } /** diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Coinone.java b/pricenode/src/main/java/bisq/price/spot/providers/Coinone.java index e99e390ec4..8ca7235aa6 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Coinone.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Coinone.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.coinone.CoinoneExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Coinone extends ExchangeRateProvider { - public Coinone() { - super("COINONE", "coinone", Duration.ofMinutes(1)); + public Coinone(Environment env) { + super(env, "COINONE", "coinone", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Coinpaprika.java b/pricenode/src/main/java/bisq/price/spot/providers/Coinpaprika.java index bd95376e24..7dbd77122c 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Coinpaprika.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Coinpaprika.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import bisq.price.util.coinpaprika.CoinpaprikaMarketData; import org.springframework.core.ParameterizedTypeReference; +import org.springframework.core.env.Environment; import org.springframework.http.RequestEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; @@ -55,8 +56,8 @@ class Coinpaprika extends ExchangeRateProvider { "INR, MYR, NOK, PKR, SEK, TWD, ZAR, VND, BOB, COP, PEN, ARS, ISK") .replace(" ", ""); // Strip any spaces - public Coinpaprika() { - super("COINPAPRIKA", "coinpaprika", Duration.ofMinutes(1)); + public Coinpaprika(Environment env) { + super(env, "COINPAPRIKA", "coinpaprika", Duration.ofMinutes(1)); } @Override @@ -67,7 +68,7 @@ class Coinpaprika extends ExchangeRateProvider { Set result = new HashSet(); - Predicate isDesiredFiatPair = t -> SUPPORTED_FIAT_CURRENCIES.contains(t.getKey()); + Predicate isDesiredFiatPair = t -> getSupportedFiatCurrencies().contains(t.getKey()); getMarketData().getQuotes().entrySet().stream() .filter(isDesiredFiatPair) diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Exmo.java b/pricenode/src/main/java/bisq/price/spot/providers/Exmo.java deleted file mode 100644 index a70e495b8e..0000000000 --- a/pricenode/src/main/java/bisq/price/spot/providers/Exmo.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package bisq.price.spot.providers; - -import bisq.price.spot.ExchangeRate; -import bisq.price.spot.ExchangeRateProvider; - -import org.knowm.xchange.exmo.ExmoExchange; - -import org.springframework.stereotype.Component; - -import java.time.Duration; - -import java.util.Set; - -@Component -class Exmo extends ExchangeRateProvider { - - public Exmo() { - // API rate limit = 10 calls / second from the same IP ( see https://exmo.com/en/api ) - super("EXMO", "exmo", Duration.ofMinutes(1)); - } - - @Override - public Set doGet() { - // Supported fiat: EUR, PLN, RUB, UAH (Ukrainian hryvnia), USD - // Supported alts: DASH, DOGE, ETC, ETH, LTC, XMR, ZEC - return doGet(ExmoExchange.class); - } - -} diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Huobi.java b/pricenode/src/main/java/bisq/price/spot/providers/Huobi.java index 4cfe9f7e9e..a64b96681c 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Huobi.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Huobi.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.huobi.HuobiExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Huobi extends ExchangeRateProvider { - public Huobi() { - super("HUOBI", "huobi", Duration.ofMinutes(1)); + public Huobi(Environment env) { + super(env, "HUOBI", "huobi", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/IndependentReserve.java b/pricenode/src/main/java/bisq/price/spot/providers/IndependentReserve.java index 073db18c8c..930f995f38 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/IndependentReserve.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/IndependentReserve.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.independentreserve.IndependentReserveExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class IndependentReserve extends ExchangeRateProvider { - public IndependentReserve() { - super("IndependentReserve", "independentreserve", Duration.ofMinutes(1)); + public IndependentReserve(Environment env) { + super(env, "IndependentReserve", "independentreserve", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Kraken.java b/pricenode/src/main/java/bisq/price/spot/providers/Kraken.java index bafbd8aa20..98c899f1d4 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Kraken.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Kraken.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.kraken.KrakenExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Kraken extends ExchangeRateProvider { - public Kraken() { - super("KRAKEN", "kraken", Duration.ofMinutes(1)); + public Kraken(Environment env) { + super(env, "KRAKEN", "kraken", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Luno.java b/pricenode/src/main/java/bisq/price/spot/providers/Luno.java index 22d8a7e2ff..371d4005e7 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Luno.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Luno.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.luno.LunoExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Luno extends ExchangeRateProvider { - public Luno() { - super("LUNO", "luno", Duration.ofMinutes(1)); + public Luno(Environment env) { + super(env, "LUNO", "luno", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/MercadoBitcoin.java b/pricenode/src/main/java/bisq/price/spot/providers/MercadoBitcoin.java index 78c2cca313..9deed9d264 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/MercadoBitcoin.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/MercadoBitcoin.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.mercadobitcoin.MercadoBitcoinExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class MercadoBitcoin extends ExchangeRateProvider { - public MercadoBitcoin() { - super("MercadoBitcoin", "mercadobitcoin", Duration.ofMinutes(1)); + public MercadoBitcoin(Environment env) { + super(env, "MercadoBitcoin", "mercadobitcoin", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Paribu.java b/pricenode/src/main/java/bisq/price/spot/providers/Paribu.java index 6421ddf0a6..3d3b3875eb 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Paribu.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Paribu.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.paribu.ParibuExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Paribu extends ExchangeRateProvider { - public Paribu() { - super("PARIBU", "paribu", Duration.ofMinutes(1)); + public Paribu(Environment env) { + super(env, "PARIBU", "paribu", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java b/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java index 4fd13d9fc3..d24368e561 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Poloniex.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.poloniex.PoloniexExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Poloniex extends ExchangeRateProvider { - public Poloniex() { - super("POLO", "poloniex", Duration.ofMinutes(1)); + public Poloniex(Environment env) { + super(env, "POLO", "poloniex", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/spot/providers/Quoine.java b/pricenode/src/main/java/bisq/price/spot/providers/Quoine.java index e4c958921d..0fa82f28bd 100644 --- a/pricenode/src/main/java/bisq/price/spot/providers/Quoine.java +++ b/pricenode/src/main/java/bisq/price/spot/providers/Quoine.java @@ -22,6 +22,7 @@ import bisq.price.spot.ExchangeRateProvider; import org.knowm.xchange.quoine.QuoineExchange; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; import java.time.Duration; @@ -31,8 +32,8 @@ import java.util.Set; @Component class Quoine extends ExchangeRateProvider { - public Quoine() { - super("QUOINE", "quoine", Duration.ofMinutes(1)); + public Quoine(Environment env) { + super(env, "QUOINE", "quoine", Duration.ofMinutes(1)); } @Override diff --git a/pricenode/src/main/java/bisq/price/util/VersionController.java b/pricenode/src/main/java/bisq/price/util/VersionController.java deleted file mode 100644 index 7ccf4641e7..0000000000 --- a/pricenode/src/main/java/bisq/price/util/VersionController.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package bisq.price.util; - -import bisq.price.PriceController; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.actuate.info.Info; -import org.springframework.boot.actuate.info.InfoContributor; -import org.springframework.core.io.Resource; -import org.springframework.util.FileCopyUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.io.IOException; -import java.io.InputStreamReader; - -@RestController -class VersionController extends PriceController implements InfoContributor { - - private final String version; - - public VersionController(@Value("classpath:version.txt") Resource versionTxt) throws IOException { - this.version = FileCopyUtils.copyToString( - new InputStreamReader( - versionTxt.getInputStream() - ) - ).trim(); - } - - @GetMapping(path = "/getVersion") - public String getVersion() { - return version; - } - - @Override - public void contribute(Info.Builder builder) { - builder.withDetail("version", version); - } -} diff --git a/pricenode/src/main/resources/application.properties b/pricenode/src/main/resources/application.properties index 07107b430c..5f97b25cc6 100644 --- a/pricenode/src/main/resources/application.properties +++ b/pricenode/src/main/resources/application.properties @@ -1,3 +1,4 @@ +server.port=8078 spring.jackson.serialization.indent_output=true # To enable another fee estimation endpoint, simply uncomment one of the following lines @@ -7,3 +8,5 @@ bisq.price.mining.providers.mempoolHostname.2=mempool.emzy.de bisq.price.mining.providers.mempoolHostname.3=mempool.ninja bisq.price.mining.providers.mempoolHostname.4=mempool.bisq.services # bisq.price.mining.providers.mempoolHostname.5=someHostOrIP +bisq.price.fiatcurrency.excluded=LBP,ARS +bisq.price.cryptocurrency.excluded= diff --git a/pricenode/src/test/java/bisq/price/AbstractExchangeRateProviderTest.java b/pricenode/src/test/java/bisq/price/AbstractExchangeRateProviderTest.java index a459dc68b4..911f45439d 100644 --- a/pricenode/src/test/java/bisq/price/AbstractExchangeRateProviderTest.java +++ b/pricenode/src/test/java/bisq/price/AbstractExchangeRateProviderTest.java @@ -30,7 +30,7 @@ public abstract class AbstractExchangeRateProviderTest { // Sanity checks assertTrue(retrievedExchangeRates.size() > 0); - checkProviderCurrencyPairs(retrievedExchangeRates); + checkProviderCurrencyPairs(exchangeProvider, retrievedExchangeRates); } /** @@ -40,24 +40,24 @@ public abstract class AbstractExchangeRateProviderTest { * * @param retrievedExchangeRates Exchange rates retrieved from the provider */ - private void checkProviderCurrencyPairs(Set retrievedExchangeRates) { + private void checkProviderCurrencyPairs(ExchangeRateProvider exchangeProvider, Set retrievedExchangeRates) { Set retrievedRatesCurrencies = retrievedExchangeRates.stream() .map(ExchangeRate::getCurrency) .collect(Collectors.toSet()); - Set supportedFiatCurrenciesRetrieved = ExchangeRateProvider.SUPPORTED_FIAT_CURRENCIES.stream() + Set supportedFiatCurrenciesRetrieved = exchangeProvider.getSupportedFiatCurrencies().stream() .filter(f -> retrievedRatesCurrencies.contains(f)) .collect(Collectors.toCollection(TreeSet::new)); log.info("Retrieved rates for supported fiat currencies: " + supportedFiatCurrenciesRetrieved); - Set supportedCryptoCurrenciesRetrieved = ExchangeRateProvider.SUPPORTED_CRYPTO_CURRENCIES.stream() + Set supportedCryptoCurrenciesRetrieved = exchangeProvider.getSupportedCryptoCurrencies().stream() .filter(c -> retrievedRatesCurrencies.contains(c)) .collect(Collectors.toCollection(TreeSet::new)); log.info("Retrieved rates for supported altcoins: " + supportedCryptoCurrenciesRetrieved); Set supportedCurrencies = Sets.union( - ExchangeRateProvider.SUPPORTED_CRYPTO_CURRENCIES, - ExchangeRateProvider.SUPPORTED_FIAT_CURRENCIES); + exchangeProvider.getSupportedCryptoCurrencies(), + exchangeProvider.getSupportedFiatCurrencies()); Set unsupportedCurrencies = Sets.difference(retrievedRatesCurrencies, supportedCurrencies); assertTrue("Retrieved exchange rates contain unsupported currencies: " + unsupportedCurrencies, diff --git a/pricenode/src/test/java/bisq/price/mining/FeeRateServiceTest.java b/pricenode/src/test/java/bisq/price/mining/FeeRateServiceTest.java index 7298d7143e..8f47584a41 100644 --- a/pricenode/src/test/java/bisq/price/mining/FeeRateServiceTest.java +++ b/pricenode/src/test/java/bisq/price/mining/FeeRateServiceTest.java @@ -47,13 +47,13 @@ public class FeeRateServiceTest { // Even with no working providers, we expect the service to return pre-configured // minimum fee rate - doSanityChecksForRetrievedData(retrievedData, FeeRateProvider.MIN_FEE_RATE); + doSanityChecksForRetrievedData(retrievedData, FeeRateProvider.MIN_FEE_RATE_FOR_TRADING); } @Test public void getFees_singleProvider_feeBelowMin() { // One working provider, which returns a fee lower than the minimum - long providerFee = FeeRateProvider.MIN_FEE_RATE - 3; + long providerFee = FeeRateProvider.MIN_FEE_RATE_FOR_TRADING - 3; FeeRateService service = new FeeRateService( Collections.singletonList( buildDummyReachableMempoolFeeRateProvider(providerFee))); @@ -62,7 +62,7 @@ public class FeeRateServiceTest { // When the provider returns a value below the expected min, the service should // return the min - doSanityChecksForRetrievedData(retrievedData, FeeRateProvider.MIN_FEE_RATE); + doSanityChecksForRetrievedData(retrievedData, FeeRateProvider.MIN_FEE_RATE_FOR_TRADING); } @Test @@ -84,14 +84,14 @@ public class FeeRateServiceTest { public void getFees_multipleProviders() { // 3 providers, returning 1xMIN, 2xMIN, 3xMIN FeeRateService service = new FeeRateService(asList( - buildDummyReachableMempoolFeeRateProvider(FeeRateProvider.MIN_FEE_RATE * 1), - buildDummyReachableMempoolFeeRateProvider(FeeRateProvider.MIN_FEE_RATE * 2), - buildDummyReachableMempoolFeeRateProvider(FeeRateProvider.MIN_FEE_RATE * 3))); + buildDummyReachableMempoolFeeRateProvider(FeeRateProvider.MIN_FEE_RATE_FOR_TRADING * 1), + buildDummyReachableMempoolFeeRateProvider(FeeRateProvider.MIN_FEE_RATE_FOR_TRADING * 2), + buildDummyReachableMempoolFeeRateProvider(FeeRateProvider.MIN_FEE_RATE_FOR_TRADING * 3))); Map retrievedData = service.getFees(); // The service should then return the average, which is 2xMIN - doSanityChecksForRetrievedData(retrievedData, FeeRateProvider.MIN_FEE_RATE * 2); + doSanityChecksForRetrievedData(retrievedData, FeeRateProvider.MIN_FEE_RATE_FOR_TRADING * 2); } /** @@ -103,7 +103,7 @@ public class FeeRateServiceTest { // providers), we always expect a non-zero timestamp assertNotEquals(0L, retrievedData.get(Config.BTC_FEES_TS)); - Map retrievedDataMap = (Map) retrievedData.get("dataMap"); + Map retrievedDataMap = (Map) retrievedData.get(Config.LEGACY_FEE_DATAMAP); assertEquals(2, retrievedDataMap.size()); assertEquals(expectedFeeRate, retrievedDataMap.get(Config.BTC_TX_FEE)); } diff --git a/pricenode/src/test/java/bisq/price/mining/providers/MempoolFeeRateProviderTest.java b/pricenode/src/test/java/bisq/price/mining/providers/MempoolFeeRateProviderTest.java index 65b013043b..999e550745 100644 --- a/pricenode/src/test/java/bisq/price/mining/providers/MempoolFeeRateProviderTest.java +++ b/pricenode/src/test/java/bisq/price/mining/providers/MempoolFeeRateProviderTest.java @@ -50,7 +50,7 @@ public class MempoolFeeRateProviderTest { FeeRate retrievedFeeRate = feeRateProvider.doGet(); // Check that the FeeRateProvider returns a fee within the defined parameters - assertTrue(retrievedFeeRate.getPrice() >= FeeRateProvider.MIN_FEE_RATE); + assertTrue(retrievedFeeRate.getPrice() >= FeeRateProvider.MIN_FEE_RATE_FOR_TRADING); assertTrue(retrievedFeeRate.getPrice() <= FeeRateProvider.MAX_FEE_RATE); } @@ -61,7 +61,7 @@ public class MempoolFeeRateProviderTest { MempoolFeeRateProvider dummyProvider = new MempoolFeeRateProvider.First(env) { @Override protected FeeRate doGet() { - return new FeeRate("BTC", feeRate, MIN_FEE_RATE, Instant.now().getEpochSecond()); + return new FeeRate("BTC", feeRate, MIN_FEE_RATE_FOR_WITHDRAWAL, Instant.now().getEpochSecond()); } }; diff --git a/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java b/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java index 23e4f7de76..c6c6c06ed3 100644 --- a/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java +++ b/pricenode/src/test/java/bisq/price/spot/ExchangeRateServiceTest.java @@ -17,6 +17,11 @@ package bisq.price.spot; +import bisq.core.locale.CurrencyUtil; + +import org.springframework.core.env.Environment; +import org.springframework.core.env.StandardEnvironment; + import com.google.common.collect.Sets; import org.apache.commons.lang3.RandomStringUtils; @@ -46,10 +51,9 @@ import org.junit.jupiter.api.Test; import static java.lang.Thread.sleep; import static java.util.Arrays.asList; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.Mockito.*; public class ExchangeRateServiceTest { @@ -156,6 +160,72 @@ public class ExchangeRateServiceTest { assertNotEquals(0L, retrievedData.get(dummyProvider2.getPrefix() + "Ts")); } + /** + * Tests the scenario when currencies are excluded from the PriceNode feed via configuration settings + */ + @Test + public void getAllMarketPrices_withMultipleProviders_excludedCurrencyCodes() { + String excludedCcyString = "LBP,USD,EUR"; + Environment mockedEnvironment = mock(Environment.class); + when(mockedEnvironment.getProperty(eq("bisq.price.fiatcurrency.excluded"), anyString())).thenReturn(excludedCcyString); + + class MockedExchangeRateProvider extends ExchangeRateProvider { + MockedExchangeRateProvider() { + super(mockedEnvironment, "ExchangeName", "EXCH", Duration.ofDays(1)); + } + + @Override + public boolean isRunning() { + return true; + } + + @Override + public Set doGet() { + HashSet exchangeRates = new HashSet<>(); + // Simulate rates for all the supported ccys + for (String rateCurrencyCode : getSupportedFiatCurrencies()) { + exchangeRates.add(new ExchangeRate( + rateCurrencyCode, + RandomUtils.nextDouble(1, 1000), // random price + System.currentTimeMillis(), + getName())); // ExchangeRateProvider name + } + return exchangeRates; + } + } + + Logger exchangeRateProviderLogger; + String LIST_APPENDER_NAME2 = "testListAppender2"; + exchangeRateProviderLogger = (Logger) LoggerFactory.getLogger(MockedExchangeRateProvider.class); + ListAppender listAppender2 = new ListAppender<>(); + listAppender2.setName(LIST_APPENDER_NAME2); + listAppender2.start(); + exchangeRateProviderLogger.addAppender(listAppender2); + + // we request rates for all currencies, and check that: + // (a) the provider supplies more currency rates than the number of currencies we are trying to exclude (sanity test), + // (b) the number of missing currency rates equals the number of currencies we told PriceNode to exclude, + // (c) none of the rates supplied are for an excluded currency. + + Set excludedFiatCurrencies = new HashSet<>(asList(excludedCcyString.split(","))); + MockedExchangeRateProvider mockedExchangeRateProvider = new MockedExchangeRateProvider(); + Set exchangeRates = mockedExchangeRateProvider.doGet(); + assertTrue(exchangeRates.size() > excludedFiatCurrencies.size()); + int numSortedFiatCurrencies = CurrencyUtil.getAllSortedFiatCurrencies().size(); + int numCurrenciesFromProvider = mockedExchangeRateProvider.getSupportedFiatCurrencies().size(); + int missingCurrencyCount = numSortedFiatCurrencies - numCurrenciesFromProvider; + assertEquals(missingCurrencyCount, excludedFiatCurrencies.size()); + for (ExchangeRate exchangeRate : exchangeRates) { + assertFalse(excludedCcyString.contains(exchangeRate.getCurrency())); + } + List logsList = ((ListAppender) exchangeRateProviderLogger.getAppender(LIST_APPENDER_NAME2)).list; + assertEquals(3, logsList.size()); + assertEquals(Level.INFO, logsList.get(1).getLevel()); + assertTrue(logsList.get(0).getFormattedMessage().endsWith("will refresh every PT24H")); + assertTrue(logsList.get(1).getFormattedMessage().endsWith("fiat currencies excluded: [LBP, USD, EUR]")); + assertTrue(logsList.get(2).getFormattedMessage().endsWith("fiat currencies supported: " + numCurrenciesFromProvider)); + } + /** * Performs generic sanity checks on the response format and contents. * @@ -259,6 +329,7 @@ public class ExchangeRateServiceTest { */ private ExchangeRateProvider buildDummyExchangeRateProvider(int numberOfRatesAvailable) { ExchangeRateProvider dummyProvider = new ExchangeRateProvider( + new StandardEnvironment(), "ExchangeName-" + getRandomAlphaNumericString(5), "EXCH-" + getRandomAlphaNumericString(3), Duration.ofDays(1)) { @@ -298,6 +369,7 @@ public class ExchangeRateServiceTest { private ExchangeRateProvider buildDummyExchangeRateProvider(Set rateCurrencyCodes) { ExchangeRateProvider dummyProvider = new ExchangeRateProvider( + new StandardEnvironment(), "ExchangeName-" + getRandomAlphaNumericString(5), "EXCH-" + getRandomAlphaNumericString(3), Duration.ofDays(1)) { diff --git a/pricenode/src/test/java/bisq/price/spot/providers/BTCMarketsTest.java b/pricenode/src/test/java/bisq/price/spot/providers/BTCMarketsTest.java index f75ea02584..b876d2ecd7 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/BTCMarketsTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/BTCMarketsTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class BTCMarketsTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new BTCMarkets()); + doGet_successfulCall(new BTCMarkets(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/BinanceTest.java b/pricenode/src/test/java/bisq/price/spot/providers/BinanceTest.java index 0b309d642c..90c2a59054 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/BinanceTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/BinanceTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class BinanceTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Binance()); + doGet_successfulCall(new Binance(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/BitbayTest.java b/pricenode/src/test/java/bisq/price/spot/providers/BitbayTest.java index 0c5beabad4..5d2a7b3d98 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/BitbayTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/BitbayTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class BitbayTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Bitbay()); + doGet_successfulCall(new Bitbay(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/BitfinexTest.java b/pricenode/src/test/java/bisq/price/spot/providers/BitfinexTest.java index 265994db53..26361d6f45 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/BitfinexTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/BitfinexTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class BitfinexTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Bitfinex()); + doGet_successfulCall(new Bitfinex(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/BitflyerTest.java b/pricenode/src/test/java/bisq/price/spot/providers/BitflyerTest.java index ed9d6ea63d..cf8a7b3ebc 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/BitflyerTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/BitflyerTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class BitflyerTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Bitflyer()); + doGet_successfulCall(new Bitflyer(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/BitpayTest.java b/pricenode/src/test/java/bisq/price/spot/providers/BitpayTest.java deleted file mode 100644 index f1fcb13807..0000000000 --- a/pricenode/src/test/java/bisq/price/spot/providers/BitpayTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package bisq.price.spot.providers; - -import bisq.price.AbstractExchangeRateProviderTest; - -import lombok.extern.slf4j.Slf4j; - -import org.junit.jupiter.api.Test; - -@Slf4j -public class BitpayTest extends AbstractExchangeRateProviderTest { - - @Test - public void doGet_successfulCall() { - doGet_successfulCall(new Bitpay()); - } - -} diff --git a/pricenode/src/test/java/bisq/price/spot/providers/BitstampTest.java b/pricenode/src/test/java/bisq/price/spot/providers/BitstampTest.java index 522310efbf..8d6741c232 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/BitstampTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/BitstampTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class BitstampTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Bitstamp()); + doGet_successfulCall(new Bitstamp(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/CoinGeckoTest.java b/pricenode/src/test/java/bisq/price/spot/providers/CoinGeckoTest.java index ef4b5684f3..714c1c6059 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/CoinGeckoTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/CoinGeckoTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class CoinGeckoTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new CoinGecko()); + doGet_successfulCall(new CoinGecko(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/CoinoneTest.java b/pricenode/src/test/java/bisq/price/spot/providers/CoinoneTest.java index 64ecf1323f..8a318c7bc1 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/CoinoneTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/CoinoneTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class CoinoneTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Coinone()); + doGet_successfulCall(new Coinone(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/CoinpaprikaTest.java b/pricenode/src/test/java/bisq/price/spot/providers/CoinpaprikaTest.java index 0e326aae5d..3262e5fdf8 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/CoinpaprikaTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/CoinpaprikaTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class CoinpaprikaTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Coinpaprika()); + doGet_successfulCall(new Coinpaprika(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/ExmoTest.java b/pricenode/src/test/java/bisq/price/spot/providers/ExmoTest.java deleted file mode 100644 index 5ed098d0fa..0000000000 --- a/pricenode/src/test/java/bisq/price/spot/providers/ExmoTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * This file is part of Haveno. - * - * Haveno is free software: you can redistribute it and/or modify it - * under the terms of the GNU Affero General Public License as published by - * the Free Software Foundation, either version 3 of the License, or (at - * your option) any later version. - * - * Haveno is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public - * License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with Haveno. If not, see . - */ - -package bisq.price.spot.providers; - -import bisq.price.AbstractExchangeRateProviderTest; - -import lombok.extern.slf4j.Slf4j; - -import org.junit.jupiter.api.Test; - -@Slf4j -public class ExmoTest extends AbstractExchangeRateProviderTest { - - @Test - public void doGet_successfulCall() { - doGet_successfulCall(new Exmo()); - } - -} diff --git a/pricenode/src/test/java/bisq/price/spot/providers/HuobiTest.java b/pricenode/src/test/java/bisq/price/spot/providers/HuobiTest.java index 572d659125..01e42fa72d 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/HuobiTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/HuobiTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class HuobiTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Huobi()); + doGet_successfulCall(new Huobi(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/IndependentReserveTest.java b/pricenode/src/test/java/bisq/price/spot/providers/IndependentReserveTest.java index bdcb169f05..1c3b7096f7 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/IndependentReserveTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/IndependentReserveTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class IndependentReserveTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new IndependentReserve()); + doGet_successfulCall(new IndependentReserve(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/KrakenTest.java b/pricenode/src/test/java/bisq/price/spot/providers/KrakenTest.java index 4160fe86f8..68096f5e0f 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/KrakenTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/KrakenTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class KrakenTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Kraken()); + doGet_successfulCall(new Kraken(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/LunoTest.java b/pricenode/src/test/java/bisq/price/spot/providers/LunoTest.java index e8c3ce3e63..a11ff36cd1 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/LunoTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/LunoTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class LunoTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Luno()); + doGet_successfulCall(new Luno(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/MercadoBitcoinTest.java b/pricenode/src/test/java/bisq/price/spot/providers/MercadoBitcoinTest.java index 9c54264ecd..e58bed774e 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/MercadoBitcoinTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/MercadoBitcoinTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class MercadoBitcoinTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new MercadoBitcoin()); + doGet_successfulCall(new MercadoBitcoin(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/ParibuTest.java b/pricenode/src/test/java/bisq/price/spot/providers/ParibuTest.java index 207d83a0e3..0b0332e599 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/ParibuTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/ParibuTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class ParibuTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Paribu()); + doGet_successfulCall(new Paribu(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/PoloniexTest.java b/pricenode/src/test/java/bisq/price/spot/providers/PoloniexTest.java index 01830ce5fa..57944c2420 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/PoloniexTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/PoloniexTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class PoloniexTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Poloniex()); + doGet_successfulCall(new Poloniex(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/spot/providers/QuoineTest.java b/pricenode/src/test/java/bisq/price/spot/providers/QuoineTest.java index 2723889b52..4bf83c3f48 100644 --- a/pricenode/src/test/java/bisq/price/spot/providers/QuoineTest.java +++ b/pricenode/src/test/java/bisq/price/spot/providers/QuoineTest.java @@ -19,6 +19,8 @@ package bisq.price.spot.providers; import bisq.price.AbstractExchangeRateProviderTest; +import org.springframework.core.env.StandardEnvironment; + import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test; @@ -28,7 +30,7 @@ public class QuoineTest extends AbstractExchangeRateProviderTest { @Test public void doGet_successfulCall() { - doGet_successfulCall(new Quoine()); + doGet_successfulCall(new Quoine(new StandardEnvironment())); } } diff --git a/pricenode/src/test/java/bisq/price/util/VersionControllerTest.java b/pricenode/src/test/java/bisq/price/util/VersionControllerTest.java deleted file mode 100644 index 86e4f9bb76..0000000000 --- a/pricenode/src/test/java/bisq/price/util/VersionControllerTest.java +++ /dev/null @@ -1,21 +0,0 @@ -package bisq.price.util; - -import org.springframework.core.io.FileSystemResource; - -import java.io.IOException; - -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class VersionControllerTest { - - @Test - public void getVersion() throws IOException { - VersionController controller = new VersionController( - new FileSystemResource("src/main/resources/version.txt")); - - String version = controller.getVersion(); - assertTrue(version.length() > 0); - } -}