Search in sources :

Example 1 with BaseCurrencyNetwork

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;
}
Also used : SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) Date(java.util.Date) UserThread(bisq.common.UserThread)

Example 2 with BaseCurrencyNetwork

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);
}
Also used : BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) Before(org.junit.Before)

Example 3 with BaseCurrencyNetwork

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);
}
Also used : BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) Before(org.junit.Before)

Example 4 with BaseCurrencyNetwork

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();
    });
}
Also used : Arrays(java.util.Arrays) Label(javafx.scene.control.Label) FXCollections(javafx.collections.FXCollections) BisqEnvironment(bisq.core.app.BisqEnvironment) StringConverter(javafx.util.StringConverter) BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) Collectors(java.util.stream.Collectors) Inject(javax.inject.Inject) Consumer(java.util.function.Consumer) Tuple2(bisq.common.util.Tuple2) List(java.util.List) FormBuilder.addLabelComboBox(bisq.desktop.util.FormBuilder.addLabelComboBox) Insets(javafx.geometry.Insets) DevEnv(bisq.common.app.DevEnv) ComboBox(javafx.scene.control.ComboBox) Res(bisq.core.locale.Res) Overlay(bisq.desktop.main.overlays.Overlay) Optional(java.util.Optional) FormBuilder.addMultilineLabel(bisq.desktop.util.FormBuilder.addMultilineLabel) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) FormBuilder.addLabelComboBox(bisq.desktop.util.FormBuilder.addLabelComboBox) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) FormBuilder.addMultilineLabel(bisq.desktop.util.FormBuilder.addMultilineLabel) BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork)

Example 5 with BaseCurrencyNetwork

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);
}
Also used : BaseCurrencyNetwork(bisq.core.btc.BaseCurrencyNetwork) Country(bisq.core.locale.Country) BlockChainExplorer(bisq.core.user.BlockChainExplorer)

Aggregations

BaseCurrencyNetwork (bisq.core.btc.BaseCurrencyNetwork)10 Before (org.junit.Before)4 UserThread (bisq.common.UserThread)2 DevEnv (bisq.common.app.DevEnv)2 BisqEnvironment (bisq.core.app.BisqEnvironment)2 Res (bisq.core.locale.Res)2 Label (javafx.scene.control.Label)2 CommonOptionKeys (bisq.common.CommonOptionKeys)1 Capabilities (bisq.common.app.Capabilities)1 Log (bisq.common.app.Log)1 Version (bisq.common.app.Version)1 LimitedKeyStrengthException (bisq.common.crypto.LimitedKeyStrengthException)1 ResultHandler (bisq.common.handlers.ResultHandler)1 PersistedDataHost (bisq.common.proto.persistable.PersistedDataHost)1 Storage (bisq.common.storage.Storage)1 Profiler (bisq.common.util.Profiler)1 Tuple2 (bisq.common.util.Tuple2)1 Utilities (bisq.common.util.Utilities)1 AlertManager (bisq.core.alert.AlertManager)1 AppOptionKeys (bisq.core.app.AppOptionKeys)1