Search in sources :

Example 1 with CryptoCurrency

use of bisq.core.locale.CryptoCurrency in project bisq-core by bisq-network.

the class PreferencesPayload method fromProto.

public static PersistableEnvelope fromProto(PB.PreferencesPayload proto, CoreProtoResolver coreProtoResolver) {
    final PB.Country userCountry = proto.getUserCountry();
    PaymentAccount paymentAccount = null;
    if (proto.hasSelectedPaymentAccountForCreateOffer() && proto.getSelectedPaymentAccountForCreateOffer().hasPaymentMethod())
        paymentAccount = PaymentAccount.fromProto(proto.getSelectedPaymentAccountForCreateOffer(), coreProtoResolver);
    return new PreferencesPayload(proto.getUserLanguage(), Country.fromProto(userCountry), proto.getFiatCurrenciesList().isEmpty() ? new ArrayList<>() : new ArrayList<>(proto.getFiatCurrenciesList().stream().map(FiatCurrency::fromProto).collect(Collectors.toList())), proto.getCryptoCurrenciesList().isEmpty() ? new ArrayList<>() : new ArrayList<>(proto.getCryptoCurrenciesList().stream().map(CryptoCurrency::fromProto).collect(Collectors.toList())), BlockChainExplorer.fromProto(proto.getBlockChainExplorerMainNet()), BlockChainExplorer.fromProto(proto.getBlockChainExplorerTestNet()), BlockChainExplorer.fromProto(proto.getBsqBlockChainExplorer()), ProtoUtil.stringOrNullFromProto(proto.getBackupDirectory()), proto.getAutoSelectArbitrators(), Maps.newHashMap(proto.getDontShowAgainMapMap()), proto.getTacAccepted(), proto.getUseTorForBitcoinJ(), proto.getShowOwnOffersInOfferBook(), proto.hasPreferredTradeCurrency() ? TradeCurrency.fromProto(proto.getPreferredTradeCurrency()) : null, proto.getWithdrawalTxFeeInBytes(), proto.getUseCustomWithdrawalTxFee(), proto.getMaxPriceDistanceInPercent(), ProtoUtil.stringOrNullFromProto(proto.getOfferBookChartScreenCurrencyCode()), ProtoUtil.stringOrNullFromProto(proto.getTradeChartsScreenCurrencyCode()), ProtoUtil.stringOrNullFromProto(proto.getBuyScreenCurrencyCode()), ProtoUtil.stringOrNullFromProto(proto.getSellScreenCurrencyCode()), proto.getTradeStatisticsTickUnitIndex(), proto.getResyncSpvRequested(), proto.getSortMarketCurrenciesNumerically(), proto.getUsePercentageBasedPrice(), Maps.newHashMap(proto.getPeerTagMapMap()), proto.getBitcoinNodes(), proto.getIgnoreTradersListList(), proto.getDirectoryChooserPath(), proto.getBuyerSecurityDepositAsLong(), proto.getUseAnimations(), paymentAccount, proto.getPayFeeInBtc(), proto.getBridgeAddressesList().isEmpty() ? null : new ArrayList<>(proto.getBridgeAddressesList()), proto.getBridgeOptionOrdinal(), proto.getTorTransportOrdinal(), ProtoUtil.stringOrNullFromProto(proto.getCustomBridges()), proto.getBitcoinNodesOptionOrdinal());
}
Also used : CryptoCurrency(bisq.core.locale.CryptoCurrency) PB(io.bisq.generated.protobuffer.PB) PaymentAccount(bisq.core.payment.PaymentAccount) ArrayList(java.util.ArrayList) FiatCurrency(bisq.core.locale.FiatCurrency)

Example 2 with CryptoCurrency

use of bisq.core.locale.CryptoCurrency in project bisq-desktop by bisq-network.

the class FiatAccountsDataModel method onSaveNewAccount.

// /////////////////////////////////////////////////////////////////////////////////////////
// UI actions
// /////////////////////////////////////////////////////////////////////////////////////////
public void onSaveNewAccount(PaymentAccount paymentAccount) {
    user.addPaymentAccount(paymentAccount);
    TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
    List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
    if (singleTradeCurrency != null) {
        if (singleTradeCurrency instanceof FiatCurrency)
            preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency);
        else
            preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
    } else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) {
        if (tradeCurrencies.contains(CurrencyUtil.getDefaultTradeCurrency()))
            paymentAccount.setSelectedTradeCurrency(CurrencyUtil.getDefaultTradeCurrency());
        else
            paymentAccount.setSelectedTradeCurrency(tradeCurrencies.get(0));
        tradeCurrencies.forEach(tradeCurrency -> {
            if (tradeCurrency instanceof FiatCurrency)
                preferences.addFiatCurrency((FiatCurrency) tradeCurrency);
            else
                preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency);
        });
    }
    accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload());
}
Also used : GUIUtil(bisq.desktop.util.GUIUtil) TradeCurrency(bisq.core.locale.TradeCurrency) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) ActivatableDataModel(bisq.desktop.common.model.ActivatableDataModel) Inject(com.google.inject.Inject) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) FiatCurrency(bisq.core.locale.FiatCurrency) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Collectors(java.util.stream.Collectors) OpenOfferManager(bisq.core.offer.OpenOfferManager) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) User(bisq.core.user.User) PersistenceProtoResolver(bisq.common.proto.persistable.PersistenceProtoResolver) ArrayList(java.util.ArrayList) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) CryptoCurrency(bisq.core.locale.CryptoCurrency) Stage(javafx.stage.Stage) TradeManager(bisq.core.trade.TradeManager) Preferences(bisq.core.user.Preferences) CurrencyUtil(bisq.core.locale.CurrencyUtil) ObservableList(javafx.collections.ObservableList) CryptoCurrency(bisq.core.locale.CryptoCurrency) TradeCurrency(bisq.core.locale.TradeCurrency) FiatCurrency(bisq.core.locale.FiatCurrency)

Example 3 with CryptoCurrency

use of bisq.core.locale.CryptoCurrency in project bisq-desktop by bisq-network.

the class AltCoinAccountsDataModel method onSaveNewAccount.

// /////////////////////////////////////////////////////////////////////////////////////////
// UI actions
// /////////////////////////////////////////////////////////////////////////////////////////
public void onSaveNewAccount(PaymentAccount paymentAccount) {
    user.addPaymentAccount(paymentAccount);
    TradeCurrency singleTradeCurrency = paymentAccount.getSingleTradeCurrency();
    List<TradeCurrency> tradeCurrencies = paymentAccount.getTradeCurrencies();
    if (singleTradeCurrency != null) {
        if (singleTradeCurrency instanceof FiatCurrency)
            preferences.addFiatCurrency((FiatCurrency) singleTradeCurrency);
        else
            preferences.addCryptoCurrency((CryptoCurrency) singleTradeCurrency);
    } else if (tradeCurrencies != null && !tradeCurrencies.isEmpty()) {
        tradeCurrencies.stream().forEach(tradeCurrency -> {
            if (tradeCurrency instanceof FiatCurrency)
                preferences.addFiatCurrency((FiatCurrency) tradeCurrency);
            else
                preferences.addCryptoCurrency((CryptoCurrency) tradeCurrency);
        });
    }
    if (!(paymentAccount instanceof CryptoCurrencyAccount))
        accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload());
}
Also used : GUIUtil(bisq.desktop.util.GUIUtil) TradeCurrency(bisq.core.locale.TradeCurrency) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) ActivatableDataModel(bisq.desktop.common.model.ActivatableDataModel) Inject(com.google.inject.Inject) SetChangeListener(javafx.collections.SetChangeListener) FXCollections(javafx.collections.FXCollections) FiatCurrency(bisq.core.locale.FiatCurrency) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Collectors(java.util.stream.Collectors) OpenOfferManager(bisq.core.offer.OpenOfferManager) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) User(bisq.core.user.User) PersistenceProtoResolver(bisq.common.proto.persistable.PersistenceProtoResolver) ArrayList(java.util.ArrayList) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) CryptoCurrency(bisq.core.locale.CryptoCurrency) Stage(javafx.stage.Stage) TradeManager(bisq.core.trade.TradeManager) Preferences(bisq.core.user.Preferences) ObservableList(javafx.collections.ObservableList) CryptoCurrency(bisq.core.locale.CryptoCurrency) TradeCurrency(bisq.core.locale.TradeCurrency) FiatCurrency(bisq.core.locale.FiatCurrency) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount)

Example 4 with CryptoCurrency

use of bisq.core.locale.CryptoCurrency in project bisq-desktop by bisq-network.

the class PreferencesView method activateDisplayCurrencies.

private void activateDisplayCurrencies() {
    preferredTradeCurrencyComboBox.setItems(tradeCurrencies);
    preferredTradeCurrencyComboBox.getSelectionModel().select(preferences.getPreferredTradeCurrency());
    preferredTradeCurrencyComboBox.setVisibleRowCount(25);
    preferredTradeCurrencyComboBox.setOnAction(e -> {
        TradeCurrency selectedItem = preferredTradeCurrencyComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null)
            preferences.setPreferredTradeCurrency(selectedItem);
    });
    fiatCurrenciesComboBox.setItems(allFiatCurrencies);
    fiatCurrenciesListView.setItems(fiatCurrencies);
    fiatCurrenciesComboBox.setOnAction(e -> {
        FiatCurrency selectedItem = fiatCurrenciesComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            preferences.addFiatCurrency(selectedItem);
            if (allFiatCurrencies.contains(selectedItem)) {
                UserThread.execute(() -> {
                    fiatCurrenciesComboBox.getSelectionModel().clearSelection();
                    allFiatCurrencies.remove(selectedItem);
                });
            }
        }
    });
    cryptoCurrenciesComboBox.setItems(allCryptoCurrencies);
    cryptoCurrenciesListView.setItems(cryptoCurrencies);
    cryptoCurrenciesComboBox.setOnAction(e -> {
        CryptoCurrency selectedItem = cryptoCurrenciesComboBox.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
            preferences.addCryptoCurrency(selectedItem);
            if (allCryptoCurrencies.contains(selectedItem)) {
                UserThread.execute(() -> {
                    cryptoCurrenciesComboBox.getSelectionModel().clearSelection();
                    allCryptoCurrencies.remove(selectedItem);
                });
            }
        }
    });
}
Also used : CryptoCurrency(bisq.core.locale.CryptoCurrency) TradeCurrency(bisq.core.locale.TradeCurrency) FiatCurrency(bisq.core.locale.FiatCurrency)

Example 5 with CryptoCurrency

use of bisq.core.locale.CryptoCurrency in project bisq-desktop by bisq-network.

the class OfferBookViewModel method fillAllTradeCurrencies.

private void fillAllTradeCurrencies() {
    allTradeCurrencies.clear();
    // Used for ignoring filter (show all)
    allTradeCurrencies.add(new CryptoCurrency(GUIUtil.SHOW_ALL_FLAG, GUIUtil.SHOW_ALL_FLAG));
    allTradeCurrencies.addAll(preferences.getTradeCurrenciesAsObservable());
    allTradeCurrencies.add(new CryptoCurrency(GUIUtil.EDIT_FLAG, GUIUtil.EDIT_FLAG));
}
Also used : CryptoCurrency(bisq.core.locale.CryptoCurrency)

Aggregations

CryptoCurrency (bisq.core.locale.CryptoCurrency)10 PaymentAccount (bisq.core.payment.PaymentAccount)6 TradeCurrency (bisq.core.locale.TradeCurrency)5 FiatCurrency (bisq.core.locale.FiatCurrency)4 BSFormatter (bisq.desktop.util.BSFormatter)3 ArrayList (java.util.ArrayList)3 UserThread (bisq.common.UserThread)2 PersistenceProtoResolver (bisq.common.proto.persistable.PersistenceProtoResolver)2 Tuple2 (bisq.common.util.Tuple2)2 Tuple3 (bisq.common.util.Tuple3)2 CurrencyUtil (bisq.core.locale.CurrencyUtil)2 Res (bisq.core.locale.Res)2 OpenOfferManager (bisq.core.offer.OpenOfferManager)2 AccountAgeWitnessService (bisq.core.payment.AccountAgeWitnessService)2 CryptoCurrencyAccount (bisq.core.payment.CryptoCurrencyAccount)2 PaymentMethod (bisq.core.payment.payload.PaymentMethod)2 FeeService (bisq.core.provider.fee.FeeService)2 TradeManager (bisq.core.trade.TradeManager)2 Preferences (bisq.core.user.Preferences)2 User (bisq.core.user.User)2