Search in sources :

Example 1 with CountryBasedPaymentAccount

use of bisq.core.payment.CountryBasedPaymentAccount 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 2 with CountryBasedPaymentAccount

use of bisq.core.payment.CountryBasedPaymentAccount 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 3 with CountryBasedPaymentAccount

use of bisq.core.payment.CountryBasedPaymentAccount in project bisq-desktop by bisq-network.

the class SepaInstantForm method autoFillNameTextField.

@Override
protected void autoFillNameTextField() {
    if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
        TradeCurrency singleTradeCurrency = this.paymentAccount.getSingleTradeCurrency();
        String currency = singleTradeCurrency != null ? singleTradeCurrency.getCode() : null;
        if (currency != null) {
            String iban = ibanInputTextField.getText();
            if (iban.length() > 9)
                iban = StringUtils.abbreviate(iban, 9);
            String method = Res.get(paymentAccount.getPaymentMethod().getId());
            CountryBasedPaymentAccount countryBasedPaymentAccount = (CountryBasedPaymentAccount) this.paymentAccount;
            String country = countryBasedPaymentAccount.getCountry() != null ? countryBasedPaymentAccount.getCountry().code : null;
            if (country != null)
                accountNameTextField.setText(method.concat(" (").concat(currency).concat("/").concat(country).concat("): ").concat(iban));
        }
    }
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount)

Example 4 with CountryBasedPaymentAccount

use of bisq.core.payment.CountryBasedPaymentAccount in project bisq-desktop by bisq-network.

the class CreateOfferDataModel method createAndGetOffer.

// /////////////////////////////////////////////////////////////////////////////////////////
// UI actions
// /////////////////////////////////////////////////////////////////////////////////////////
@SuppressWarnings("ConstantConditions")
Offer createAndGetOffer() {
    final boolean useMarketBasedPriceValue = marketPriceAvailable && useMarketBasedPrice.get();
    long priceAsLong = price.get() != null && !useMarketBasedPriceValue ? price.get().getValue() : 0L;
    String currencyCode = tradeCurrencyCode.get();
    boolean isCryptoCurrency = CurrencyUtil.isCryptoCurrency(currencyCode);
    String baseCurrencyCode = isCryptoCurrency ? currencyCode : Res.getBaseCurrencyCode();
    String counterCurrencyCode = isCryptoCurrency ? Res.getBaseCurrencyCode() : currencyCode;
    double marketPriceMarginParam = useMarketBasedPriceValue ? marketPriceMargin : 0;
    long amount = this.amount.get() != null ? this.amount.get().getValue() : 0L;
    long minAmount = this.minAmount.get() != null ? this.minAmount.get().getValue() : 0L;
    ArrayList<String> acceptedCountryCodes = null;
    if (paymentAccount instanceof SepaAccount) {
        acceptedCountryCodes = new ArrayList<>();
        acceptedCountryCodes.addAll(((SepaAccount) paymentAccount).getAcceptedCountryCodes());
    } else if (paymentAccount instanceof SepaInstantAccount) {
        acceptedCountryCodes = new ArrayList<>();
        acceptedCountryCodes.addAll(((SepaInstantAccount) paymentAccount).getAcceptedCountryCodes());
    } else if (paymentAccount instanceof CountryBasedPaymentAccount) {
        acceptedCountryCodes = new ArrayList<>();
        acceptedCountryCodes.add(((CountryBasedPaymentAccount) paymentAccount).getCountry().code);
    }
    ArrayList<String> acceptedBanks = null;
    if (paymentAccount instanceof SpecificBanksAccount) {
        acceptedBanks = new ArrayList<>(((SpecificBanksAccount) paymentAccount).getAcceptedBanks());
    } else if (paymentAccount instanceof SameBankAccount) {
        acceptedBanks = new ArrayList<>();
        acceptedBanks.add(((SameBankAccount) paymentAccount).getBankId());
    }
    String bankId = paymentAccount instanceof BankAccount ? ((BankAccount) paymentAccount).getBankId() : null;
    // That is optional and set to null if not supported (AltCoins, OKPay,...)
    String countryCode = paymentAccount instanceof CountryBasedPaymentAccount ? ((CountryBasedPaymentAccount) paymentAccount).getCountry().code : null;
    checkNotNull(p2PService.getAddress(), "Address must not be null");
    checkNotNull(getMakerFee(), "makerFee must not be null");
    long maxTradeLimit = getMaxTradeLimit();
    long maxTradePeriod = paymentAccount.getPaymentMethod().getMaxTradePeriod();
    // reserved for future use cases
    // Use null values if not set
    boolean isPrivateOffer = false;
    boolean useAutoClose = false;
    boolean useReOpenAfterAutoClose = false;
    long lowerClosePrice = 0;
    long upperClosePrice = 0;
    String hashOfChallenge = null;
    HashMap<String, String> extraDataMap = null;
    if (CurrencyUtil.isFiatCurrency(currencyCode)) {
        extraDataMap = new HashMap<>();
        final String myWitnessHashAsHex = accountAgeWitnessService.getMyWitnessHashAsHex(paymentAccount.getPaymentAccountPayload());
        extraDataMap.put(OfferPayload.ACCOUNT_AGE_WITNESS_HASH, myWitnessHashAsHex);
    }
    Coin buyerSecurityDepositAsCoin = buyerSecurityDeposit.get();
    checkArgument(buyerSecurityDepositAsCoin.compareTo(Restrictions.getMaxBuyerSecurityDeposit()) <= 0, "securityDeposit must be not exceed " + Restrictions.getMaxBuyerSecurityDeposit().toFriendlyString());
    checkArgument(buyerSecurityDepositAsCoin.compareTo(Restrictions.getMinBuyerSecurityDeposit()) >= 0, "securityDeposit must be not be less than " + Restrictions.getMinBuyerSecurityDeposit().toFriendlyString());
    checkArgument(!filterManager.isCurrencyBanned(currencyCode), Res.get("offerbook.warning.currencyBanned"));
    checkArgument(!filterManager.isPaymentMethodBanned(paymentAccount.getPaymentMethod()), Res.get("offerbook.warning.paymentMethodBanned"));
    OfferPayload offerPayload = new OfferPayload(offerId, new Date().getTime(), p2PService.getAddress(), keyRing.getPubKeyRing(), OfferPayload.Direction.valueOf(direction.name()), priceAsLong, marketPriceMarginParam, useMarketBasedPriceValue, amount, minAmount, baseCurrencyCode, counterCurrencyCode, Lists.newArrayList(user.getAcceptedArbitratorAddresses()), Lists.newArrayList(user.getAcceptedMediatorAddresses()), paymentAccount.getPaymentMethod().getId(), paymentAccount.getId(), null, countryCode, acceptedCountryCodes, bankId, acceptedBanks, Version.VERSION, btcWalletService.getLastBlockSeenHeight(), txFeeFromFeeService.value, getMakerFee().value, isCurrencyForMakerFeeBtc(), buyerSecurityDepositAsCoin.value, sellerSecurityDeposit.value, maxTradeLimit, maxTradePeriod, useAutoClose, useReOpenAfterAutoClose, upperClosePrice, lowerClosePrice, isPrivateOffer, hashOfChallenge, extraDataMap, Version.TRADE_PROTOCOL_VERSION);
    Offer offer = new Offer(offerPayload);
    offer.setPriceFeedService(priceFeedService);
    return offer;
}
Also used : SepaInstantAccount(bisq.core.payment.SepaInstantAccount) SameBankAccount(bisq.core.payment.SameBankAccount) SepaAccount(bisq.core.payment.SepaAccount) ArrayList(java.util.ArrayList) SameBankAccount(bisq.core.payment.SameBankAccount) BankAccount(bisq.core.payment.BankAccount) Date(java.util.Date) Coin(org.bitcoinj.core.Coin) Offer(bisq.core.offer.Offer) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount) OfferPayload(bisq.core.offer.OfferPayload) SpecificBanksAccount(bisq.core.payment.SpecificBanksAccount)

Example 5 with CountryBasedPaymentAccount

use of bisq.core.payment.CountryBasedPaymentAccount in project bisq-desktop by bisq-network.

the class SepaForm method autoFillNameTextField.

@Override
protected void autoFillNameTextField() {
    if (useCustomAccountNameCheckBox != null && !useCustomAccountNameCheckBox.isSelected()) {
        TradeCurrency singleTradeCurrency = this.paymentAccount.getSingleTradeCurrency();
        String currency = singleTradeCurrency != null ? singleTradeCurrency.getCode() : null;
        if (currency != null) {
            String iban = ibanInputTextField.getText();
            if (iban.length() > 9)
                iban = StringUtils.abbreviate(iban, 9);
            String method = Res.get(paymentAccount.getPaymentMethod().getId());
            CountryBasedPaymentAccount countryBasedPaymentAccount = (CountryBasedPaymentAccount) this.paymentAccount;
            String country = countryBasedPaymentAccount.getCountry() != null ? countryBasedPaymentAccount.getCountry().code : null;
            if (country != null)
                accountNameTextField.setText(method.concat(" (").concat(currency).concat("/").concat(country).concat("): ").concat(iban));
        }
    }
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount)

Aggregations

CountryBasedPaymentAccount (bisq.core.payment.CountryBasedPaymentAccount)5 Country (bisq.core.locale.Country)2 FiatCurrency (bisq.core.locale.FiatCurrency)2 TradeCurrency (bisq.core.locale.TradeCurrency)2 SepaAccount (bisq.core.payment.SepaAccount)2 Offer (bisq.core.offer.Offer)1 OfferPayload (bisq.core.offer.OfferPayload)1 BankAccount (bisq.core.payment.BankAccount)1 NationalBankAccount (bisq.core.payment.NationalBankAccount)1 SameBankAccount (bisq.core.payment.SameBankAccount)1 SepaInstantAccount (bisq.core.payment.SepaInstantAccount)1 SpecificBanksAccount (bisq.core.payment.SpecificBanksAccount)1 NationalBankAccountPayload (bisq.core.payment.payload.NationalBankAccountPayload)1 SepaAccountPayload (bisq.core.payment.payload.SepaAccountPayload)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Coin (org.bitcoinj.core.Coin)1