Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API PR part 2/2, adding the enableApi switch #976

Closed
wants to merge 8 commits into from
4 changes: 2 additions & 2 deletions common/src/main/java/io/bisq/common/locale/LocaleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ public class LocaleUtil {

public static List<Locale> 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<Locale> allLocales = new ArrayList<>();

allLocales.add(new Locale("bg", "", ""));
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/io/bisq/core/app/AppOptionKeys.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
6 changes: 5 additions & 1 deletion core/src/main/java/io/bisq/core/app/BisqEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -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) :
"";
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/io/bisq/core/app/BisqExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions gui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -366,5 +366,16 @@
<version>1.4.0</version>
</dependency>

<dependency>
<groupId>com.github.mrosseel</groupId>
<artifactId>bisq-api</artifactId>
<version>-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>com.github.bisq-network.bisq-exchange</groupId>
<artifactId>core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
15 changes: 6 additions & 9 deletions gui/src/main/java/io/bisq/gui/app/BisqApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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!
Expand Down
1 change: 0 additions & 1 deletion gui/src/main/java/io/bisq/gui/app/BisqAppModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down