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());
}
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());
}
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());
}
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);
});
}
}
});
}
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));
}
Aggregations