Search in sources :

Example 1 with CryptoCurrencyAccount

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

the class MainViewModel method setupDevDummyPaymentAccounts.

private void setupDevDummyPaymentAccounts() {
    if (user.getPaymentAccounts() != null && user.getPaymentAccounts().isEmpty()) {
        PerfectMoneyAccount perfectMoneyAccount = new PerfectMoneyAccount();
        perfectMoneyAccount.init();
        perfectMoneyAccount.setAccountNr("dummy_" + new Random().nextInt(100));
        // Don't translate only for dev
        perfectMoneyAccount.setAccountName("PerfectMoney dummy");
        perfectMoneyAccount.setSelectedTradeCurrency(GlobalSettings.getDefaultTradeCurrency());
        user.addPaymentAccount(perfectMoneyAccount);
        if (p2PService.isBootstrapped()) {
            accountAgeWitnessService.publishMyAccountAgeWitness(perfectMoneyAccount.getPaymentAccountPayload());
        } else {
            p2PService.addP2PServiceListener(new BootstrapListener() {

                @Override
                public void onUpdatedDataReceived() {
                    accountAgeWitnessService.publishMyAccountAgeWitness(perfectMoneyAccount.getPaymentAccountPayload());
                }
            });
        }
        CryptoCurrencyAccount cryptoCurrencyAccount = new CryptoCurrencyAccount();
        cryptoCurrencyAccount.init();
        // Don't translate only for dev
        cryptoCurrencyAccount.setAccountName("ETH dummy");
        cryptoCurrencyAccount.setAddress("0x" + new Random().nextInt(1000000));
        cryptoCurrencyAccount.setSingleTradeCurrency(CurrencyUtil.getCryptoCurrency("ETH").get());
        user.addPaymentAccount(cryptoCurrencyAccount);
    }
}
Also used : Random(java.util.Random) BootstrapListener(bisq.network.p2p.BootstrapListener) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount) PerfectMoneyAccount(bisq.core.payment.PerfectMoneyAccount)

Example 2 with CryptoCurrencyAccount

use of bisq.core.payment.CryptoCurrencyAccount 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());
}
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) ObservableList(javafx.collections.ObservableList) CryptoCurrency(bisq.core.locale.CryptoCurrency) TradeCurrency(bisq.core.locale.TradeCurrency) FiatCurrency(bisq.core.locale.FiatCurrency) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount)

Example 3 with CryptoCurrencyAccount

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

the class PaymentMethodForm method addLimitations.

protected void addLimitations() {
    long hours = paymentAccount.getPaymentMethod().getMaxTradePeriod() / 3600_000;
    final TradeCurrency tradeCurrency;
    if (paymentAccount.getSingleTradeCurrency() != null)
        tradeCurrency = paymentAccount.getSingleTradeCurrency();
    else if (paymentAccount.getSelectedTradeCurrency() != null)
        tradeCurrency = paymentAccount.getSelectedTradeCurrency();
    else if (!paymentAccount.getTradeCurrencies().isEmpty())
        tradeCurrency = paymentAccount.getTradeCurrencies().get(0);
    else
        tradeCurrency = paymentAccount instanceof CryptoCurrencyAccount ? CurrencyUtil.getAllSortedCryptoCurrencies().get(0) : CurrencyUtil.getDefaultTradeCurrency();
    final boolean isAddAccountScreen = paymentAccount.getAccountName() == null;
    final long accountAge = !isAddAccountScreen ? accountAgeWitnessService.getMyAccountAge(paymentAccount.getPaymentAccountPayload()) : 0L;
    addLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), Res.get("payment.maxPeriodAndLimit", getTimeText(hours), formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrency.getCode()))), formatter.formatAccountAge(accountAge)));
    if (isAddAccountScreen) {
        InputTextField inputTextField = addLabelInputTextField(gridPane, ++gridRow, Res.get("payment.salt"), 0).second;
        inputTextField.setText(Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
        inputTextField.textProperty().addListener((observable, oldValue, newValue) -> {
            if (!newValue.isEmpty()) {
                try {
                    // test if input is hex
                    Utilities.decodeFromHex(newValue);
                    paymentAccount.setSaltAsHex(newValue);
                } catch (Throwable t) {
                    new Popup().warning(Res.get("payment.error.noHexSalt")).show();
                    inputTextField.setText(Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
                    log.warn(t.toString());
                }
            }
        });
    } else {
        addLabelTextFieldWithCopyIcon(gridPane, ++gridRow, Res.get("payment.salt", Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt())), Utilities.bytesAsHexString(paymentAccount.getPaymentAccountPayload().getSalt()));
    }
}
Also used : TradeCurrency(bisq.core.locale.TradeCurrency) InputTextField(bisq.desktop.components.InputTextField) Popup(bisq.desktop.main.overlays.popups.Popup) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount)

Example 4 with CryptoCurrencyAccount

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

the class OfferBookViewModelTest method getCryptoAccount.

private PaymentAccount getCryptoAccount(String currencyCode) {
    PaymentAccount paymentAccount = new CryptoCurrencyAccount();
    paymentAccount.addCurrency(new CryptoCurrency(currencyCode, null));
    return paymentAccount;
}
Also used : CryptoCurrency(bisq.core.locale.CryptoCurrency) CountryBasedPaymentAccount(bisq.core.payment.CountryBasedPaymentAccount) PaymentAccount(bisq.core.payment.PaymentAccount) CryptoCurrencyAccount(bisq.core.payment.CryptoCurrencyAccount)

Aggregations

CryptoCurrencyAccount (bisq.core.payment.CryptoCurrencyAccount)4 CryptoCurrency (bisq.core.locale.CryptoCurrency)2 TradeCurrency (bisq.core.locale.TradeCurrency)2 PaymentAccount (bisq.core.payment.PaymentAccount)2 PersistenceProtoResolver (bisq.common.proto.persistable.PersistenceProtoResolver)1 FiatCurrency (bisq.core.locale.FiatCurrency)1 OpenOfferManager (bisq.core.offer.OpenOfferManager)1 AccountAgeWitnessService (bisq.core.payment.AccountAgeWitnessService)1 CountryBasedPaymentAccount (bisq.core.payment.CountryBasedPaymentAccount)1 PerfectMoneyAccount (bisq.core.payment.PerfectMoneyAccount)1 PaymentMethod (bisq.core.payment.payload.PaymentMethod)1 TradeManager (bisq.core.trade.TradeManager)1 Preferences (bisq.core.user.Preferences)1 User (bisq.core.user.User)1 ActivatableDataModel (bisq.desktop.common.model.ActivatableDataModel)1 InputTextField (bisq.desktop.components.InputTextField)1 Popup (bisq.desktop.main.overlays.popups.Popup)1 GUIUtil (bisq.desktop.util.GUIUtil)1 BootstrapListener (bisq.network.p2p.BootstrapListener)1 Inject (com.google.inject.Inject)1