mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-24 07:07:43 +01:00
read preferred crypto network from property file
This commit is contained in:
parent
d50ff6c6dc
commit
a61a350ec7
10 changed files with 188 additions and 80 deletions
|
@ -84,11 +84,11 @@ public class Version {
|
||||||
return p2pMessageVersion;
|
return p2pMessageVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The version for the bitcoin network (Mainnet = 0, TestNet = 1, Regtest = 2)
|
// The version for the crypto network (BTC_Mainnet = 0, BTC_TestNet = 1, BTC_Regtest = 2, ...)
|
||||||
private static int CRYPTO_NETWORK_ID;
|
private static int CRYPTO_NETWORK_ID;
|
||||||
|
|
||||||
public static void setBaseCryptoNetworkId(int btcNetworkId) {
|
public static void setBaseCryptoNetworkId(int baseCryptoNetworkId) {
|
||||||
CRYPTO_NETWORK_ID = btcNetworkId;
|
CRYPTO_NETWORK_ID = baseCryptoNetworkId;
|
||||||
|
|
||||||
// CRYPTO_NETWORK_ID is 0, 1 or 2, we use for changes at NETWORK_PROTOCOL_VERSION a multiplication with 10
|
// CRYPTO_NETWORK_ID is 0, 1 or 2, we use for changes at NETWORK_PROTOCOL_VERSION a multiplication with 10
|
||||||
// to avoid conflicts:
|
// to avoid conflicts:
|
||||||
|
|
|
@ -49,12 +49,20 @@ public class ProtoUtil {
|
||||||
return "".equals(stringFromProto) ? null : stringFromProto;
|
return "".equals(stringFromProto) ? null : stringFromProto;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <E extends Enum<E>> E enumFromProto(Class<E> e, String id) {
|
/**
|
||||||
|
* Get a Java enum from a Protobuf enum in a safe way.
|
||||||
|
*
|
||||||
|
* @param enumType the class of the enum, e.g: BlaEnum.class
|
||||||
|
* @param name the name of the enum entry, e.g: proto.getWinner().name()
|
||||||
|
* @param <E> the enum Type
|
||||||
|
* @return an enum
|
||||||
|
*/
|
||||||
|
public static <E extends Enum<E>> E enumFromProto(Class<E> enumType, String name) {
|
||||||
E result = null;
|
E result = null;
|
||||||
try {
|
try {
|
||||||
result = Enum.valueOf(e, id);
|
result = Enum.valueOf(enumType, name);
|
||||||
} catch (IllegalArgumentException err) {
|
} catch (IllegalArgumentException err) {
|
||||||
log.error("Invalid value for enum " + e.getSimpleName() + ": " + id, err);
|
log.error("Invalid value for enum " + enumType.getSimpleName() + ": " + name, err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -1335,11 +1335,17 @@ formatter.asTaker={0} {1} as taker
|
||||||
# we use enum values here
|
# we use enum values here
|
||||||
# dynamic values are not recognized by IntelliJ
|
# dynamic values are not recognized by IntelliJ
|
||||||
# suppress inspection "UnusedProperty"
|
# suppress inspection "UnusedProperty"
|
||||||
MAINNET=Mainnet
|
BTC_MAINNET=Bitcoin Mainnet
|
||||||
# suppress inspection "UnusedProperty"
|
# suppress inspection "UnusedProperty"
|
||||||
TESTNET=Testnet
|
BTC_TESTNET=Bitcoin Testnet
|
||||||
# suppress inspection "UnusedProperty"
|
# suppress inspection "UnusedProperty"
|
||||||
REGTEST=Regtest
|
BTC_REGTEST=Bitcoin Regtest
|
||||||
|
|
||||||
|
LTC_MAINNET=Litecoin Mainnet
|
||||||
|
# suppress inspection "UnusedProperty"
|
||||||
|
LTC_TESTNET=Litecoin Testnet
|
||||||
|
# suppress inspection "UnusedProperty"
|
||||||
|
LTC_REGTEST=Litecoin Regtest
|
||||||
|
|
||||||
time.year=Year
|
time.year=Year
|
||||||
time.month=Month
|
time.month=Month
|
||||||
|
|
|
@ -91,7 +91,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||||
File file = resource.getFile();
|
File file = resource.getFile();
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
Object propertiesObject = appDirProperties().getSource();
|
Object propertiesObject = getAppDirProperties().getSource();
|
||||||
if (propertiesObject instanceof Properties) {
|
if (propertiesObject instanceof Properties) {
|
||||||
properties = (Properties) propertiesObject;
|
properties = (Properties) propertiesObject;
|
||||||
} else {
|
} else {
|
||||||
|
@ -199,6 +199,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||||
MutablePropertySources propertySources = this.getPropertySources();
|
MutablePropertySources propertySources = this.getPropertySources();
|
||||||
propertySources.addFirst(commandLineProperties);
|
propertySources.addFirst(commandLineProperties);
|
||||||
try {
|
try {
|
||||||
|
propertySources.addLast(getAppDirProperties());
|
||||||
baseCryptoNetwork = BaseCryptoNetwork.valueOf(getProperty(BtcOptionKeys.BASE_CRYPTO_NETWORK,
|
baseCryptoNetwork = BaseCryptoNetwork.valueOf(getProperty(BtcOptionKeys.BASE_CRYPTO_NETWORK,
|
||||||
BaseCryptoNetwork.DEFAULT.name()).toUpperCase());
|
BaseCryptoNetwork.DEFAULT.name()).toUpperCase());
|
||||||
btcNetworkDir = Paths.get(appDataDir, baseCryptoNetwork.name().toLowerCase()).toString();
|
btcNetworkDir = Paths.get(appDataDir, baseCryptoNetwork.name().toLowerCase()).toString();
|
||||||
|
@ -218,7 +219,7 @@ public class BisqEnvironment extends StandardEnvironment {
|
||||||
return resourceLoader.getResource(location);
|
return resourceLoader.getResource(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertySource<?> appDirProperties() throws Exception {
|
PropertySource<?> getAppDirProperties() throws Exception {
|
||||||
Resource resource = getAppDirPropertiesResource();
|
Resource resource = getAppDirPropertiesResource();
|
||||||
|
|
||||||
if (!resource.exists())
|
if (!resource.exists())
|
||||||
|
|
|
@ -26,22 +26,27 @@ import org.libdohj.params.LitecoinRegTestParams;
|
||||||
import org.libdohj.params.LitecoinTestNet3Params;
|
import org.libdohj.params.LitecoinTestNet3Params;
|
||||||
|
|
||||||
public enum BaseCryptoNetwork {
|
public enum BaseCryptoNetwork {
|
||||||
BTC_MAINNET(MainNetParams.get()),
|
BTC_MAINNET(MainNetParams.get(), "BTC", "MAINNET"),
|
||||||
BTC_TESTNET(TestNet3Params.get()),
|
BTC_TESTNET(TestNet3Params.get(), "BTC", "TESTNET"),
|
||||||
BTC_REGTEST(RegTestParams.get()),
|
BTC_REGTEST(RegTestParams.get(), "BTC", "REGTEST"),
|
||||||
LTC_MAINNET(LitecoinMainNetParams.get()),
|
LTC_MAINNET(LitecoinMainNetParams.get(), "LTC", "MAINNET"),
|
||||||
LTC_TESTNET(LitecoinTestNet3Params.get()),
|
LTC_TESTNET(LitecoinTestNet3Params.get(), "LTC", "TESTNET"),
|
||||||
LTC_REGTEST(LitecoinRegTestParams.get());
|
LTC_REGTEST(LitecoinRegTestParams.get(), "LTC", "REGTEST");
|
||||||
|
|
||||||
public static final BaseCryptoNetwork DEFAULT = BTC_MAINNET;
|
public static final BaseCryptoNetwork DEFAULT = BTC_MAINNET;
|
||||||
|
|
||||||
private final NetworkParameters parameters;
|
private final NetworkParameters parameters;
|
||||||
|
private String cryptoName;
|
||||||
|
private String networkTranslation;
|
||||||
|
|
||||||
BaseCryptoNetwork(NetworkParameters parameters) {
|
BaseCryptoNetwork(NetworkParameters parameters, String cryptoName, String networkTranslation) {
|
||||||
this.parameters = parameters;
|
this.parameters = parameters;
|
||||||
|
this.cryptoName = cryptoName;
|
||||||
|
this.networkTranslation = networkTranslation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NetworkParameters getParameters() {
|
public NetworkParameters getParameters() {
|
||||||
return parameters;
|
return parameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class WalletsSetup {
|
||||||
|
|
||||||
WalletUtils.setBaseCryptoNetwork(bisqEnvironment.getBaseCryptoNetwork());
|
WalletUtils.setBaseCryptoNetwork(bisqEnvironment.getBaseCryptoNetwork());
|
||||||
params = WalletUtils.getParameters();
|
params = WalletUtils.getParameters();
|
||||||
walletDir = new File(appDir, "bitcoin");
|
walletDir = new File(appDir, "wallet");
|
||||||
PeerGroup.setIgnoreHttpSeeds(true);
|
PeerGroup.setIgnoreHttpSeeds(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import io.bisq.common.locale.*;
|
||||||
import io.bisq.common.proto.persistable.PersistedDataHost;
|
import io.bisq.common.proto.persistable.PersistedDataHost;
|
||||||
import io.bisq.common.storage.Storage;
|
import io.bisq.common.storage.Storage;
|
||||||
import io.bisq.common.util.Utilities;
|
import io.bisq.common.util.Utilities;
|
||||||
|
import io.bisq.core.app.BisqEnvironment;
|
||||||
import io.bisq.core.btc.BaseCryptoNetwork;
|
import io.bisq.core.btc.BaseCryptoNetwork;
|
||||||
import io.bisq.core.btc.BtcOptionKeys;
|
import io.bisq.core.btc.BtcOptionKeys;
|
||||||
import io.bisq.core.btc.Restrictions;
|
import io.bisq.core.btc.Restrictions;
|
||||||
|
@ -20,6 +21,7 @@ import lombok.experimental.Delegate;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.bitcoinj.core.Coin;
|
import org.bitcoinj.core.Coin;
|
||||||
import org.bitcoinj.utils.MonetaryFormat;
|
import org.bitcoinj.utils.MonetaryFormat;
|
||||||
|
import org.bouncycastle.jce.provider.symmetric.ARC4;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -66,6 +68,7 @@ public final class Preferences implements PersistedDataHost {
|
||||||
@Delegate(excludes = ExcludesDelegateMethods.class)
|
@Delegate(excludes = ExcludesDelegateMethods.class)
|
||||||
private PreferencesPayload prefPayload = new PreferencesPayload();
|
private PreferencesPayload prefPayload = new PreferencesPayload();
|
||||||
private boolean initialReadDone = false;
|
private boolean initialReadDone = false;
|
||||||
|
private BisqEnvironment bisqEnvironment;
|
||||||
|
|
||||||
// Observable wrappers
|
// Observable wrappers
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -88,7 +91,6 @@ public final class Preferences implements PersistedDataHost {
|
||||||
private boolean resyncSpvRequested;
|
private boolean resyncSpvRequested;
|
||||||
private boolean tacAccepted;
|
private boolean tacAccepted;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -97,10 +99,12 @@ public final class Preferences implements PersistedDataHost {
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
@Inject
|
@Inject
|
||||||
public Preferences(Storage<PreferencesPayload> storage,
|
public Preferences(Storage<PreferencesPayload> storage,
|
||||||
|
BisqEnvironment bisqEnvironment,
|
||||||
@Named(BtcOptionKeys.BTC_NODES) String btcNodesFromOptions,
|
@Named(BtcOptionKeys.BTC_NODES) String btcNodesFromOptions,
|
||||||
@Named(BtcOptionKeys.USE_TOR_FOR_BTC) String useTorFlagFromOptions) {
|
@Named(BtcOptionKeys.USE_TOR_FOR_BTC) String useTorFlagFromOptions) {
|
||||||
|
|
||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
|
this.bisqEnvironment = bisqEnvironment;
|
||||||
this.btcNodesFromOptions = btcNodesFromOptions;
|
this.btcNodesFromOptions = btcNodesFromOptions;
|
||||||
this.useTorFlagFromOptions = useTorFlagFromOptions;
|
this.useTorFlagFromOptions = useTorFlagFromOptions;
|
||||||
}
|
}
|
||||||
|
@ -441,6 +445,14 @@ public final class Preferences implements PersistedDataHost {
|
||||||
persist();
|
persist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseCryptoNetwork getBaseCrypteNetwork(BaseCryptoNetwork baseCrypteNetwork) {
|
||||||
|
return bisqEnvironment.getBaseCryptoNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBaseCrypteNetwork(BaseCryptoNetwork baseCrypteNetwork) {
|
||||||
|
if (bisqEnvironment.getBaseCryptoNetwork() != baseCrypteNetwork)
|
||||||
|
bisqEnvironment.saveBaseCryptoNetwork(baseCrypteNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Getter
|
// Getter
|
||||||
|
@ -528,40 +540,73 @@ public final class Preferences implements PersistedDataHost {
|
||||||
tradeCurrenciesAsObservable.remove(change.getRemoved().get(0));
|
tradeCurrenciesAsObservable.remove(change.getRemoved().get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface ExcludesDelegateMethods {
|
private interface ExcludesDelegateMethods {
|
||||||
void setTacAccepted(boolean tacAccepted);
|
void setTacAccepted(boolean tacAccepted);
|
||||||
|
|
||||||
void setUseAnimations(boolean useAnimations);
|
void setUseAnimations(boolean useAnimations);
|
||||||
|
|
||||||
void setUserLanguage(@NotNull String userLanguageCode);
|
void setUserLanguage(@NotNull String userLanguageCode);
|
||||||
|
|
||||||
void setUserCountry(@NotNull Country userCountry);
|
void setUserCountry(@NotNull Country userCountry);
|
||||||
|
|
||||||
void setPreferredTradeCurrency(TradeCurrency preferredTradeCurrency);
|
void setPreferredTradeCurrency(TradeCurrency preferredTradeCurrency);
|
||||||
|
|
||||||
void setUseTorForBitcoinJ(boolean useTorForBitcoinJ);
|
void setUseTorForBitcoinJ(boolean useTorForBitcoinJ);
|
||||||
|
|
||||||
void setShowOwnOffersInOfferBook(boolean showOwnOffersInOfferBook);
|
void setShowOwnOffersInOfferBook(boolean showOwnOffersInOfferBook);
|
||||||
|
|
||||||
void setMaxPriceDistanceInPercent(double maxPriceDistanceInPercent);
|
void setMaxPriceDistanceInPercent(double maxPriceDistanceInPercent);
|
||||||
|
|
||||||
void setBackupDirectory(String backupDirectory);
|
void setBackupDirectory(String backupDirectory);
|
||||||
|
|
||||||
void setAutoSelectArbitrators(boolean autoSelectArbitrators);
|
void setAutoSelectArbitrators(boolean autoSelectArbitrators);
|
||||||
|
|
||||||
void setUsePercentageBasedPrice(boolean usePercentageBasedPrice);
|
void setUsePercentageBasedPrice(boolean usePercentageBasedPrice);
|
||||||
|
|
||||||
void setTagForPeer(String hostName, String tag);
|
void setTagForPeer(String hostName, String tag);
|
||||||
|
|
||||||
void setOfferBookChartScreenCurrencyCode(String offerBookChartScreenCurrencyCode);
|
void setOfferBookChartScreenCurrencyCode(String offerBookChartScreenCurrencyCode);
|
||||||
|
|
||||||
void setBuyScreenCurrencyCode(String buyScreenCurrencyCode);
|
void setBuyScreenCurrencyCode(String buyScreenCurrencyCode);
|
||||||
|
|
||||||
void setSellScreenCurrencyCode(String sellScreenCurrencyCode);
|
void setSellScreenCurrencyCode(String sellScreenCurrencyCode);
|
||||||
|
|
||||||
void setIgnoreTradersList(List<String> ignoreTradersList);
|
void setIgnoreTradersList(List<String> ignoreTradersList);
|
||||||
|
|
||||||
void setDirectoryChooserPath(String directoryChooserPath);
|
void setDirectoryChooserPath(String directoryChooserPath);
|
||||||
|
|
||||||
void setTradeChartsScreenCurrencyCode(String tradeChartsScreenCurrencyCode);
|
void setTradeChartsScreenCurrencyCode(String tradeChartsScreenCurrencyCode);
|
||||||
|
|
||||||
void setTradeStatisticsTickUnitIndex(int tradeStatisticsTickUnitIndex);
|
void setTradeStatisticsTickUnitIndex(int tradeStatisticsTickUnitIndex);
|
||||||
|
|
||||||
void setSortMarketCurrenciesNumerically(boolean sortMarketCurrenciesNumerically);
|
void setSortMarketCurrenciesNumerically(boolean sortMarketCurrenciesNumerically);
|
||||||
|
|
||||||
void setBitcoinNodes(String bitcoinNodes);
|
void setBitcoinNodes(String bitcoinNodes);
|
||||||
|
|
||||||
void setUseCustomWithdrawalTxFee(boolean useCustomWithdrawalTxFee);
|
void setUseCustomWithdrawalTxFee(boolean useCustomWithdrawalTxFee);
|
||||||
|
|
||||||
void setWithdrawalTxFeeInBytes(long withdrawalTxFeeInBytes);
|
void setWithdrawalTxFeeInBytes(long withdrawalTxFeeInBytes);
|
||||||
|
|
||||||
void setBuyerSecurityDepositAsLong(long buyerSecurityDepositAsLong);
|
void setBuyerSecurityDepositAsLong(long buyerSecurityDepositAsLong);
|
||||||
|
|
||||||
void setSelectedPaymentAccountForCreateOffer(@Nullable PaymentAccount paymentAccount);
|
void setSelectedPaymentAccountForCreateOffer(@Nullable PaymentAccount paymentAccount);
|
||||||
|
|
||||||
void setBsqBlockChainExplorer(BlockChainExplorer bsqBlockChainExplorer);
|
void setBsqBlockChainExplorer(BlockChainExplorer bsqBlockChainExplorer);
|
||||||
|
|
||||||
void setPayFeeInBtc(boolean payFeeInBtc);
|
void setPayFeeInBtc(boolean payFeeInBtc);
|
||||||
|
|
||||||
void setFiatCurrencies(List<FiatCurrency> currencies);
|
void setFiatCurrencies(List<FiatCurrency> currencies);
|
||||||
|
|
||||||
void setCryptoCurrencies(List<CryptoCurrency> currencies);
|
void setCryptoCurrencies(List<CryptoCurrency> currencies);
|
||||||
|
|
||||||
void setBlockChainExplorerTestNet(BlockChainExplorer blockChainExplorerTestNet);
|
void setBlockChainExplorerTestNet(BlockChainExplorer blockChainExplorerTestNet);
|
||||||
|
|
||||||
void setBlockChainExplorerMainNet(BlockChainExplorer blockChainExplorerMainNet);
|
void setBlockChainExplorerMainNet(BlockChainExplorer blockChainExplorerMainNet);
|
||||||
|
|
||||||
void setResyncSpvRequested(boolean resyncSpvRequested);
|
void setResyncSpvRequested(boolean resyncSpvRequested);
|
||||||
|
|
||||||
void setDontShowAgainMap(Map<String, Boolean> dontShowAgainMap);
|
void setDontShowAgainMap(Map<String, Boolean> dontShowAgainMap);
|
||||||
|
|
||||||
void setPeerTagMap(Map<String, String> peerTagMap);
|
void setPeerTagMap(Map<String, String> peerTagMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class BisqEnvironmentTests {
|
||||||
|
|
||||||
ConfigurableEnvironment env = new BisqEnvironment(commandlineProps) {
|
ConfigurableEnvironment env = new BisqEnvironment(commandlineProps) {
|
||||||
@Override
|
@Override
|
||||||
PropertySource<?> appDirProperties() {
|
PropertySource<?> getAppDirProperties() {
|
||||||
return filesystemProps;
|
return filesystemProps;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,20 +35,23 @@
|
||||||
|
|
||||||
<TitledGroupBg fx:id="btcHeader" GridPane.rowSpan="4"/>
|
<TitledGroupBg fx:id="btcHeader" GridPane.rowSpan="4"/>
|
||||||
|
|
||||||
<Label fx:id="bitcoinPeersLabel" GridPane.rowIndex="0"/>
|
<Label text="Select Network:" GridPane.rowIndex="0"/>
|
||||||
<TextArea fx:id="bitcoinPeersTextArea" GridPane.rowIndex="0" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
|
<ComboBox fx:id="netWorkComboBox" GridPane.rowIndex="0" GridPane.columnIndex="1"/>
|
||||||
|
|
||||||
|
<Label fx:id="bitcoinPeersLabel" GridPane.rowIndex="1"/>
|
||||||
|
<TextArea fx:id="bitcoinPeersTextArea" GridPane.rowIndex="1" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
|
||||||
GridPane.vgrow="SOMETIMES" editable="false" focusTraversable="false"/>
|
GridPane.vgrow="SOMETIMES" editable="false" focusTraversable="false"/>
|
||||||
|
|
||||||
<Label fx:id="useTorForBtcJLabel" GridPane.rowIndex="1"/>
|
<Label fx:id="useTorForBtcJLabel" GridPane.rowIndex="2"/>
|
||||||
<CheckBox fx:id="useTorForBtcJCheckBox" GridPane.rowIndex="1" GridPane.columnIndex="1"/>
|
<CheckBox fx:id="useTorForBtcJCheckBox" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
|
||||||
|
|
||||||
<Label fx:id="btcNodesLabel" GridPane.rowIndex="2"/>
|
<Label fx:id="btcNodesLabel" GridPane.rowIndex="3"/>
|
||||||
<InputTextField fx:id="btcNodes" GridPane.rowIndex="2" GridPane.columnIndex="1"/>
|
<InputTextField fx:id="btcNodes" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
|
||||||
|
|
||||||
<Label fx:id="reSyncSPVChainLabel" GridPane.rowIndex="3"/>
|
<Label fx:id="reSyncSPVChainLabel" GridPane.rowIndex="4"/>
|
||||||
<Button fx:id="reSyncSPVChainButton" GridPane.rowIndex="3" GridPane.columnIndex="1"/>
|
<Button fx:id="reSyncSPVChainButton" GridPane.rowIndex="4" GridPane.columnIndex="1"/>
|
||||||
|
|
||||||
<TitledGroupBg fx:id="p2pHeader" GridPane.rowIndex="4" GridPane.rowSpan="3">
|
<TitledGroupBg fx:id="p2pHeader" GridPane.rowIndex="5" GridPane.rowSpan="3">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets top="50.0"/>
|
<Insets top="50.0"/>
|
||||||
</padding>
|
</padding>
|
||||||
|
@ -62,15 +65,15 @@
|
||||||
<Insets top="50.0"/>
|
<Insets top="50.0"/>
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</Label>
|
</Label>
|
||||||
<TextField fx:id="onionAddress" GridPane.rowIndex="4" GridPane.columnIndex="1"
|
<TextField fx:id="onionAddress" GridPane.rowIndex="5" GridPane.columnIndex="1"
|
||||||
editable="false" focusTraversable="false">
|
editable="false" focusTraversable="false">
|
||||||
<GridPane.margin>
|
<GridPane.margin>
|
||||||
<Insets top="50.0"/>
|
<Insets top="50.0"/>
|
||||||
</GridPane.margin>
|
</GridPane.margin>
|
||||||
</TextField>
|
</TextField>
|
||||||
|
|
||||||
<Label fx:id="p2PPeersLabel" GridPane.rowIndex="5"/>
|
<Label fx:id="p2PPeersLabel" GridPane.rowIndex="6"/>
|
||||||
<TableView fx:id="tableView" GridPane.rowIndex="5" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
|
<TableView fx:id="tableView" GridPane.rowIndex="6" GridPane.columnIndex="1" GridPane.hgrow="ALWAYS"
|
||||||
GridPane.vgrow="SOMETIMES">
|
GridPane.vgrow="SOMETIMES">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn fx:id="onionAddressColumn" minWidth="220">
|
<TableColumn fx:id="onionAddressColumn" minWidth="220">
|
||||||
|
@ -111,8 +114,8 @@
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
|
|
||||||
<Label fx:id="totalTrafficLabel" GridPane.rowIndex="6"/>
|
<Label fx:id="totalTrafficLabel" GridPane.rowIndex="7"/>
|
||||||
<TextField fx:id="totalTrafficTextField" GridPane.rowIndex="6" GridPane.columnIndex="1" editable="false"
|
<TextField fx:id="totalTrafficTextField" GridPane.rowIndex="7" GridPane.columnIndex="1" editable="false"
|
||||||
focusTraversable="false"/>
|
focusTraversable="false"/>
|
||||||
|
|
||||||
<columnConstraints>
|
<columnConstraints>
|
||||||
|
|
|
@ -20,6 +20,8 @@ package io.bisq.gui.main.settings.network;
|
||||||
import io.bisq.common.Clock;
|
import io.bisq.common.Clock;
|
||||||
import io.bisq.common.UserThread;
|
import io.bisq.common.UserThread;
|
||||||
import io.bisq.common.locale.Res;
|
import io.bisq.common.locale.Res;
|
||||||
|
import io.bisq.core.app.BisqEnvironment;
|
||||||
|
import io.bisq.core.btc.BaseCryptoNetwork;
|
||||||
import io.bisq.core.btc.wallet.WalletsSetup;
|
import io.bisq.core.btc.wallet.WalletsSetup;
|
||||||
import io.bisq.core.user.Preferences;
|
import io.bisq.core.user.Preferences;
|
||||||
import io.bisq.gui.app.BisqApp;
|
import io.bisq.gui.app.BisqApp;
|
||||||
|
@ -41,6 +43,7 @@ import javafx.geometry.Insets;
|
||||||
import javafx.geometry.VPos;
|
import javafx.geometry.VPos;
|
||||||
import javafx.scene.control.*;
|
import javafx.scene.control.*;
|
||||||
import javafx.scene.layout.GridPane;
|
import javafx.scene.layout.GridPane;
|
||||||
|
import javafx.util.StringConverter;
|
||||||
import org.bitcoinj.core.Peer;
|
import org.bitcoinj.core.Peer;
|
||||||
import org.fxmisc.easybind.EasyBind;
|
import org.fxmisc.easybind.EasyBind;
|
||||||
import org.fxmisc.easybind.Subscription;
|
import org.fxmisc.easybind.Subscription;
|
||||||
|
@ -62,6 +65,8 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
@FXML
|
@FXML
|
||||||
TextField onionAddress, totalTrafficTextField;
|
TextField onionAddress, totalTrafficTextField;
|
||||||
@FXML
|
@FXML
|
||||||
|
ComboBox<BaseCryptoNetwork> netWorkComboBox;
|
||||||
|
@FXML
|
||||||
TextArea bitcoinPeersTextArea;
|
TextArea bitcoinPeersTextArea;
|
||||||
@FXML
|
@FXML
|
||||||
Label bitcoinPeersLabel, p2PPeersLabel;
|
Label bitcoinPeersLabel, p2PPeersLabel;
|
||||||
|
@ -89,14 +94,16 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
private final SortedList<P2pNetworkListItem> sortedList = new SortedList<>(networkListItems);
|
private final SortedList<P2pNetworkListItem> sortedList = new SortedList<>(networkListItems);
|
||||||
private ChangeListener<Boolean> btcNodesFocusListener;
|
private ChangeListener<Boolean> btcNodesFocusListener;
|
||||||
private String btcNodesPreFocusText;
|
private String btcNodesPreFocusText;
|
||||||
|
private BisqEnvironment bisqEnvironment;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public NetworkSettingsView(WalletsSetup walletsSetup, P2PService p2PService, Preferences preferences, Clock clock,
|
public NetworkSettingsView(WalletsSetup walletsSetup, P2PService p2PService, Preferences preferences,
|
||||||
BSFormatter formatter) {
|
BisqEnvironment bisqEnvironment, Clock clock, BSFormatter formatter) {
|
||||||
super();
|
super();
|
||||||
this.walletsSetup = walletsSetup;
|
this.walletsSetup = walletsSetup;
|
||||||
this.p2PService = p2PService;
|
this.p2PService = p2PService;
|
||||||
this.preferences = preferences;
|
this.preferences = preferences;
|
||||||
|
this.bisqEnvironment = bisqEnvironment;
|
||||||
this.clock = clock;
|
this.clock = clock;
|
||||||
this.formatter = formatter;
|
this.formatter = formatter;
|
||||||
}
|
}
|
||||||
|
@ -126,6 +133,20 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
GridPane.setValignment(p2PPeersLabel, VPos.TOP);
|
GridPane.setValignment(p2PPeersLabel, VPos.TOP);
|
||||||
|
|
||||||
bitcoinPeersTextArea.setPrefRowCount(6);
|
bitcoinPeersTextArea.setPrefRowCount(6);
|
||||||
|
netWorkComboBox.setItems(FXCollections.observableArrayList(BaseCryptoNetwork.values()));
|
||||||
|
netWorkComboBox.getSelectionModel().select(bisqEnvironment.getBaseCryptoNetwork());
|
||||||
|
netWorkComboBox.setOnAction(e -> onSelectNetwork());
|
||||||
|
netWorkComboBox.setConverter(new StringConverter<BaseCryptoNetwork>() {
|
||||||
|
@Override
|
||||||
|
public String toString(BaseCryptoNetwork baseCryptoNetwork) {
|
||||||
|
return Res.get(baseCryptoNetwork.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseCryptoNetwork fromString(String string) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
tableView.setMinHeight(230);
|
tableView.setMinHeight(230);
|
||||||
tableView.setPrefHeight(230);
|
tableView.setPrefHeight(230);
|
||||||
|
@ -259,5 +280,24 @@ public class NetworkSettingsView extends ActivatableViewAndModel<GridPane, Activ
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void onSelectNetwork() {
|
||||||
|
if (netWorkComboBox.getSelectionModel().getSelectedItem() != bisqEnvironment.getBaseCryptoNetwork())
|
||||||
|
selectNetwork();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void selectNetwork() {
|
||||||
|
new Popup().warning("You need to shut down and restart the application to apply the change of the Bitcoin network.\n\n" +
|
||||||
|
"Do you want to shut down now?")
|
||||||
|
.onAction(() -> {
|
||||||
|
bisqEnvironment.saveBaseCryptoNetwork(netWorkComboBox.getSelectionModel().getSelectedItem());
|
||||||
|
UserThread.runAfter(BisqApp.shutDownHandler::run, 500, TimeUnit.MILLISECONDS);
|
||||||
|
})
|
||||||
|
.actionButtonText("Shut down")
|
||||||
|
.closeButtonText("Cancel")
|
||||||
|
.onClose(() -> netWorkComboBox.getSelectionModel().select(bisqEnvironment.getBaseCryptoNetwork()))
|
||||||
|
.show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue