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