use of bisq.core.btc.BaseCurrencyNetwork in project bisq-core by bisq-network.
the class SetupUtils method readFromResources.
public static BooleanProperty readFromResources(P2PDataStorage p2PDataStorage) {
BooleanProperty result = new SimpleBooleanProperty();
Thread thread = new Thread(() -> {
Thread.currentThread().setName("readFromResourcesThread");
// Used to load different files per base currency (EntryMap_BTC_MAINNET, EntryMap_LTC,...)
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
final String postFix = "_" + baseCurrencyNetwork.getCurrencyCode() + "_" + baseCurrencyNetwork.getNetwork();
long ts = new Date().getTime();
p2PDataStorage.readFromResources(P2PDataStorage.PERSISTABLE_NETWORK_PAYLOAD_MAP_FILE_NAME, postFix);
p2PDataStorage.readFromResources(P2PDataStorage.PERSISTED_ENTRY_MAP_FILE_NAME, postFix);
log.info("readFromResources took {} ms", (new Date().getTime() - ts));
UserThread.execute(() -> result.set(true));
});
thread.start();
return result;
}
use of bisq.core.btc.BaseCurrencyNetwork in project bisq-desktop by bisq-network.
the class BtcValidatorTest method setup.
@Before
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();
Res.setBaseCurrencyCode(currencyCode);
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
CurrencyUtil.setBaseCurrencyCode(currencyCode);
}
use of bisq.core.btc.BaseCurrencyNetwork in project bisq-desktop by bisq-network.
the class FiatVolumeValidatorTest method setup.
@Before
public void setup() {
final BaseCurrencyNetwork baseCurrencyNetwork = BisqEnvironment.getBaseCurrencyNetwork();
final String currencyCode = baseCurrencyNetwork.getCurrencyCode();
Res.setBaseCurrencyCode(currencyCode);
Res.setBaseCurrencyName(baseCurrencyNetwork.getCurrencyName());
CurrencyUtil.setBaseCurrencyCode(currencyCode);
}
use of bisq.core.btc.BaseCurrencyNetwork in project bisq-desktop by bisq-network.
the class SelectBaseCurrencyWindow method addContent.
// /////////////////////////////////////////////////////////////////////////////////////////
// Protected
// /////////////////////////////////////////////////////////////////////////////////////////
private void addContent() {
Label label = addMultilineLabel(gridPane, ++rowIndex, Res.get("selectBaseCurrencyWindow.msg", BisqEnvironment.getBaseCurrencyNetwork().getCurrencyName()), 10);
GridPane.setMargin(label, new Insets(0, 0, 10, 0));
Tuple2<Label, ComboBox> tuple = addLabelComboBox(gridPane, ++rowIndex, Res.get("selectBaseCurrencyWindow.select"));
// noinspection unchecked
comboBox = tuple.second;
comboBox.setPromptText(Res.get("shared.select"));
List<BaseCurrencyNetwork> baseCurrencyNetworks = Arrays.asList(BaseCurrencyNetwork.values());
// show ony mainnet in production version
if (!DevEnv.isDevMode())
baseCurrencyNetworks = baseCurrencyNetworks.stream().filter(e -> e.isMainnet()).collect(Collectors.toList());
comboBox.setItems(FXCollections.observableArrayList(baseCurrencyNetworks));
comboBox.setConverter(new StringConverter<BaseCurrencyNetwork>() {
@Override
public String toString(BaseCurrencyNetwork baseCurrencyNetwork) {
return DevEnv.isDevMode() ? (baseCurrencyNetwork.getCurrencyName() + "_" + baseCurrencyNetwork.getNetwork()) : baseCurrencyNetwork.getCurrencyName();
}
@Override
public BaseCurrencyNetwork fromString(String string) {
return null;
}
});
comboBox.setOnAction(event -> {
selectHandlerOptional.get().accept(comboBox.getSelectionModel().getSelectedItem());
hide();
});
}
use of bisq.core.btc.BaseCurrencyNetwork in project bisq-desktop by bisq-network.
the class PreferencesView method activateGeneralOptions.
// /////////////////////////////////////////////////////////////////////////////////////////
// Activate
// /////////////////////////////////////////////////////////////////////////////////////////
private void activateGeneralOptions() {
List<BaseCurrencyNetwork> baseCurrencyNetworks = Arrays.asList(BaseCurrencyNetwork.values());
// show ony mainnet in production version
if (!DevEnv.isDevMode())
baseCurrencyNetworks = baseCurrencyNetworks.stream().filter(e -> !e.isDash()).filter(BaseCurrencyNetwork::isMainnet).collect(Collectors.toList());
selectBaseCurrencyNetworkComboBox.setItems(FXCollections.observableArrayList(baseCurrencyNetworks));
selectBaseCurrencyNetworkComboBox.setOnAction(e -> onSelectNetwork());
selectBaseCurrencyNetworkComboBox.getSelectionModel().select(BisqEnvironment.getBaseCurrencyNetwork());
boolean useCustomWithdrawalTxFee = preferences.isUseCustomWithdrawalTxFee();
useCustomFeeCheckbox.setSelected(useCustomWithdrawalTxFee);
transactionFeeInputTextField.setEditable(useCustomWithdrawalTxFee);
if (!useCustomWithdrawalTxFee) {
transactionFeeInputTextField.setText(String.valueOf(feeService.getTxFeePerByte().value));
feeService.feeUpdateCounterProperty().addListener(transactionFeeChangeListener);
}
transactionFeeInputTextField.setText(String.valueOf(getTxFeeForWithdrawalPerByte()));
ignoreTradersListInputTextField.setText(preferences.getIgnoreTradersList().stream().collect(Collectors.joining(", ")));
userLanguageComboBox.setItems(languageCodes);
userLanguageComboBox.getSelectionModel().select(preferences.getUserLanguage());
userLanguageComboBox.setConverter(new StringConverter<String>() {
@Override
public String toString(String code) {
return LanguageUtil.getDisplayName(code);
}
@Override
public String fromString(String string) {
return null;
}
});
userLanguageComboBox.setOnAction(e -> {
String selectedItem = userLanguageComboBox.getSelectionModel().getSelectedItem();
if (selectedItem != null) {
preferences.setUserLanguage(selectedItem);
new Popup<>().information(Res.get("settings.preferences.languageChange")).closeButtonText(Res.get("shared.ok")).show();
}
// Should we apply the changed currency immediately to the language list?
// If so and the user selects a unknown language he might get lost and it is hard to find
// again the language he understands
/* if (selectedItem != null && !selectedItem.equals(preferences.getUserLanguage())) {
preferences.setUserLanguage(selectedItem);
UserThread.execute(() -> {
languageCodes.clear();
languageCodes.addAll(LanguageUtil.getAllLanguageCodes());
userLanguageComboBox.getSelectionModel().select(preferences.getUserLanguage());
});
}*/
});
userCountryComboBox.setItems(countries);
userCountryComboBox.getSelectionModel().select(preferences.getUserCountry());
userCountryComboBox.setConverter(new StringConverter<Country>() {
@Override
public String toString(Country country) {
return CountryUtil.getNameByCode(country.code);
}
@Override
public Country fromString(String string) {
return null;
}
});
userCountryComboBox.setOnAction(e -> {
Country country = userCountryComboBox.getSelectionModel().getSelectedItem();
if (country != null) {
preferences.setUserCountry(country);
}
});
blockChainExplorerComboBox.setItems(blockExplorers);
blockChainExplorerComboBox.getSelectionModel().select(preferences.getBlockChainExplorer());
blockChainExplorerComboBox.setConverter(new StringConverter<BlockChainExplorer>() {
@Override
public String toString(BlockChainExplorer blockChainExplorer) {
return blockChainExplorer.name;
}
@Override
public BlockChainExplorer fromString(String string) {
return null;
}
});
blockChainExplorerComboBox.setOnAction(e -> preferences.setBlockChainExplorer(blockChainExplorerComboBox.getSelectionModel().getSelectedItem()));
deviationInputTextField.setText(formatter.formatPercentagePrice(preferences.getMaxPriceDistanceInPercent()));
deviationInputTextField.textProperty().addListener(deviationListener);
deviationInputTextField.focusedProperty().addListener(deviationFocusedListener);
transactionFeeInputTextField.focusedProperty().addListener(transactionFeeFocusedListener);
ignoreTradersListInputTextField.textProperty().addListener(ignoreTradersListListener);
useCustomFeeCheckbox.selectedProperty().addListener(useCustomFeeCheckboxListener);
}
Aggregations