Search in sources :

Example 1 with FiatCurrency

use of bisq.core.locale.FiatCurrency 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 FiatCurrency

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

the class OfferBookViewModelTest method getSepaAccount.

private PaymentAccount getSepaAccount(String currencyCode, String countryCode, String bic, ArrayList<String> countryCodes) {
    CountryBasedPaymentAccount paymentAccount = new SepaAccount();
    paymentAccount.setSingleTradeCurrency(new FiatCurrency(currencyCode));
    paymentAccount.setCountry(new Country(countryCode, null, null));
    ((SepaAccountPayload) paymentAccount.getPaymentAccountPayload()).setBic(bic);
    countryCodes.forEach(((SepaAccountPayload) paymentAccount.getPaymentAccountPayload())::addAcceptedCountry);
    return paymentAccount;
}
Also used : SepaAccount(bisq.core.payment.SepaAccount) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount) SepaAccountPayload(bisq.core.payment.payload.SepaAccountPayload) Country(bisq.core.locale.Country) FiatCurrency(bisq.core.locale.FiatCurrency)

Example 3 with FiatCurrency

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

the class OfferBookViewModelTest method getNationalBankAccount.

private PaymentAccount getNationalBankAccount(String currencyCode, String countryCode, String bankId) {
    CountryBasedPaymentAccount paymentAccount = new NationalBankAccount();
    paymentAccount.setSingleTradeCurrency(new FiatCurrency(currencyCode));
    paymentAccount.setCountry(new Country(countryCode, null, null));
    ((NationalBankAccountPayload) paymentAccount.getPaymentAccountPayload()).setBankId(bankId);
    return paymentAccount;
}
Also used : NationalBankAccount(bisq.core.payment.NationalBankAccount) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount) Country(bisq.core.locale.Country) FiatCurrency(bisq.core.locale.FiatCurrency) NationalBankAccountPayload(bisq.core.payment.payload.NationalBankAccountPayload)

Example 4 with FiatCurrency

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

the class OfferBookViewModelTest method getSpecificBanksAccount.

private PaymentAccount getSpecificBanksAccount(String currencyCode, String countryCode, String bankId, ArrayList<String> bankIds) {
    SpecificBanksAccount paymentAccount = new SpecificBanksAccount();
    paymentAccount.setSingleTradeCurrency(new FiatCurrency(currencyCode));
    paymentAccount.setCountry(new Country(countryCode, null, null));
    ((SpecificBanksAccountPayload) paymentAccount.getPaymentAccountPayload()).setBankId(bankId);
    bankIds.forEach(((SpecificBanksAccountPayload) paymentAccount.getPaymentAccountPayload())::addAcceptedBank);
    return paymentAccount;
}
Also used : Country(bisq.core.locale.Country) SpecificBanksAccountPayload(bisq.core.payment.payload.SpecificBanksAccountPayload) FiatCurrency(bisq.core.locale.FiatCurrency) SpecificBanksAccount(bisq.core.payment.SpecificBanksAccount)

Example 5 with FiatCurrency

use of bisq.core.locale.FiatCurrency 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)

Aggregations

FiatCurrency (bisq.core.locale.FiatCurrency)16 Country (bisq.core.locale.Country)8 TradeCurrency (bisq.core.locale.TradeCurrency)8 CryptoCurrency (bisq.core.locale.CryptoCurrency)5 PaymentAccount (bisq.core.payment.PaymentAccount)4 Popup (bisq.desktop.main.overlays.popups.Popup)4 ArrayList (java.util.ArrayList)4 ComboBox (javafx.scene.control.ComboBox)4 Label (javafx.scene.control.Label)4 Region (bisq.core.locale.Region)3 CountryBasedPaymentAccount (bisq.core.payment.CountryBasedPaymentAccount)3 Preferences (bisq.core.user.Preferences)3 PersistenceProtoResolver (bisq.common.proto.persistable.PersistenceProtoResolver)2 CurrencyUtil (bisq.core.locale.CurrencyUtil)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 TradeManager (bisq.core.trade.TradeManager)2 TradeStatistics2 (bisq.core.trade.statistics.TradeStatistics2)2