Search in sources :

Example 1 with PaymentAccount

use of bisq.core.payment.PaymentAccount 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 PaymentAccount

use of bisq.core.payment.PaymentAccount 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)

Example 3 with PaymentAccount

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

the class FiatAccountsView method buildForm.

// /////////////////////////////////////////////////////////////////////////////////////////
// Base form
// /////////////////////////////////////////////////////////////////////////////////////////
private void buildForm() {
    addTitledGroupBg(root, gridRow, 1, Res.get("shared.manageAccounts"));
    Tuple2<Label, ListView> tuple = addLabelListView(root, gridRow, Res.get("account.fiat.yourFiatAccounts"), Layout.FIRST_ROW_DISTANCE);
    GridPane.setValignment(tuple.first, VPos.TOP);
    tuple.first.setTextAlignment(TextAlignment.RIGHT);
    // noinspection unchecked
    paymentAccountsListView = tuple.second;
    paymentAccountsListView.setPrefHeight(2 * Layout.LIST_ROW_HEIGHT + 14);
    paymentAccountsListView.setCellFactory(new Callback<ListView<PaymentAccount>, ListCell<PaymentAccount>>() {

        @Override
        public ListCell<PaymentAccount> call(ListView<PaymentAccount> list) {
            return new ListCell<PaymentAccount>() {

                final Label label = new AutoTooltipLabel();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new AutoTooltipButton("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final PaymentAccount item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(item.getAccountName());
                        removeButton.setOnAction(e -> onDeleteAccount(item));
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                    }
                }
            };
        }
    });
    Tuple3<Button, Button, Button> tuple3 = add3ButtonsAfterGroup(root, ++gridRow, Res.get("shared.addNewAccount"), Res.get("shared.ExportAccounts"), Res.get("shared.importAccounts"));
    addAccountButton = tuple3.first;
    exportButton = tuple3.second;
    importButton = tuple3.third;
}
Also used : Button(javafx.scene.control.Button) PopmoneyValidator(bisq.desktop.util.validation.PopmoneyValidator) Coin(org.bitcoinj.core.Coin) ListCell(javafx.scene.control.ListCell) Layout(bisq.desktop.util.Layout) BSFormatter(bisq.desktop.util.BSFormatter) PaymentAccountFactory(bisq.core.payment.PaymentAccountFactory) WesternUnionAccount(bisq.core.payment.WesternUnionAccount) ComboBox(javafx.scene.control.ComboBox) Res(bisq.core.locale.Res) MoneyBeamValidator(bisq.desktop.util.validation.MoneyBeamValidator) BICValidator(bisq.desktop.util.validation.BICValidator) AliPayForm(bisq.desktop.components.paymentmethods.AliPayForm) PopmoneyForm(bisq.desktop.components.paymentmethods.PopmoneyForm) SwishForm(bisq.desktop.components.paymentmethods.SwishForm) VenmoForm(bisq.desktop.components.paymentmethods.VenmoForm) AliPayValidator(bisq.desktop.util.validation.AliPayValidator) SepaInstantForm(bisq.desktop.components.paymentmethods.SepaInstantForm) Popup(bisq.desktop.main.overlays.popups.Popup) ChaseQuickPayValidator(bisq.desktop.util.validation.ChaseQuickPayValidator) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) FormBuilder(bisq.desktop.util.FormBuilder) ClearXchangeValidator(bisq.desktop.util.validation.ClearXchangeValidator) PaymentMethod(bisq.core.payment.payload.PaymentMethod) Collectors(java.util.stream.Collectors) AccountAgeWitnessService(bisq.core.payment.AccountAgeWitnessService) OKPayForm(bisq.desktop.components.paymentmethods.OKPayForm) OKPayValidator(bisq.desktop.util.validation.OKPayValidator) VenmoValidator(bisq.desktop.util.validation.VenmoValidator) PaymentAccount(bisq.core.payment.PaymentAccount) List(java.util.List) CashDepositForm(bisq.desktop.components.paymentmethods.CashDepositForm) RevolutValidator(bisq.desktop.util.validation.RevolutValidator) AnchorPane(javafx.scene.layout.AnchorPane) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) UpholdForm(bisq.desktop.components.paymentmethods.UpholdForm) UserThread(bisq.common.UserThread) SpecificBankForm(bisq.desktop.components.paymentmethods.SpecificBankForm) IBANValidator(bisq.desktop.util.validation.IBANValidator) FasterPaymentsForm(bisq.desktop.components.paymentmethods.FasterPaymentsForm) MoneyBeamForm(bisq.desktop.components.paymentmethods.MoneyBeamForm) SwishValidator(bisq.desktop.util.validation.SwishValidator) ClearXchangeForm(bisq.desktop.components.paymentmethods.ClearXchangeForm) ListView(javafx.scene.control.ListView) FXCollections(javafx.collections.FXCollections) FxmlView(bisq.desktop.common.view.FxmlView) Inject(javax.inject.Inject) ClearXchangeAccount(bisq.core.payment.ClearXchangeAccount) Tuple2(bisq.common.util.Tuple2) USPostalMoneyOrderValidator(bisq.desktop.util.validation.USPostalMoneyOrderValidator) Tuple3(bisq.common.util.Tuple3) VPos(javafx.geometry.VPos) UpholdValidator(bisq.desktop.util.validation.UpholdValidator) TextAlignment(javafx.scene.text.TextAlignment) Callback(javafx.util.Callback) RevolutForm(bisq.desktop.components.paymentmethods.RevolutForm) TitledGroupBg(bisq.desktop.components.TitledGroupBg) GridPane(javafx.scene.layout.GridPane) NationalBankForm(bisq.desktop.components.paymentmethods.NationalBankForm) SameBankForm(bisq.desktop.components.paymentmethods.SameBankForm) WesternUnionForm(bisq.desktop.components.paymentmethods.WesternUnionForm) Label(javafx.scene.control.Label) InteracETransferValidator(bisq.desktop.util.validation.InteracETransferValidator) PerfectMoneyForm(bisq.desktop.components.paymentmethods.PerfectMoneyForm) BisqEnvironment(bisq.core.app.BisqEnvironment) StringConverter(javafx.util.StringConverter) CashAppValidator(bisq.desktop.util.validation.CashAppValidator) USPostalMoneyOrderForm(bisq.desktop.components.paymentmethods.USPostalMoneyOrderForm) TimeUnit(java.util.concurrent.TimeUnit) PaymentMethodForm(bisq.desktop.components.paymentmethods.PaymentMethodForm) InputValidator(bisq.core.util.validation.InputValidator) ChaseQuickPayForm(bisq.desktop.components.paymentmethods.ChaseQuickPayForm) ImageUtil(bisq.desktop.util.ImageUtil) SepaForm(bisq.desktop.components.paymentmethods.SepaForm) ImageView(javafx.scene.image.ImageView) CashAppForm(bisq.desktop.components.paymentmethods.CashAppForm) InteracETransferForm(bisq.desktop.components.paymentmethods.InteracETransferForm) PerfectMoneyValidator(bisq.desktop.util.validation.PerfectMoneyValidator) ActivatableViewAndModel(bisq.desktop.common.view.ActivatableViewAndModel) ChangeListener(javafx.beans.value.ChangeListener) PaymentAccount(bisq.core.payment.PaymentAccount) ListCell(javafx.scene.control.ListCell) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) Label(javafx.scene.control.Label) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) ListView(javafx.scene.control.ListView) Button(javafx.scene.control.Button) AutoTooltipButton(bisq.desktop.components.AutoTooltipButton) ImageView(javafx.scene.image.ImageView) AutoTooltipLabel(bisq.desktop.components.AutoTooltipLabel) AnchorPane(javafx.scene.layout.AnchorPane)

Example 4 with PaymentAccount

use of bisq.core.payment.PaymentAccount 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 5 with PaymentAccount

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

the class AltCoinAccountsView method getPaymentMethodForm.

// /////////////////////////////////////////////////////////////////////////////////////////
// Utils
// /////////////////////////////////////////////////////////////////////////////////////////
private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod) {
    final PaymentAccount paymentAccount = PaymentAccountFactory.getPaymentAccount(paymentMethod);
    paymentAccount.init();
    return getPaymentMethodForm(paymentAccount);
}
Also used : PaymentAccount(bisq.core.payment.PaymentAccount)

Aggregations

PaymentAccount (bisq.core.payment.PaymentAccount)17 CryptoCurrency (bisq.core.locale.CryptoCurrency)7 TradeCurrency (bisq.core.locale.TradeCurrency)7 PaymentMethod (bisq.core.payment.payload.PaymentMethod)7 AccountAgeWitnessService (bisq.core.payment.AccountAgeWitnessService)6 Res (bisq.core.locale.Res)5 User (bisq.core.user.User)5 BSFormatter (bisq.desktop.util.BSFormatter)5 UserThread (bisq.common.UserThread)4 Tuple3 (bisq.common.util.Tuple3)4 CryptoCurrencyAccount (bisq.core.payment.CryptoCurrencyAccount)4 InputValidator (bisq.core.util.validation.InputValidator)4 Popup (bisq.desktop.main.overlays.popups.Popup)4 Tuple2 (bisq.common.util.Tuple2)3 FiatCurrency (bisq.core.locale.FiatCurrency)3 CountryBasedPaymentAccount (bisq.core.payment.CountryBasedPaymentAccount)3 PaymentAccountFactory (bisq.core.payment.PaymentAccountFactory)3 ActivatableViewAndModel (bisq.desktop.common.view.ActivatableViewAndModel)3 FxmlView (bisq.desktop.common.view.FxmlView)3 AutoTooltipButton (bisq.desktop.components.AutoTooltipButton)3