diff --git a/common/src/main/java/io/bisq/common/locale/LocaleUtil.java b/common/src/main/java/io/bisq/common/locale/LocaleUtil.java index d81a77bf947..78ca944797d 100644 --- a/common/src/main/java/io/bisq/common/locale/LocaleUtil.java +++ b/common/src/main/java/io/bisq/common/locale/LocaleUtil.java @@ -29,8 +29,8 @@ public class LocaleUtil { public static List getAllLocales() { - // derived form Locale.getAvailableLocales() and added some missing locales - // Key is ISO 639-1 code (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), value is ISO 3166 country code + // derived form Locale.getAvailableLocales() and added some missing locales + // Key is ISO 639-1 code (https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes), value is ISO 3166 country code List allLocales = new ArrayList<>(); allLocales.add(new Locale("bg", "", "")); diff --git a/core/src/main/java/io/bisq/core/app/AppOptionKeys.java b/core/src/main/java/io/bisq/core/app/AppOptionKeys.java index e00ff1f4ab1..5c1773492d1 100644 --- a/core/src/main/java/io/bisq/core/app/AppOptionKeys.java +++ b/core/src/main/java/io/bisq/core/app/AppOptionKeys.java @@ -8,4 +8,5 @@ public class AppOptionKeys { public static final String MAX_MEMORY = "maxMemory"; public static final String DUMP_STATISTICS = "dumpStatistics"; public static final String IGNORE_DEV_MSG_KEY = "ignoreDevMsg"; + public static final String ENABLE_API = "enableAPI"; } diff --git a/core/src/main/java/io/bisq/core/app/BisqEnvironment.java b/core/src/main/java/io/bisq/core/app/BisqEnvironment.java index 3539d333c72..5ab597cdc99 100644 --- a/core/src/main/java/io/bisq/core/app/BisqEnvironment.java +++ b/core/src/main/java/io/bisq/core/app/BisqEnvironment.java @@ -166,7 +166,7 @@ private static String appDataDir(String userDataDir, String appName) { private final String btcNodes, seedNodes, ignoreDevMsg, useTorForBtc, rpcUser, rpcPassword, rpcPort, rpcBlockNotificationPort, dumpBlockchainData, fullDaoNode, - myAddress, banList, dumpStatistics, maxMemory, socks5ProxyBtcAddress, + myAddress, banList, dumpStatistics, enableApi, maxMemory, socks5ProxyBtcAddress, socks5ProxyHttpAddress; @@ -200,6 +200,9 @@ public BisqEnvironment(PropertySource commandLineProperties) { dumpStatistics = commandLineProperties.containsProperty(AppOptionKeys.DUMP_STATISTICS) ? (String) commandLineProperties.getProperty(AppOptionKeys.DUMP_STATISTICS) : ""; + enableApi = commandLineProperties.containsProperty(AppOptionKeys.ENABLE_API) ? + (String) commandLineProperties.getProperty(AppOptionKeys.ENABLE_API) : + ""; maxMemory = commandLineProperties.containsProperty(AppOptionKeys.MAX_MEMORY) ? (String) commandLineProperties.getProperty(AppOptionKeys.MAX_MEMORY) : ""; @@ -344,6 +347,7 @@ private PropertySource defaultProperties() { setProperty(AppOptionKeys.APP_DATA_DIR_KEY, appDataDir); setProperty(AppOptionKeys.IGNORE_DEV_MSG_KEY, ignoreDevMsg); setProperty(AppOptionKeys.DUMP_STATISTICS, dumpStatistics); + setProperty(AppOptionKeys.ENABLE_API, enableApi); setProperty(AppOptionKeys.APP_NAME_KEY, appName); setProperty(AppOptionKeys.MAX_MEMORY, maxMemory); setProperty(AppOptionKeys.USER_DATA_DIR_KEY, userDataDir); diff --git a/core/src/main/java/io/bisq/core/app/BisqExecutable.java b/core/src/main/java/io/bisq/core/app/BisqExecutable.java index 40ef9aa33b5..d9b8fc1a93a 100644 --- a/core/src/main/java/io/bisq/core/app/BisqExecutable.java +++ b/core/src/main/java/io/bisq/core/app/BisqExecutable.java @@ -128,6 +128,10 @@ protected void customizeOptionParsing(OptionParser parser) { description("If set to true the trade statistics are stored as json file in the data dir.", false)) .withRequiredArg() .ofType(boolean.class); + parser.accepts(AppOptionKeys.ENABLE_API, + description("If set to true the trading api is enabled.", false)) + .withRequiredArg() + .ofType(boolean.class); parser.accepts(AppOptionKeys.PROVIDERS, description("Custom providers (comma separated)", false)) .withRequiredArg(); diff --git a/gui/pom.xml b/gui/pom.xml index 90b61af9914..151001fee6c 100644 --- a/gui/pom.xml +++ b/gui/pom.xml @@ -366,5 +366,16 @@ 1.4.0 + + com.github.mrosseel + bisq-api + -SNAPSHOT + + + com.github.bisq-network.bisq-exchange + core + + + diff --git a/gui/src/main/java/io/bisq/gui/app/BisqApp.java b/gui/src/main/java/io/bisq/gui/app/BisqApp.java index e4a04d8e3da..e78c38ac3aa 100644 --- a/gui/src/main/java/io/bisq/gui/app/BisqApp.java +++ b/gui/src/main/java/io/bisq/gui/app/BisqApp.java @@ -21,6 +21,7 @@ import ch.qos.logback.classic.Logger; import com.google.inject.Guice; import com.google.inject.Injector; +import io.bisq.api.service.BisqApiApplication; import io.bisq.common.CommonOptionKeys; import io.bisq.common.UserThread; import io.bisq.common.app.DevEnv; @@ -162,7 +163,7 @@ public void start(Stage stage) throws IOException { Security.addProvider(new BouncyCastleProvider()); final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork(); - final String currencyCode = baseCurrencyNetwork.getCurrencyCode(); + String currencyCode = baseCurrencyNetwork.getCurrencyCode(); Res.setBaseCurrencyCode(currencyCode); Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName()); CurrencyUtil.setBaseCurrencyCode(currencyCode); @@ -172,14 +173,10 @@ public void start(Stage stage) throws IOException { bisqAppModule = new BisqAppModule(bisqEnvironment, primaryStage); injector = Guice.createInjector(bisqAppModule); injector.getInstance(InjectorViewFactory.class).setInjector(injector); -/* - PrintWriter out = new PrintWriter(new File("grapher.dot"), "UTF-8"); - Injector injector = Guice.createInjector(new GraphvizModule()); - GraphvizGrapher grapher = injector.getInstance(GraphvizGrapher.class); - grapher.setOut(out); - grapher.setRankdir("TB"); - grapher.graph(injector); -*/ + + if(Boolean.valueOf(bisqEnvironment.getRequiredProperty(AppOptionKeys.ENABLE_API))) { + injector.getInstance(BisqApiApplication.class).run("server", "bisq-api.yml"); + } // All classes which are persisting objects need to be added here // Maintain order! diff --git a/gui/src/main/java/io/bisq/gui/app/BisqAppModule.java b/gui/src/main/java/io/bisq/gui/app/BisqAppModule.java index ce0485f8216..0615206c65b 100644 --- a/gui/src/main/java/io/bisq/gui/app/BisqAppModule.java +++ b/gui/src/main/java/io/bisq/gui/app/BisqAppModule.java @@ -78,7 +78,6 @@ protected void configure() { bind(NetworkProtoResolver.class).to(CoreNetworkProtoResolver.class).in(Singleton.class); bind(PersistenceProtoResolver.class).to(CorePersistenceProtoResolver.class).in(Singleton.class); - bind(Preferences.class).in(Singleton.class); // ordering is used for shut down sequence install(tradeModule());