Search in sources :

Example 1 with TradeCurrency

use of io.bisq.common.locale.TradeCurrency in project bisq-api by mrosseel.

the class BisqProxy method addPaymentAccount.

public PaymentAccount addPaymentAccount(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());
    return paymentAccount;
}
Also used : AccountAgeWitnessService(io.bisq.core.payment.AccountAgeWitnessService) Transaction(org.bitcoinj.core.Transaction) PaymentAccount(io.bisq.core.payment.PaymentAccount) io.bisq.core.trade.protocol(io.bisq.core.trade.protocol) Coin(org.bitcoinj.core.Coin) User(io.bisq.core.user.User) BigDecimal(java.math.BigDecimal) CoinUtil(io.bisq.core.util.CoinUtil) FeeService(io.bisq.core.provider.fee.FeeService) ClosedTradableManager(io.bisq.core.trade.closed.ClosedTradableManager) ResultHandler(io.bisq.common.handlers.ResultHandler) CurrencyUtil(io.bisq.common.locale.CurrencyUtil) NodeAddress(io.bisq.network.p2p.NodeAddress) PaymentAccountHelper(io.bisq.api.model.payment.PaymentAccountHelper) Collectors(java.util.stream.Collectors) io.bisq.core.offer(io.bisq.core.offer) ECKey(org.bitcoinj.core.ECKey) Platform(javafx.application.Platform) BtcWalletService(io.bisq.core.btc.wallet.BtcWalletService) Slf4j(lombok.extern.slf4j.Slf4j) Stream(java.util.stream.Stream) Arbitrator(io.bisq.core.arbitration.Arbitrator) Address(org.bitcoinj.core.Address) KeyRing(io.bisq.common.crypto.KeyRing) ObservableList(javafx.collections.ObservableList) NotNull(org.jetbrains.annotations.NotNull) SellerAsMakerTrade(io.bisq.core.trade.SellerAsMakerTrade) CryptoCurrencyAccount(io.bisq.core.payment.CryptoCurrencyAccount) TradeManager(io.bisq.core.trade.TradeManager) java.util(java.util) Getter(lombok.Getter) ArbitratorManager(io.bisq.core.arbitration.ArbitratorManager) CryptoCurrency(io.bisq.common.locale.CryptoCurrency) TradeCurrency(io.bisq.common.locale.TradeCurrency) Preferences(io.bisq.core.user.Preferences) CompletableFuture(java.util.concurrent.CompletableFuture) PaymentAccountUtil.isPaymentAccountValidForOffer(io.bisq.core.payment.PaymentAccountUtil.isPaymentAccountValidForOffer) Strings(com.google.common.base.Strings) ErrorMessageHandler(io.bisq.common.handlers.ErrorMessageHandler) Trade(io.bisq.core.trade.Trade) FailedTradesManager(io.bisq.core.trade.failed.FailedTradesManager) io.bisq.api.model(io.bisq.api.model) BuyerAsMakerTrade(io.bisq.core.trade.BuyerAsMakerTrade) Nullable(javax.annotation.Nullable) BisqEnvironment(io.bisq.core.app.BisqEnvironment) AddressEntry(io.bisq.core.btc.AddressEntry) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) BsqWalletService(io.bisq.core.btc.wallet.BsqWalletService) Injector(com.google.inject.Injector) WalletsSetup(io.bisq.core.btc.wallet.WalletsSetup) Collectors.toList(java.util.stream.Collectors.toList) P2PService(io.bisq.network.p2p.P2PService) ValidationException(javax.validation.ValidationException) DevEnv(io.bisq.common.app.DevEnv) FiatCurrency(io.bisq.common.locale.FiatCurrency) Restrictions(io.bisq.core.btc.Restrictions) CryptoCurrency(io.bisq.common.locale.CryptoCurrency) TradeCurrency(io.bisq.common.locale.TradeCurrency) FiatCurrency(io.bisq.common.locale.FiatCurrency)

Example 2 with TradeCurrency

use of io.bisq.common.locale.TradeCurrency in project bisq-api by mrosseel.

the class AbstractPaymentAccountConverter method toRestModel.

protected void toRestModel(R rest, B business) {
    rest.id = business.getId();
    rest.accountName = business.getAccountName();
    final TradeCurrency selectedTradeCurrency = business.getSelectedTradeCurrency();
    if (null != selectedTradeCurrency)
        rest.selectedTradeCurrency = selectedTradeCurrency.getCode();
    final List<TradeCurrency> tradeCurrencies = business.getTradeCurrencies();
    if (null != tradeCurrencies)
        tradeCurrencies.stream().forEach(currency -> rest.tradeCurrencies.add(currency.getCode()));
}
Also used : List(java.util.List) TradeCurrency(io.bisq.common.locale.TradeCurrency) PaymentAccountPayload(io.bisq.core.payment.payload.PaymentAccountPayload) FiatCurrency(io.bisq.common.locale.FiatCurrency) TradeCurrency(io.bisq.common.locale.TradeCurrency)

Aggregations

FiatCurrency (io.bisq.common.locale.FiatCurrency)2 TradeCurrency (io.bisq.common.locale.TradeCurrency)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Strings (com.google.common.base.Strings)1 Injector (com.google.inject.Injector)1 io.bisq.api.model (io.bisq.api.model)1 PaymentAccountHelper (io.bisq.api.model.payment.PaymentAccountHelper)1 DevEnv (io.bisq.common.app.DevEnv)1 KeyRing (io.bisq.common.crypto.KeyRing)1 ErrorMessageHandler (io.bisq.common.handlers.ErrorMessageHandler)1 ResultHandler (io.bisq.common.handlers.ResultHandler)1 CryptoCurrency (io.bisq.common.locale.CryptoCurrency)1 CurrencyUtil (io.bisq.common.locale.CurrencyUtil)1 BisqEnvironment (io.bisq.core.app.BisqEnvironment)1 Arbitrator (io.bisq.core.arbitration.Arbitrator)1 ArbitratorManager (io.bisq.core.arbitration.ArbitratorManager)1 AddressEntry (io.bisq.core.btc.AddressEntry)1 Restrictions (io.bisq.core.btc.Restrictions)1 BsqWalletService (io.bisq.core.btc.wallet.BsqWalletService)1 BtcWalletService (io.bisq.core.btc.wallet.BtcWalletService)1