Merge branch 'upstream-dev' into route_bitcoinj_over_jtoryproxy

This commit is contained in:
danda 2016-07-19 16:44:02 -07:00
commit 6198307d76
22 changed files with 177 additions and 116 deletions

View File

@ -1,6 +1,6 @@
package io.bitsquare.common;
public class OptionKeys {
public class CommonOptionKeys {
public static final String LOG_LEVEL_KEY = "logLevel";
public static final String IGNORE_DEV_MSG_KEY = "ignoreDevMsg";
}

View File

@ -19,7 +19,7 @@ package io.bitsquare.alert;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.bitsquare.common.OptionKeys;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.crypto.KeyRing;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.p2p.storage.HashMapChangedListener;
@ -56,7 +56,7 @@ public class AlertManager {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public AlertManager(P2PService p2PService, KeyRing keyRing, User user, @Named(OptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
public AlertManager(P2PService p2PService, KeyRing keyRing, User user, @Named(CommonOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
this.p2PService = p2PService;
this.keyRing = keyRing;
this.user = user;

View File

@ -19,7 +19,7 @@ package io.bitsquare.alert;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.bitsquare.common.OptionKeys;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.crypto.KeyRing;
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
import io.bitsquare.p2p.Message;
@ -58,7 +58,7 @@ public class PrivateNotificationManager {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public PrivateNotificationManager(P2PService p2PService, KeyRing keyRing, @Named(OptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
public PrivateNotificationManager(P2PService p2PService, KeyRing keyRing, @Named(CommonOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
this.p2PService = p2PService;
this.keyRing = keyRing;

View File

@ -20,11 +20,13 @@ package io.bitsquare.app;
import ch.qos.logback.classic.Level;
import io.bitsquare.BitsquareException;
import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.BtcOptionKeys;
import io.bitsquare.btc.UserAgent;
import io.bitsquare.btc.WalletService;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.crypto.KeyStorage;
import io.bitsquare.common.util.Utilities;
import io.bitsquare.network.OptionKeys;
import io.bitsquare.network.NetworkOptionKeys;
import io.bitsquare.storage.Storage;
import io.bitsquare.util.spring.JOptCommandLinePropertySource;
import joptsimple.OptionSet;
@ -82,8 +84,7 @@ public class BitsquareEnvironment extends StandardEnvironment {
private final String btcNetworkDir;
private final String logLevel;
private BitcoinNetwork bitcoinNetwork;
private final String seedNodes, ignoreDevMsg;
private final String myAddress, banList;
private final String btcSeedNodes, seedNodes, ignoreDevMsg, useTorForBtc, myAddress, banList;
public BitsquareEnvironment(OptionSet options) {
this(new JOptCommandLinePropertySource(BITSQUARE_COMMANDLINE_PROPERTY_SOURCE_NAME, checkNotNull(
@ -132,25 +133,34 @@ public class BitsquareEnvironment extends StandardEnvironment {
(String) commandLineProperties.getProperty(APP_DATA_DIR_KEY) :
appDataDir(userDataDir, appName);
logLevel = commandLineProperties.containsProperty(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY) ?
(String) commandLineProperties.getProperty(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY) :
logLevel = commandLineProperties.containsProperty(CommonOptionKeys.LOG_LEVEL_KEY) ?
(String) commandLineProperties.getProperty(CommonOptionKeys.LOG_LEVEL_KEY) :
LOG_LEVEL_DEFAULT;
seedNodes = commandLineProperties.containsProperty(OptionKeys.SEED_NODES_KEY) ?
(String) commandLineProperties.getProperty(OptionKeys.SEED_NODES_KEY) :
seedNodes = commandLineProperties.containsProperty(NetworkOptionKeys.SEED_NODES_KEY) ?
(String) commandLineProperties.getProperty(NetworkOptionKeys.SEED_NODES_KEY) :
"";
myAddress = commandLineProperties.containsProperty(OptionKeys.MY_ADDRESS) ?
(String) commandLineProperties.getProperty(OptionKeys.MY_ADDRESS) :
myAddress = commandLineProperties.containsProperty(NetworkOptionKeys.MY_ADDRESS) ?
(String) commandLineProperties.getProperty(NetworkOptionKeys.MY_ADDRESS) :
"";
banList = commandLineProperties.containsProperty(OptionKeys.BAN_LIST) ?
(String) commandLineProperties.getProperty(OptionKeys.BAN_LIST) :
banList = commandLineProperties.containsProperty(NetworkOptionKeys.BAN_LIST) ?
(String) commandLineProperties.getProperty(NetworkOptionKeys.BAN_LIST) :
"";
ignoreDevMsg = commandLineProperties.containsProperty(io.bitsquare.common.OptionKeys.IGNORE_DEV_MSG_KEY) ?
(String) commandLineProperties.getProperty(io.bitsquare.common.OptionKeys.IGNORE_DEV_MSG_KEY) :
ignoreDevMsg = commandLineProperties.containsProperty(CommonOptionKeys.IGNORE_DEV_MSG_KEY) ?
(String) commandLineProperties.getProperty(CommonOptionKeys.IGNORE_DEV_MSG_KEY) :
"";
btcSeedNodes = commandLineProperties.containsProperty(BtcOptionKeys.BTC_SEED_NODES) ?
(String) commandLineProperties.getProperty(BtcOptionKeys.BTC_SEED_NODES) :
"";
useTorForBtc = commandLineProperties.containsProperty(BtcOptionKeys.USE_TOR_FOR_BTC) ?
(String) commandLineProperties.getProperty(BtcOptionKeys.USE_TOR_FOR_BTC) :
"";
MutablePropertySources propertySources = this.getPropertySources();
propertySources.addFirst(commandLineProperties);
try {
@ -206,12 +216,15 @@ public class BitsquareEnvironment extends StandardEnvironment {
{
setProperty(APP_DATA_DIR_KEY, appDataDir);
setProperty(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY, logLevel);
setProperty(CommonOptionKeys.LOG_LEVEL_KEY, logLevel);
setProperty(OptionKeys.SEED_NODES_KEY, seedNodes);
setProperty(OptionKeys.MY_ADDRESS, myAddress);
setProperty(OptionKeys.BAN_LIST, banList);
setProperty(io.bitsquare.common.OptionKeys.IGNORE_DEV_MSG_KEY, ignoreDevMsg);
setProperty(NetworkOptionKeys.SEED_NODES_KEY, seedNodes);
setProperty(NetworkOptionKeys.MY_ADDRESS, myAddress);
setProperty(NetworkOptionKeys.BAN_LIST, banList);
setProperty(CommonOptionKeys.IGNORE_DEV_MSG_KEY, ignoreDevMsg);
setProperty(BtcOptionKeys.BTC_SEED_NODES, btcSeedNodes);
setProperty(BtcOptionKeys.USE_TOR_FOR_BTC, useTorForBtc);
setProperty(APP_NAME_KEY, appName);
setProperty(USER_DATA_DIR_KEY, userDataDir);
@ -223,9 +236,9 @@ public class BitsquareEnvironment extends StandardEnvironment {
setProperty(Storage.DIR_KEY, Paths.get(btcNetworkDir, "db").toString());
setProperty(KeyStorage.DIR_KEY, Paths.get(btcNetworkDir, "keys").toString());
setProperty(OptionKeys.TOR_DIR, Paths.get(btcNetworkDir, "tor").toString());
setProperty(NetworkOptionKeys.TOR_DIR, Paths.get(btcNetworkDir, "tor").toString());
setProperty(OptionKeys.NETWORK_ID, String.valueOf(bitcoinNetwork.ordinal()));
setProperty(NetworkOptionKeys.NETWORK_ID, String.valueOf(bitcoinNetwork.ordinal()));
}
});
}

View File

@ -19,8 +19,10 @@ package io.bitsquare.app;
import io.bitsquare.BitsquareException;
import io.bitsquare.btc.BitcoinNetwork;
import io.bitsquare.btc.BtcOptionKeys;
import io.bitsquare.btc.RegTestHost;
import io.bitsquare.network.OptionKeys;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.network.NetworkOptionKeys;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.util.joptsimple.EnumValueConverter;
import joptsimple.OptionException;
@ -74,29 +76,34 @@ public abstract class BitsquareExecutable {
.withRequiredArg();
parser.accepts(APP_DATA_DIR_KEY, description("Application data directory", DEFAULT_APP_DATA_DIR))
.withRequiredArg();
parser.accepts(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY, description("Log level [OFF, ALL, ERROR, WARN, INFO, DEBUG, TRACE]", LOG_LEVEL_DEFAULT))
parser.accepts(CommonOptionKeys.LOG_LEVEL_KEY, description("Log level [OFF, ALL, ERROR, WARN, INFO, DEBUG, TRACE]", LOG_LEVEL_DEFAULT))
.withRequiredArg();
parser.accepts(OptionKeys.SEED_NODES_KEY, description("Override hard coded seed nodes as comma separated list: E.g. rxdkppp3vicnbgqt.onion:8002, mfla72c4igh5ta2t.onion:8002", ""))
parser.accepts(NetworkOptionKeys.SEED_NODES_KEY, description("Override hard coded seed nodes as comma separated list: E.g. rxdkppp3vicnbgqt.onion:8002, mfla72c4igh5ta2t.onion:8002", ""))
.withRequiredArg();
parser.accepts(OptionKeys.MY_ADDRESS, description("My own onion address (used for botstrap nodes to exclude itself)", ""))
parser.accepts(NetworkOptionKeys.MY_ADDRESS, description("My own onion address (used for botstrap nodes to exclude itself)", ""))
.withRequiredArg();
parser.accepts(OptionKeys.BAN_LIST, description("Nodes to exclude from network connections.", ""))
parser.accepts(NetworkOptionKeys.BAN_LIST, description("Nodes to exclude from network connections.", ""))
.withRequiredArg();
parser.accepts(io.bitsquare.common.OptionKeys.IGNORE_DEV_MSG_KEY, description("If set to true all signed messages from Bitsquare developers are ignored " +
parser.accepts(CommonOptionKeys.IGNORE_DEV_MSG_KEY, description("If set to true all signed messages from Bitsquare developers are ignored " +
"(Global alert, Version update alert, Filters for offers, nodes or payment account data)", false))
.withRequiredArg()
.ofType(boolean.class);
parser.accepts(BtcOptionKeys.BTC_SEED_NODES, description("Custom seed nodes used for BitcoinJ.", ""))
.withRequiredArg();
parser.accepts(BtcOptionKeys.USE_TOR_FOR_BTC, description("If set to true BitcoinJ is routed over our native Tor instance.", ""))
.withRequiredArg();
// use a fixed port as arbitrator use that for his ID
parser.accepts(OptionKeys.PORT_KEY, description("Port to listen on", 9999))
parser.accepts(NetworkOptionKeys.PORT_KEY, description("Port to listen on", 9999))
.withRequiredArg()
.ofType(int.class);
parser.accepts(OptionKeys.USE_LOCALHOST, description("Use localhost network for development", false))
parser.accepts(NetworkOptionKeys.USE_LOCALHOST, description("Use localhost network for development", false))
.withRequiredArg()
.ofType(boolean.class);
parser.accepts(OptionKeys.MAX_CONNECTIONS, description("Max. connections a peer will try to keep", P2PService.MAX_CONNECTIONS_DEFAULT))
parser.accepts(NetworkOptionKeys.MAX_CONNECTIONS, description("Max. connections a peer will try to keep", P2PService.MAX_CONNECTIONS_DEFAULT))
.withRequiredArg()
.ofType(int.class);
parser.accepts(BitcoinNetwork.KEY, description("Bitcoin network", BitcoinNetwork.DEFAULT))

View File

@ -48,6 +48,9 @@ public class BitcoinModule extends AppModule {
File walletDir = new File(env.getRequiredProperty(WalletService.DIR_KEY));
bind(File.class).annotatedWith(named(WalletService.DIR_KEY)).toInstance(walletDir);
bindConstant().annotatedWith(named(BtcOptionKeys.BTC_SEED_NODES)).to(env.getRequiredProperty(BtcOptionKeys.BTC_SEED_NODES));
bindConstant().annotatedWith(named(BtcOptionKeys.USE_TOR_FOR_BTC)).to(env.getRequiredProperty(BtcOptionKeys.USE_TOR_FOR_BTC));
bind(AddressEntryList.class).in(Singleton.class);
bind(TradeWalletService.class).in(Singleton.class);
bind(WalletService.class).in(Singleton.class);

View File

@ -0,0 +1,6 @@
package io.bitsquare.btc;
public class BtcOptionKeys {
public static final String BTC_SEED_NODES = "btcSeedNodes";
public static final String USE_TOR_FOR_BTC = "useTorForBtc";
}

View File

@ -88,6 +88,7 @@ public class WalletService {
private final RegTestHost regTestHost;
private final TradeWalletService tradeWalletService;
private final AddressEntryList addressEntryList;
private final String seedNodes;
private final NetworkParameters params;
private final File walletDir;
private final UserAgent userAgent;
@ -108,14 +109,30 @@ public class WalletService {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public WalletService(RegTestHost regTestHost, TradeWalletService tradeWalletService, AddressEntryList addressEntryList, UserAgent userAgent,
@Named(DIR_KEY) File appDir, Preferences preferences) {
public WalletService(RegTestHost regTestHost,
TradeWalletService tradeWalletService,
AddressEntryList addressEntryList,
UserAgent userAgent,
@Named(DIR_KEY) File appDir,
Preferences preferences,
@Named(BtcOptionKeys.BTC_SEED_NODES) String seedNodes,
@Named(BtcOptionKeys.USE_TOR_FOR_BTC) String useTorFlagFromOptions) {
this.regTestHost = regTestHost;
this.tradeWalletService = tradeWalletService;
this.addressEntryList = addressEntryList;
this.seedNodes = seedNodes;
this.params = preferences.getBitcoinNetwork().getParameters();
this.walletDir = new File(appDir, "bitcoin");
this.userAgent = userAgent;
// We support a checkbox in the settings to set the use tor flag.
// If we get the options set we override that setting.
if (useTorFlagFromOptions != null && !useTorFlagFromOptions.isEmpty()) {
if (useTorFlagFromOptions.equals("false"))
preferences.setUseTorForBitcoinJ(false);
else if (useTorFlagFromOptions.equals("true"))
preferences.setUseTorForBitcoinJ(true);
}
useTor = preferences.getUseTorForBitcoinJ();
storage = new Storage<>(walletDir);
@ -250,9 +267,11 @@ public class WalletService {
// 1333 / (2800 + 1333) = 0.32 -> 32 % probability that a pub key is in our wallet
walletAppKit.setBloomFilterFalsePositiveRate(0.00005);
// Pass custom seed nodes if set in options
if (seedNodes != null && !seedNodes.isEmpty()) {
//TODO Check how to pass seed nodes to the wallet kit. Probably via walletAppKit.setPeerNodes
}
// TODO Get bitcoinj running over our tor proxy. BlockingClientManager need to be used to use the socket
// from jtorproxy. To get supported it via nio / netty will be harder
if (useTor && params.getId().equals(NetworkParameters.ID_MAINNET))
walletAppKit.useTor();

View File

@ -19,7 +19,7 @@ package io.bitsquare.filter;
import com.google.inject.Inject;
import com.google.inject.name.Named;
import io.bitsquare.common.OptionKeys;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.crypto.KeyRing;
import io.bitsquare.common.util.Tuple3;
import io.bitsquare.common.util.Utilities;
@ -59,7 +59,7 @@ public class FilterManager {
///////////////////////////////////////////////////////////////////////////////////////////
@Inject
public FilterManager(P2PService p2PService, KeyRing keyRing, User user, @Named(OptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
public FilterManager(P2PService p2PService, KeyRing keyRing, User user, @Named(CommonOptionKeys.IGNORE_DEV_MSG_KEY) boolean ignoreDevMsg) {
this.p2PService = p2PService;
this.keyRing = keyRing;
this.user = user;

View File

@ -19,7 +19,7 @@ package io.bitsquare.filter;
import com.google.inject.Singleton;
import io.bitsquare.app.AppModule;
import io.bitsquare.common.OptionKeys;
import io.bitsquare.common.CommonOptionKeys;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;
@ -36,6 +36,6 @@ public class FilterModule extends AppModule {
@Override
protected final void configure() {
bind(FilterManager.class).in(Singleton.class);
bindConstant().annotatedWith(named(OptionKeys.IGNORE_DEV_MSG_KEY)).to(env.getRequiredProperty(OptionKeys.IGNORE_DEV_MSG_KEY));
bindConstant().annotatedWith(named(CommonOptionKeys.IGNORE_DEV_MSG_KEY)).to(env.getRequiredProperty(CommonOptionKeys.IGNORE_DEV_MSG_KEY));
}
}

View File

@ -111,8 +111,7 @@ public final class Preferences implements Persistable {
private boolean autoSelectArbitrators = true;
private final Map<String, Boolean> dontShowAgainMap;
private boolean tacAccepted;
// Don't remove as we don't want to break old serialized data
private boolean useTorForBitcoinJ = false;
private boolean useTorForBitcoinJ = true;
private boolean showOwnOffersInOfferBook = true;
private Locale preferredLocale;
private TradeCurrency preferredTradeCurrency;
@ -185,8 +184,7 @@ public final class Preferences implements Persistable {
defaultLocale = preferredLocale;
preferredTradeCurrency = persisted.getPreferredTradeCurrency();
defaultTradeCurrency = preferredTradeCurrency;
// useTorForBitcoinJ = persisted.getUseTorForBitcoinJ();
useTorForBitcoinJ = false;
useTorForBitcoinJ = persisted.getUseTorForBitcoinJ();
useStickyMarketPrice = persisted.getUseStickyMarketPrice();
usePercentageBasedPrice = persisted.getUsePercentageBasedPrice();
showOwnOffersInOfferBook = persisted.getShowOwnOffersInOfferBook();
@ -372,10 +370,10 @@ public final class Preferences implements Persistable {
storage.queueUpForSave();
}
/* public void setUseTorForBitcoinJ(boolean useTorForBitcoinJ) {
public void setUseTorForBitcoinJ(boolean useTorForBitcoinJ) {
this.useTorForBitcoinJ = useTorForBitcoinJ;
storage.queueUpForSave();
}*/
}
public void setShowOwnOffersInOfferBook(boolean showOwnOffersInOfferBook) {
this.showOwnOffersInOfferBook = showOwnOffersInOfferBook;

View File

@ -24,7 +24,7 @@ import com.google.inject.Injector;
import io.bitsquare.alert.AlertManager;
import io.bitsquare.arbitration.ArbitratorManager;
import io.bitsquare.btc.WalletService;
import io.bitsquare.common.OptionKeys;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.handlers.ResultHandler;
import io.bitsquare.common.util.Utilities;
@ -109,7 +109,7 @@ public class BitsquareApp extends Application {
log.info("Log files under: " + logPath);
Version.printVersion();
Utilities.printSysInfo();
Log.setLevel(Level.toLevel(env.getRequiredProperty(OptionKeys.LOG_LEVEL_KEY)));
Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));
UserThread.setExecutor(Platform::runLater);
UserThread.setTimerClass(UITimer.class);

View File

@ -34,14 +34,14 @@
<TitledGroupBg text="Bitcoin network" GridPane.rowSpan="2"/>
<!-- <Label text="Use tor:" GridPane.rowIndex="1"/>
<CheckBox fx:id="useTorCheckBox" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
-->
<Label fx:id="bitcoinPeersLabel" text="Connected peers:" GridPane.rowIndex="0"/>
<TextArea fx:id="bitcoinPeersTextArea" GridPane.rowIndex="0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
<Label text="Use tor:" GridPane.rowIndex="0"/>
<CheckBox fx:id="useTorCheckBox" GridPane.rowIndex="0" GridPane.columnIndex="1"/>
<Label fx:id="bitcoinPeersLabel" text="Connected peers:" GridPane.rowIndex="1"/>
<TextArea fx:id="bitcoinPeersTextArea" GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
GridPane.vgrow="SOMETIMES" editable="false" focusTraversable="false"/>
<TitledGroupBg text="P2P network" GridPane.rowIndex="1" GridPane.rowSpan="5">
<TitledGroupBg text="P2P network" GridPane.rowIndex="2" GridPane.rowSpan="5">
<padding>
<Insets top="50.0"/>
</padding>
@ -50,20 +50,20 @@
</GridPane.margin>
</TitledGroupBg>
<Label text="My onion address:" GridPane.rowIndex="1">
<Label text="My onion address:" GridPane.rowIndex="2">
<GridPane.margin>
<Insets top="50.0"/>
</GridPane.margin>
</Label>
<TextField fx:id="onionAddress" GridPane.rowIndex="1" GridPane.columnIndex="1"
<TextField fx:id="onionAddress" GridPane.rowIndex="2" GridPane.columnIndex="1"
editable="false" focusTraversable="false">
<GridPane.margin>
<Insets top="50.0"/>
</GridPane.margin>
</TextField>
<Label fx:id="p2PPeersLabel" text="Connected peers:" GridPane.rowIndex="2"/>
<TableView fx:id="tableView" GridPane.rowIndex="2" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
<Label fx:id="p2PPeersLabel" text="Connected peers:" GridPane.rowIndex="3"/>
<TableView fx:id="tableView" GridPane.rowIndex="3" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
GridPane.vgrow="ALWAYS">
<columns>
<TableColumn text="Onion address" fx:id="onionAddressColumn" minWidth="220">
@ -109,14 +109,14 @@
</columns>
</TableView>
<Label text="Total traffic:" GridPane.rowIndex="3"/>
<TextField fx:id="totalTraffic" GridPane.rowIndex="3" GridPane.columnIndex="1" editable="false"
<Label text="Total traffic:" GridPane.rowIndex="4"/>
<TextField fx:id="totalTraffic" GridPane.rowIndex="4" GridPane.columnIndex="1" editable="false"
focusTraversable="false"/>
<Label text="Use Tor bridges:" GridPane.rowIndex="4"/>
<CheckBox fx:id="useBridgesCheckBox" GridPane.rowIndex="4" GridPane.columnIndex="1"/>
<Label fx:id="bridgesLabel" text="Tor bridges:" GridPane.rowIndex="5" visible="false" managed="false"/>
<TextArea fx:id="bridgesTextArea" GridPane.rowIndex="5" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
<Label text="Use Tor bridges:" GridPane.rowIndex="5"/>
<CheckBox fx:id="useBridgesCheckBox" GridPane.rowIndex="5" GridPane.columnIndex="1"/>
<Label fx:id="bridgesLabel" text="Tor bridges:" GridPane.rowIndex="6" visible="false" managed="false"/>
<TextArea fx:id="bridgesTextArea" GridPane.rowIndex="6" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
minHeight="60"
GridPane.vgrow="SOMETIMES" editable="true" focusTraversable="true" visible="false" managed="false"/>

View File

@ -17,11 +17,14 @@
package io.bitsquare.gui.main.settings.network;
import io.bitsquare.app.BitsquareApp;
import io.bitsquare.btc.WalletService;
import io.bitsquare.common.Clock;
import io.bitsquare.common.UserThread;
import io.bitsquare.gui.common.model.Activatable;
import io.bitsquare.gui.common.view.ActivatableViewAndModel;
import io.bitsquare.gui.common.view.FxmlView;
import io.bitsquare.gui.main.overlays.popups.Popup;
import io.bitsquare.gui.util.BSFormatter;
import io.bitsquare.p2p.P2PService;
import io.bitsquare.p2p.network.Statistic;
@ -41,6 +44,7 @@ import org.fxmisc.easybind.Subscription;
import javax.inject.Inject;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@FxmlView
@ -61,8 +65,8 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
TextArea bitcoinPeersTextArea, bridgesTextArea;
@FXML
Label bitcoinPeersLabel, p2PPeersLabel, bridgesLabel;
/* @FXML
CheckBox useTorCheckBox;*/
@FXML
CheckBox useTorCheckBox;
@FXML
TableView<P2pNetworkListItem> tableView;
@FXML
@ -124,7 +128,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
@Override
public void activate() {
/* useTorCheckBox.setSelected(preferences.getUseTorForBitcoinJ());
useTorCheckBox.setSelected(preferences.getUseTorForBitcoinJ());
useTorCheckBox.setOnAction(event -> {
boolean selected = useTorCheckBox.isSelected();
if (selected != preferences.getUseTorForBitcoinJ()) {
@ -139,7 +143,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
.onClose(() -> useTorCheckBox.setSelected(!selected))
.show();
}
});*/
});
bitcoinPeersSubscription = EasyBind.subscribe(walletService.connectedPeersProperty(), connectedPeers -> updateBitcoinPeersTextArea());
nodeAddressSubscription = EasyBind.subscribe(p2PService.getNetworkNode().nodeAddressProperty(),
@ -166,7 +170,7 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
@Override
public void deactivate() {
//useTorCheckBox.setOnAction(null);
useTorCheckBox.setOnAction(null);
if (nodeAddressSubscription != null)
nodeAddressSubscription.unsubscribe();

View File

@ -8,6 +8,7 @@ import io.bitsquare.app.Log;
import io.bitsquare.app.Version;
import io.bitsquare.arbitration.ArbitratorManager;
import io.bitsquare.btc.WalletService;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.handlers.ResultHandler;
import io.bitsquare.common.util.Utilities;
@ -45,7 +46,7 @@ public class Headless {
log.info("Log files under: " + logPath);
Version.printVersion();
Utilities.printSysInfo();
Log.setLevel(Level.toLevel(env.getRequiredProperty(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY)));
Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));
// setup UncaughtExceptionHandler
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {

View File

@ -8,6 +8,7 @@ import io.bitsquare.app.Log;
import io.bitsquare.app.Version;
import io.bitsquare.arbitration.ArbitratorManager;
import io.bitsquare.btc.WalletService;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.handlers.ResultHandler;
import io.bitsquare.common.util.Utilities;
@ -46,7 +47,7 @@ public class Monitor {
log.info("Log files under: " + logPath);
Version.printVersion();
Utilities.printSysInfo();
Log.setLevel(Level.toLevel(env.getRequiredProperty(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY)));
Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));
// setup UncaughtExceptionHandler
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {

View File

@ -1,6 +1,6 @@
package io.bitsquare.network;
public class OptionKeys {
public class NetworkOptionKeys {
public static final String TOR_DIR = "torDir";
public static final String USE_LOCALHOST = "useLocalhost";
public static final String MAX_CONNECTIONS = "maxConnections";

View File

@ -20,7 +20,7 @@ package io.bitsquare.p2p;
import com.google.inject.Singleton;
import com.google.inject.name.Names;
import io.bitsquare.app.AppModule;
import io.bitsquare.network.OptionKeys;
import io.bitsquare.network.NetworkOptionKeys;
import io.bitsquare.p2p.seed.SeedNodesRepository;
import org.springframework.core.env.Environment;
@ -40,23 +40,23 @@ public class P2PModule extends AppModule {
bind(SeedNodesRepository.class).in(Singleton.class);
bind(P2PService.class).in(Singleton.class);
Boolean useLocalhost = env.getProperty(OptionKeys.USE_LOCALHOST, boolean.class, false);
bind(boolean.class).annotatedWith(Names.named(OptionKeys.USE_LOCALHOST)).toInstance(useLocalhost);
Boolean useLocalhost = env.getProperty(NetworkOptionKeys.USE_LOCALHOST, boolean.class, false);
bind(boolean.class).annotatedWith(Names.named(NetworkOptionKeys.USE_LOCALHOST)).toInstance(useLocalhost);
File torDir = new File(env.getRequiredProperty(OptionKeys.TOR_DIR));
bind(File.class).annotatedWith(named(OptionKeys.TOR_DIR)).toInstance(torDir);
File torDir = new File(env.getRequiredProperty(NetworkOptionKeys.TOR_DIR));
bind(File.class).annotatedWith(named(NetworkOptionKeys.TOR_DIR)).toInstance(torDir);
// use a fixed port as arbitrator use that for his ID
Integer port = env.getProperty(OptionKeys.PORT_KEY, int.class, 9999);
bind(int.class).annotatedWith(Names.named(OptionKeys.PORT_KEY)).toInstance(port);
Integer port = env.getProperty(NetworkOptionKeys.PORT_KEY, int.class, 9999);
bind(int.class).annotatedWith(Names.named(NetworkOptionKeys.PORT_KEY)).toInstance(port);
Integer maxConnections = env.getProperty(OptionKeys.MAX_CONNECTIONS, int.class, P2PService.MAX_CONNECTIONS_DEFAULT);
bind(int.class).annotatedWith(Names.named(OptionKeys.MAX_CONNECTIONS)).toInstance(maxConnections);
Integer maxConnections = env.getProperty(NetworkOptionKeys.MAX_CONNECTIONS, int.class, P2PService.MAX_CONNECTIONS_DEFAULT);
bind(int.class).annotatedWith(Names.named(NetworkOptionKeys.MAX_CONNECTIONS)).toInstance(maxConnections);
Integer networkId = env.getProperty(OptionKeys.NETWORK_ID, int.class, 1);
bind(int.class).annotatedWith(Names.named(OptionKeys.NETWORK_ID)).toInstance(networkId);
bindConstant().annotatedWith(named(OptionKeys.SEED_NODES_KEY)).to(env.getRequiredProperty(OptionKeys.SEED_NODES_KEY));
bindConstant().annotatedWith(named(OptionKeys.MY_ADDRESS)).to(env.getRequiredProperty(OptionKeys.MY_ADDRESS));
bindConstant().annotatedWith(named(OptionKeys.BAN_LIST)).to(env.getRequiredProperty(OptionKeys.BAN_LIST));
Integer networkId = env.getProperty(NetworkOptionKeys.NETWORK_ID, int.class, 1);
bind(int.class).annotatedWith(Names.named(NetworkOptionKeys.NETWORK_ID)).toInstance(networkId);
bindConstant().annotatedWith(named(NetworkOptionKeys.SEED_NODES_KEY)).to(env.getRequiredProperty(NetworkOptionKeys.SEED_NODES_KEY));
bindConstant().annotatedWith(named(NetworkOptionKeys.MY_ADDRESS)).to(env.getRequiredProperty(NetworkOptionKeys.MY_ADDRESS));
bindConstant().annotatedWith(named(NetworkOptionKeys.BAN_LIST)).to(env.getRequiredProperty(NetworkOptionKeys.BAN_LIST));
}
}

View File

@ -14,7 +14,7 @@ import io.bitsquare.common.crypto.KeyRing;
import io.bitsquare.common.crypto.PubKeyRing;
import io.bitsquare.crypto.DecryptedMsgWithPubKey;
import io.bitsquare.crypto.EncryptionService;
import io.bitsquare.network.OptionKeys;
import io.bitsquare.network.NetworkOptionKeys;
import io.bitsquare.p2p.messaging.*;
import io.bitsquare.p2p.network.*;
import io.bitsquare.p2p.peers.BanList;
@ -102,15 +102,15 @@ public class P2PService implements SetupListener, MessageListener, ConnectionLis
// Called also from SeedNodeP2PService
@Inject
public P2PService(SeedNodesRepository seedNodesRepository,
@Named(OptionKeys.PORT_KEY) int port,
@Named(OptionKeys.TOR_DIR) File torDir,
@Named(OptionKeys.USE_LOCALHOST) boolean useLocalhost,
@Named(OptionKeys.NETWORK_ID) int networkId,
@Named(OptionKeys.MAX_CONNECTIONS) int maxConnections,
@Named(NetworkOptionKeys.PORT_KEY) int port,
@Named(NetworkOptionKeys.TOR_DIR) File torDir,
@Named(NetworkOptionKeys.USE_LOCALHOST) boolean useLocalhost,
@Named(NetworkOptionKeys.NETWORK_ID) int networkId,
@Named(NetworkOptionKeys.MAX_CONNECTIONS) int maxConnections,
@Named(Storage.DIR_KEY) File storageDir,
@Named(OptionKeys.SEED_NODES_KEY) String seedNodes,
@Named(OptionKeys.MY_ADDRESS) String myAddress,
@Named(OptionKeys.BAN_LIST) String banList,
@Named(NetworkOptionKeys.SEED_NODES_KEY) String seedNodes,
@Named(NetworkOptionKeys.MY_ADDRESS) String myAddress,
@Named(NetworkOptionKeys.BAN_LIST) String banList,
Clock clock,
@Nullable EncryptionService encryptionService,
@Nullable KeyRing keyRing) {

View File

@ -481,11 +481,18 @@ public class P2PDataStorage implements MessageListener, ConnectionListener {
protectedStorageEntry.ownerPubKey.equals(protectedStorageEntry.getStoragePayload().getOwnerPubKey());
}
if (!result)
log.error("PublicKey of payload data and ProtectedData are not matching. protectedStorageEntry=" +
(protectedStorageEntry != null ? protectedStorageEntry.toString() : "null") +
"protectedStorageEntry.getStoragePayload().getOwnerPubKey()=" +
(protectedStorageEntry.getStoragePayload() != null ? protectedStorageEntry.getStoragePayload().getOwnerPubKey().toString() : "null"));
if (!result) {
String res1 = "null";
String res2 = "null";
if (protectedStorageEntry != null) {
res1 = protectedStorageEntry.toString();
if (protectedStorageEntry.getStoragePayload() != null && protectedStorageEntry.getStoragePayload().getOwnerPubKey() != null)
res2 = protectedStorageEntry.getStoragePayload().getOwnerPubKey().toString();
}
log.error("PublicKey of payload data and ProtectedData are not matching. protectedStorageEntry=" + res1 +
"protectedStorageEntry.getStoragePayload().getOwnerPubKey()=" + res2);
}
return result;
}

View File

@ -5,9 +5,10 @@ import com.google.common.annotations.VisibleForTesting;
import io.bitsquare.app.Log;
import io.bitsquare.app.Version;
import io.bitsquare.common.Clock;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.util.Utilities;
import io.bitsquare.network.OptionKeys;
import io.bitsquare.network.NetworkOptionKeys;
import io.bitsquare.p2p.peers.BanList;
import io.bitsquare.p2p.seed.SeedNodesRepository;
import org.jetbrains.annotations.Nullable;
@ -77,30 +78,30 @@ public class DummySeedNode {
String arg = args[i];
if (arg.startsWith("--"))
arg = arg.substring(2);
if (arg.startsWith(OptionKeys.MY_ADDRESS)) {
arg = arg.substring(OptionKeys.MY_ADDRESS.length() + 1);
if (arg.startsWith(NetworkOptionKeys.MY_ADDRESS)) {
arg = arg.substring(NetworkOptionKeys.MY_ADDRESS.length() + 1);
checkArgument(arg.contains(":") && arg.split(":").length == 2 && arg.split(":")[1].length() > 3, "Wrong program argument: " + arg);
mySeedNodeAddress = new NodeAddress(arg);
log.info("From processArgs: mySeedNodeAddress=" + mySeedNodeAddress);
} else if (arg.startsWith(OptionKeys.NETWORK_ID)) {
arg = arg.substring(OptionKeys.NETWORK_ID.length() + 1);
} else if (arg.startsWith(NetworkOptionKeys.NETWORK_ID)) {
arg = arg.substring(NetworkOptionKeys.NETWORK_ID.length() + 1);
networkId = Integer.parseInt(arg);
log.info("From processArgs: networkId=" + networkId);
checkArgument(networkId > -1 && networkId < 3,
"networkId out of scope (Mainnet = 0, TestNet = 1, Regtest = 2)");
Version.setBtcNetworkId(networkId);
} else if (arg.startsWith(OptionKeys.MAX_CONNECTIONS)) {
arg = arg.substring(OptionKeys.MAX_CONNECTIONS.length() + 1);
} else if (arg.startsWith(NetworkOptionKeys.MAX_CONNECTIONS)) {
arg = arg.substring(NetworkOptionKeys.MAX_CONNECTIONS.length() + 1);
maxConnections = Integer.parseInt(arg);
log.info("From processArgs: maxConnections=" + maxConnections);
checkArgument(maxConnections < MAX_CONNECTIONS_LIMIT, "maxConnections seems to be a bit too high...");
} else if (arg.startsWith(OptionKeys.USE_LOCALHOST)) {
arg = arg.substring(OptionKeys.USE_LOCALHOST.length() + 1);
} else if (arg.startsWith(NetworkOptionKeys.USE_LOCALHOST)) {
arg = arg.substring(NetworkOptionKeys.USE_LOCALHOST.length() + 1);
checkArgument(arg.equals("true") || arg.equals("false"));
useLocalhost = ("true").equals(arg);
log.info("From processArgs: useLocalhost=" + useLocalhost);
} else if (arg.startsWith(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY)) {
arg = arg.substring(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY.length() + 1);
} else if (arg.startsWith(CommonOptionKeys.LOG_LEVEL_KEY)) {
arg = arg.substring(CommonOptionKeys.LOG_LEVEL_KEY.length() + 1);
logLevel = Level.toLevel(arg.toUpperCase());
log.info("From processArgs: logLevel=" + logLevel);
} else if (arg.startsWith(SEED_NODES_LIST)) {
@ -116,8 +117,8 @@ public class DummySeedNode {
});
log.info("From processArgs: progArgSeedNodes=" + progArgSeedNodes);
progArgSeedNodes.remove(mySeedNodeAddress);
} else if (arg.startsWith(OptionKeys.BAN_LIST)) {
arg = arg.substring(OptionKeys.BAN_LIST.length() + 1);
} else if (arg.startsWith(NetworkOptionKeys.BAN_LIST)) {
arg = arg.substring(NetworkOptionKeys.BAN_LIST.length() + 1);
checkArgument(arg.contains(":") && arg.split(":").length > 1 && arg.split(":")[1].length() > 3,
"Wrong program argument " + arg);
List<String> list = Arrays.asList(arg.split(","));

View File

@ -8,6 +8,7 @@ import io.bitsquare.app.Log;
import io.bitsquare.app.Version;
import io.bitsquare.arbitration.ArbitratorManager;
import io.bitsquare.btc.WalletService;
import io.bitsquare.common.CommonOptionKeys;
import io.bitsquare.common.UserThread;
import io.bitsquare.common.handlers.ResultHandler;
import io.bitsquare.common.util.Utilities;
@ -42,7 +43,7 @@ public class SeedNode {
log.info("Log files under: " + logPath);
Version.printVersion();
Utilities.printSysInfo();
Log.setLevel(Level.toLevel(env.getRequiredProperty(io.bitsquare.common.OptionKeys.LOG_LEVEL_KEY)));
Log.setLevel(Level.toLevel(env.getRequiredProperty(CommonOptionKeys.LOG_LEVEL_KEY)));
// setup UncaughtExceptionHandler
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {