From 6c11fc18c78d559b8766227bdda790eabb45bc7a Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Mar 2019 01:12:54 -0500 Subject: [PATCH 1/6] Add altcoin payment method for live trading - Add LiveAsset account, payment method, AccountPayload - Extract super classes for normal CryptoCurrenyAccount and payload and LiveAssetAccount and payload - Add isAsset method - Add button for creating a live asset account As it is a bit tricky to use the AccountForm for both methods and add a checkbox there so defined which payment method to use I added a button to add an AccountForm with the LiveAssets passed. This is just temporary to be able to test a bit more and see if there are any critical issues. We should unify that form but that might require a bit of refactoring of the CryptoCurrencyForm. --- common/src/main/proto/pb.proto | 5 ++ .../java/bisq/core/payment/AssetAccount.java | 35 ++++++++ .../core/payment/CryptoCurrencyAccount.java | 10 +-- .../bisq/core/payment/LiveAssetsAccount.java | 37 ++++++++ .../core/payment/PaymentAccountFactory.java | 2 + .../payment/payload/AssetsAccountPayload.java | 82 ++++++++++++++++++ .../payload/CryptoCurrencyAccountPayload.java | 28 +----- .../payload/LiveAssetsAccountPayload.java | 80 +++++++++++++++++ .../core/payment/payload/PaymentMethod.java | 10 ++- .../resources/i18n/displayStrings.properties | 5 ++ .../paymentmethods/CryptoCurrencyForm.java | 26 +++--- .../AltCoinAccountsDataModel.java | 3 +- .../altcoinaccounts/AltCoinAccountsView.java | 86 ++++++++++++++++++- .../fiataccounts/FiatAccountsDataModel.java | 3 +- .../fiataccounts/FiatAccountsView.java | 2 +- .../pendingtrades/PendingTradesViewModel.java | 3 +- .../steps/buyer/BuyerStep2View.java | 1 + .../main/java/bisq/desktop/util/GUIUtil.java | 12 ++- 18 files changed, 364 insertions(+), 66 deletions(-) create mode 100644 core/src/main/java/bisq/core/payment/AssetAccount.java create mode 100644 core/src/main/java/bisq/core/payment/LiveAssetsAccount.java create mode 100644 core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java create mode 100644 core/src/main/java/bisq/core/payment/payload/LiveAssetsAccountPayload.java diff --git a/common/src/main/proto/pb.proto b/common/src/main/proto/pb.proto index 8db992f910a..602b3628a3c 100644 --- a/common/src/main/proto/pb.proto +++ b/common/src/main/proto/pb.proto @@ -725,6 +725,7 @@ message PaymentAccountPayload { HalCashAccountPayload hal_cash_account_payload = 24; PromptPayAccountPayload prompt_pay_account_payload = 25; AdvancedCashAccountPayload advanced_cash_account_payload = 26; + LiveAssetsAccountPayload live_assets_account_payload = 27; } map exclude_from_json_data = 15; } @@ -836,6 +837,10 @@ message CryptoCurrencyAccountPayload { string address = 1; } +message LiveAssetsAccountPayload { + string address = 1; +} + message FasterPaymentsAccountPayload { string sort_code = 1; string account_nr = 2; diff --git a/core/src/main/java/bisq/core/payment/AssetAccount.java b/core/src/main/java/bisq/core/payment/AssetAccount.java new file mode 100644 index 00000000000..de7c2e72d2f --- /dev/null +++ b/core/src/main/java/bisq/core/payment/AssetAccount.java @@ -0,0 +1,35 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.core.payment; + +import bisq.core.payment.payload.AssetsAccountPayload; +import bisq.core.payment.payload.PaymentMethod; + +public abstract class AssetAccount extends PaymentAccount { + protected AssetAccount(PaymentMethod paymentMethod) { + super(paymentMethod); + } + + public void setAddress(String address) { + ((AssetsAccountPayload) paymentAccountPayload).setAddress(address); + } + + public String getAddress() { + return ((AssetsAccountPayload) paymentAccountPayload).getAddress(); + } +} diff --git a/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java b/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java index ad096d15d99..534157bd1f8 100644 --- a/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java +++ b/core/src/main/java/bisq/core/payment/CryptoCurrencyAccount.java @@ -24,7 +24,7 @@ import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) -public final class CryptoCurrencyAccount extends PaymentAccount { +public final class CryptoCurrencyAccount extends AssetAccount { public CryptoCurrencyAccount() { super(PaymentMethod.BLOCK_CHAINS); @@ -34,12 +34,4 @@ public CryptoCurrencyAccount() { protected PaymentAccountPayload createPayload() { return new CryptoCurrencyAccountPayload(paymentMethod.getId(), id); } - - public void setAddress(String address) { - ((CryptoCurrencyAccountPayload) paymentAccountPayload).setAddress(address); - } - - public String getAddress() { - return ((CryptoCurrencyAccountPayload) paymentAccountPayload).getAddress(); - } } diff --git a/core/src/main/java/bisq/core/payment/LiveAssetsAccount.java b/core/src/main/java/bisq/core/payment/LiveAssetsAccount.java new file mode 100644 index 00000000000..9375220e836 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/LiveAssetsAccount.java @@ -0,0 +1,37 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.core.payment; + +import bisq.core.payment.payload.LiveAssetsAccountPayload; +import bisq.core.payment.payload.PaymentAccountPayload; +import bisq.core.payment.payload.PaymentMethod; + +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +public final class LiveAssetsAccount extends AssetAccount { + + public LiveAssetsAccount() { + super(PaymentMethod.LIVE_ASSETS); + } + + @Override + protected PaymentAccountPayload createPayload() { + return new LiveAssetsAccountPayload(paymentMethod.getId(), id); + } +} diff --git a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java index b35dabc3ff1..d452e95da3f 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java @@ -74,6 +74,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) { return new PromptPayAccount(); case PaymentMethod.ADVANCED_CASH_ID: return new AdvancedCashAccount(); + case PaymentMethod.LIVE_ASSETS_ID: + return new LiveAssetsAccount(); default: throw new RuntimeException("Not supported PaymentMethod: " + paymentMethod); } diff --git a/core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java new file mode 100644 index 00000000000..76d34790e62 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/payload/AssetsAccountPayload.java @@ -0,0 +1,82 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.core.payment.payload; + +import bisq.core.locale.Res; + +import java.nio.charset.Charset; + +import java.util.Map; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +import javax.annotation.Nullable; + +@EqualsAndHashCode(callSuper = true) +@ToString +@Setter +@Getter +@Slf4j +public abstract class AssetsAccountPayload extends PaymentAccountPayload { + protected String address = ""; + + protected AssetsAccountPayload(String paymentMethod, String id) { + super(paymentMethod, id); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // PROTO BUFFER + /////////////////////////////////////////////////////////////////////////////////////////// + + protected AssetsAccountPayload(String paymentMethod, + String id, + String address, + long maxTradePeriod, + @Nullable Map excludeFromJsonDataMap) { + super(paymentMethod, + id, + maxTradePeriod, + excludeFromJsonDataMap); + this.address = address; + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // API + /////////////////////////////////////////////////////////////////////////////////////////// + + @Override + public String getPaymentDetails() { + return Res.getWithCol("payment.altcoin.receiver.address") + " " + address; + } + + @Override + public String getPaymentDetailsForTradePopup() { + return getPaymentDetails(); + } + + @Override + public byte[] getAgeWitnessInputData() { + return super.getAgeWitnessInputData(address.getBytes(Charset.forName("UTF-8"))); + } +} diff --git a/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java index 04dcbe94f9f..a295816f642 100644 --- a/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/CryptoCurrencyAccountPayload.java @@ -17,16 +17,12 @@ package bisq.core.payment.payload; -import bisq.core.locale.Res; - import io.bisq.generated.protobuffer.PB; import com.google.protobuf.Message; import org.springframework.util.CollectionUtils; -import java.nio.charset.Charset; - import java.util.HashMap; import java.util.Map; @@ -43,8 +39,7 @@ @Setter @Getter @Slf4j -public final class CryptoCurrencyAccountPayload extends PaymentAccountPayload { - private String address = ""; +public final class CryptoCurrencyAccountPayload extends AssetsAccountPayload { public CryptoCurrencyAccountPayload(String paymentMethod, String id) { super(paymentMethod, id); @@ -62,9 +57,9 @@ private CryptoCurrencyAccountPayload(String paymentMethod, @Nullable Map excludeFromJsonDataMap) { super(paymentMethod, id, + address, maxTradePeriod, excludeFromJsonDataMap); - this.address = address; } @Override @@ -83,23 +78,4 @@ public static CryptoCurrencyAccountPayload fromProto(PB.PaymentAccountPayload pr CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); } - - /////////////////////////////////////////////////////////////////////////////////////////// - // API - /////////////////////////////////////////////////////////////////////////////////////////// - - @Override - public String getPaymentDetails() { - return Res.getWithCol("payment.altcoin.receiver.address") + " " + address; - } - - @Override - public String getPaymentDetailsForTradePopup() { - return getPaymentDetails(); - } - - @Override - public byte[] getAgeWitnessInputData() { - return super.getAgeWitnessInputData(address.getBytes(Charset.forName("UTF-8"))); - } } diff --git a/core/src/main/java/bisq/core/payment/payload/LiveAssetsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/LiveAssetsAccountPayload.java new file mode 100644 index 00000000000..9b4f7517c47 --- /dev/null +++ b/core/src/main/java/bisq/core/payment/payload/LiveAssetsAccountPayload.java @@ -0,0 +1,80 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.core.payment.payload; + +import io.bisq.generated.protobuffer.PB; + +import com.google.protobuf.Message; + +import org.springframework.util.CollectionUtils; + +import java.util.HashMap; +import java.util.Map; + +import lombok.EqualsAndHashCode; +import lombok.Getter; +import lombok.Setter; +import lombok.ToString; +import lombok.extern.slf4j.Slf4j; + +import javax.annotation.Nullable; + +@EqualsAndHashCode(callSuper = true) +@ToString +@Setter +@Getter +@Slf4j +public final class LiveAssetsAccountPayload extends AssetsAccountPayload { + + public LiveAssetsAccountPayload(String paymentMethod, String id) { + super(paymentMethod, id); + } + + + /////////////////////////////////////////////////////////////////////////////////////////// + // PROTO BUFFER + /////////////////////////////////////////////////////////////////////////////////////////// + + private LiveAssetsAccountPayload(String paymentMethod, + String id, + String address, + long maxTradePeriod, + @Nullable Map excludeFromJsonDataMap) { + super(paymentMethod, + id, + address, + maxTradePeriod, + excludeFromJsonDataMap); + } + + @Override + public Message toProtoMessage() { + return getPaymentAccountPayloadBuilder() + .setLiveAssetsAccountPayload(PB.LiveAssetsAccountPayload.newBuilder() + .setAddress(address)) + .build(); + } + + public static LiveAssetsAccountPayload fromProto(PB.PaymentAccountPayload proto) { + return new LiveAssetsAccountPayload(proto.getPaymentMethodId(), + proto.getId(), + proto.getLiveAssetsAccountPayload().getAddress(), + proto.getMaxTradePeriod(), + CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); + } +} diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java index 7722dca9ae7..e307311ef7d 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -89,6 +89,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable { public static final String BLOCK_CHAINS_ID = "BLOCK_CHAINS"; public static final String PROMPT_PAY_ID = "PROMPT_PAY"; public static final String ADVANCED_CASH_ID = "ADVANCED_CASH"; + public static final String LIVE_ASSETS_ID = "LIVE_ASSETS"; public static PaymentMethod UPHOLD; public static PaymentMethod MONEY_BEAM; @@ -116,6 +117,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable { public static PaymentMethod BLOCK_CHAINS; public static PaymentMethod PROMPT_PAY; public static PaymentMethod ADVANCED_CASH; + public static PaymentMethod LIVE_ASSETS; // The limit and duration assignment must not be changed as that could break old offers (if amount would be higher // than new trade limit) and violate the maker expectation when he created the offer (duration). @@ -166,7 +168,9 @@ public final class PaymentMethod implements PersistablePayload, Comparable { PROMPT_PAY = new PaymentMethod(PROMPT_PAY_ID, DAY, DEFAULT_TRADE_LIMIT_LOW_RISK), // Altcoins - BLOCK_CHAINS = new PaymentMethod(BLOCK_CHAINS_ID, DAY, DEFAULT_TRADE_LIMIT_VERY_LOW_RISK) + BLOCK_CHAINS = new PaymentMethod(BLOCK_CHAINS_ID, DAY, DEFAULT_TRADE_LIMIT_VERY_LOW_RISK), + // Altcoins with 1 hour trade period + LIVE_ASSETS = new PaymentMethod(LIVE_ASSETS_ID, TimeUnit.HOURS.toMillis(1), DEFAULT_TRADE_LIMIT_VERY_LOW_RISK) )); static { @@ -292,4 +296,8 @@ public int compareTo(@NotNull Object other) { else return 0; } + + public boolean isAsset() { + return this.equals(LIVE_ASSETS) || this.equals(BLOCK_CHAINS); + } } diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 32bd9ff409b..5b2b0ca6281 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2561,6 +2561,8 @@ BLOCK_CHAINS=Altcoins PROMPT_PAY=PromptPay # suppress inspection "UnusedProperty" ADVANCED_CASH=Advanced Cash +# suppress inspection "UnusedProperty" +LIVE_ASSETS=Live assets # suppress inspection "UnusedProperty" UPHOLD_SHORT=Uphold @@ -2598,6 +2600,9 @@ BLOCK_CHAINS_SHORT=Altcoins PROMPT_PAY_SHORT=PromptPay # suppress inspection "UnusedProperty" ADVANCED_CASH_SHORT=Advanced Cash +# suppress inspection "UnusedProperty" +LIVE_ASSETS_SHORT=Live assets + #################################################################### # Validation diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java index 5b962b5faf2..7a9039cdae8 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java @@ -27,7 +27,7 @@ import bisq.core.locale.Res; import bisq.core.locale.TradeCurrency; import bisq.core.payment.AccountAgeWitnessService; -import bisq.core.payment.CryptoCurrencyAccount; +import bisq.core.payment.AssetAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.CryptoCurrencyAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; @@ -56,7 +56,7 @@ import static bisq.desktop.util.GUIUtil.getComboBoxButtonCell; public class CryptoCurrencyForm extends PaymentMethodForm { - private final CryptoCurrencyAccount cryptoCurrencyAccount; + private final AssetAccount assetAccount; private final AltCoinAddressValidator altCoinAddressValidator; private final AssetService assetService; private final FilterManager filterManager; @@ -82,7 +82,7 @@ public CryptoCurrencyForm(PaymentAccount paymentAccount, AssetService assetService, FilterManager filterManager) { super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); - this.cryptoCurrencyAccount = (CryptoCurrencyAccount) paymentAccount; + this.assetAccount = (AssetAccount) paymentAccount; this.altCoinAddressValidator = altCoinAddressValidator; this.assetService = assetService; this.filterManager = filterManager; @@ -99,7 +99,7 @@ public void addFormForAddAccount() { addressInputTextField.setValidator(altCoinAddressValidator); addressInputTextField.textProperty().addListener((ov, oldValue, newValue) -> { - cryptoCurrencyAccount.setAddress(newValue); + assetAccount.setAddress(newValue); updateFromInputs(); }); @@ -109,9 +109,9 @@ public void addFormForAddAccount() { @Override public void updateFromInputs() { - if (addressInputTextField != null && cryptoCurrencyAccount.getSingleTradeCurrency() != null) + if (addressInputTextField != null && assetAccount.getSingleTradeCurrency() != null) addressInputTextField.setPromptText(Res.get("payment.altcoin.address.dyn", - cryptoCurrencyAccount.getSingleTradeCurrency().getName())); + assetAccount.getSingleTradeCurrency().getName())); super.updateFromInputs(); } @@ -131,14 +131,14 @@ protected void autoFillNameTextField() { public void addFormForDisplayAccount() { gridRowFrom = gridRow; addTopLabelTextField(gridPane, gridRow, Res.get("payment.account.name"), - cryptoCurrencyAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); + assetAccount.getAccountName(), Layout.FIRST_ROW_AND_GROUP_DISTANCE); addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("shared.paymentMethod"), - Res.get(cryptoCurrencyAccount.getPaymentMethod().getId())); + Res.get(assetAccount.getPaymentMethod().getId())); Tuple3 tuple2 = addCompactTopLabelTextField(gridPane, ++gridRow, - Res.get("payment.altcoin.address"), cryptoCurrencyAccount.getAddress()); + Res.get("payment.altcoin.address"), assetAccount.getAddress()); TextField field = tuple2.second; field.setMouseTransparent(false); - final TradeCurrency singleTradeCurrency = cryptoCurrencyAccount.getSingleTradeCurrency(); + final TradeCurrency singleTradeCurrency = assetAccount.getSingleTradeCurrency(); final String nameAndCode = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : ""; addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.altcoin"), nameAndCode); @@ -147,12 +147,12 @@ public void addFormForDisplayAccount() { @Override public void updateAllInputsValid() { - TradeCurrency selectedTradeCurrency = cryptoCurrencyAccount.getSelectedTradeCurrency(); + TradeCurrency selectedTradeCurrency = assetAccount.getSelectedTradeCurrency(); if (selectedTradeCurrency != null) { altCoinAddressValidator.setCurrencyCode(selectedTradeCurrency.getCode()); allInputsValid.set(isAccountNameValid() - && altCoinAddressValidator.validate(cryptoCurrencyAccount.getAddress()).isValid - && cryptoCurrencyAccount.getSingleTradeCurrency() != null); + && altCoinAddressValidator.validate(assetAccount.getAddress()).isValid + && assetAccount.getSingleTradeCurrency() != null); } } diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java index d431bcddab1..cd333ed391a 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java @@ -27,7 +27,6 @@ import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.CryptoCurrencyAccount; import bisq.core.payment.PaymentAccount; -import bisq.core.payment.payload.PaymentMethod; import bisq.core.trade.TradeManager; import bisq.core.user.Preferences; import bisq.core.user.User; @@ -83,7 +82,7 @@ protected void activate() { private void fillAndSortPaymentAccounts() { if (user.getPaymentAccounts() != null) { paymentAccounts.setAll(user.getPaymentAccounts().stream() - .filter(paymentAccount -> paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.BLOCK_CHAINS_ID)) + .filter(paymentAccount -> paymentAccount.getPaymentMethod().isAsset()) .collect(Collectors.toList())); paymentAccounts.sort((o1, o2) -> o1.getCreationDate().compareTo(o2.getCreationDate())); } diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java index 732e1a150ae..23db2f58aa7 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java @@ -18,6 +18,7 @@ package bisq.desktop.main.account.content.altcoinaccounts; import bisq.desktop.common.view.FxmlView; +import bisq.desktop.components.AutoTooltipButton; import bisq.desktop.components.TitledGroupBg; import bisq.desktop.components.paymentmethods.CryptoCurrencyForm; import bisq.desktop.components.paymentmethods.PaymentMethodForm; @@ -45,6 +46,7 @@ import bisq.common.util.Tuple2; import bisq.common.util.Tuple3; +import bisq.common.util.Tuple4; import javax.inject.Inject; @@ -54,14 +56,17 @@ import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; +import javafx.geometry.Insets; + import javafx.collections.ObservableList; import java.util.Optional; import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup; -import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup; import static bisq.desktop.util.FormBuilder.addTitledGroupBg; import static bisq.desktop.util.FormBuilder.addTopLabelListView; @@ -79,6 +84,8 @@ public class AltCoinAccountsView extends PaymentAccountsView tuple3 = add3ButtonsAfterGroup(root, ++gridRow, Res.get("shared.addNewAccount"), + // TODO just for dev + Tuple4 tuple4 = add4Buttons(root, ++gridRow, Res.get("shared.addNewAccount"), + "Add Live Assets account", Res.get("shared.ExportAccounts"), Res.get("shared.importAccounts"), 15); + addAccountButton = tuple4.first; + addLiveAssetAccountButton = tuple4.second; + exportButton = tuple4.third; + importButton = tuple4.forth; + addLiveAssetAccountButton.setOnAction(event -> addNewLiveAssetAccount()); + + /* Tuple3 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; + */ + } + + //TODO just temp for dev + private Tuple4 add4Buttons(GridPane gridPane, + int rowIndex, + String title1, + String title2, + String title3, + String title4, + double top) { + HBox hBox = new HBox(); + hBox.setSpacing(10); + Button button1 = new AutoTooltipButton(title1); + + button1.getStyleClass().add("action-button"); + button1.setDefaultButton(true); + button1.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button1, Priority.ALWAYS); + + Button button2 = new AutoTooltipButton(title2); + button2.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button2, Priority.ALWAYS); + + Button button3 = new AutoTooltipButton(title3); + button3.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button3, Priority.ALWAYS); + + Button button4 = new AutoTooltipButton(title4); + button4.setMaxWidth(Double.MAX_VALUE); + HBox.setHgrow(button4, Priority.ALWAYS); + + hBox.getChildren().addAll(button1, button2, button3, button4); + GridPane.setRowIndex(hBox, rowIndex); + GridPane.setColumnIndex(hBox, 0); + GridPane.setMargin(hBox, new Insets(top, 10, 0, 0)); + gridPane.getChildren().add(hBox); + return new Tuple4<>(button1, button2, button3, button4); + } + + //TODO temp for dev + private void addNewLiveAssetAccount() { + paymentAccountsListView.getSelectionModel().clearSelection(); + removeAccountRows(); + addAccountButton.setDisable(true); + accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.createNewAccount"), Layout.GROUP_DISTANCE); + + if (paymentMethodForm != null) { + FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1); + GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); + } + gridRow = 2; + // We don't separate here between normal altcoin and live assets + paymentMethodForm = getPaymentMethodForm(PaymentMethod.LIVE_ASSETS); + + paymentMethodForm.addFormForAddAccount(); + gridRow = paymentMethodForm.getGridRow(); + Tuple2 tuple2 = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.saveNewAccount"), Res.get("shared.cancel")); + saveNewAccountButton = tuple2.first; + saveNewAccountButton.setOnAction(event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount())); + saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not()); + Button cancelButton = tuple2.second; + cancelButton.setOnAction(event -> onCancelNewAccount()); + GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); } // Add new account form @@ -221,7 +301,7 @@ protected void onSelectAccount(PaymentAccount paymentAccount) { /////////////////////////////////////////////////////////////////////////////////////////// private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod) { - final PaymentAccount paymentAccount = PaymentAccountFactory.getPaymentAccount(paymentMethod); + PaymentAccount paymentAccount = PaymentAccountFactory.getPaymentAccount(paymentMethod); paymentAccount.init(); return getPaymentMethodForm(paymentAccount); } diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java index 88afc51720b..af180bbeed1 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java @@ -28,7 +28,6 @@ import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.CryptoCurrencyAccount; import bisq.core.payment.PaymentAccount; -import bisq.core.payment.payload.PaymentMethod; import bisq.core.trade.TradeManager; import bisq.core.user.Preferences; import bisq.core.user.User; @@ -85,7 +84,7 @@ protected void activate() { private void fillAndSortPaymentAccounts() { if (user.getPaymentAccounts() != null) { List list = user.getPaymentAccounts().stream() - .filter(paymentAccount -> !paymentAccount.getPaymentMethod().getId().equals(PaymentMethod.BLOCK_CHAINS_ID)) + .filter(paymentAccount -> !paymentAccount.getPaymentMethod().isAsset()) .collect(Collectors.toList()); paymentAccounts.setAll(list); paymentAccounts.sort(Comparator.comparing(PaymentAccount::getCreationDate)); diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java index b3564ae0b19..80d76c875c9 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsView.java @@ -334,7 +334,7 @@ protected void addNewAccount() { paymentMethodComboBox.setVisibleRowCount(11); paymentMethodComboBox.setPrefWidth(250); List list = PaymentMethod.getPaymentMethods().stream() - .filter(paymentMethod -> !paymentMethod.getId().equals(PaymentMethod.BLOCK_CHAINS_ID)) + .filter(paymentMethod -> !paymentMethod.isAsset()) .collect(Collectors.toList()); paymentMethodComboBox.setItems(FXCollections.observableArrayList(list)); paymentMethodComboBox.setConverter(new StringConverter<>() { diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java index ab41b1ee552..11ff39e3823 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/PendingTradesViewModel.java @@ -25,7 +25,6 @@ import bisq.core.network.MessageState; import bisq.core.offer.Offer; import bisq.core.payment.AccountAgeWitnessService; -import bisq.core.payment.payload.PaymentMethod; import bisq.core.trade.Contract; import bisq.core.trade.Trade; import bisq.core.trade.closed.ClosedTradableManager; @@ -322,7 +321,7 @@ public String getSecurityDeposit() { } public boolean isBlockChainMethod() { - return dataModel.getOffer() != null && dataModel.getOffer().getPaymentMethod().equals(PaymentMethod.BLOCK_CHAINS); + return dataModel.getOffer() != null && dataModel.getOffer().getPaymentMethod().isAsset(); } public int getNumPastTrades(Trade trade) { diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 7d4eb004485..7dbc0bd9481 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -281,6 +281,7 @@ protected void addContent() { gridRow = F2FForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, model.dataModel.getTrade().getOffer(), 0); break; case PaymentMethod.BLOCK_CHAINS_ID: + case PaymentMethod.LIVE_ASSETS_ID: String labelTitle = Res.get("portfolio.pending.step2_buyer.sellersAddress", CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode())); gridRow = CryptoCurrencyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, labelTitle); diff --git a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java index a97f98ec29f..163cf0481ff 100644 --- a/desktop/src/main/java/bisq/desktop/util/GUIUtil.java +++ b/desktop/src/main/java/bisq/desktop/util/GUIUtil.java @@ -532,18 +532,16 @@ protected void updateItem(PaymentMethod item, boolean empty) { public static Callback, ListCell> getPaymentMethodCellFactory() { return p -> new ListCell<>() { @Override - protected void updateItem(PaymentMethod item, boolean empty) { - super.updateItem(item, empty); + protected void updateItem(PaymentMethod method, boolean empty) { + super.updateItem(method, empty); - if (item != null && !empty) { - - String id = item.getId(); + if (method != null && !empty) { + String id = method.getId(); HBox box = new HBox(); box.setSpacing(20); - final boolean isBlockchainPaymentMethod = item.equals(PaymentMethod.BLOCK_CHAINS); Label paymentType = new AutoTooltipLabel( - isBlockchainPaymentMethod ? Res.get("shared.crypto") : Res.get("shared.fiat")); + method.isAsset() ? Res.get("shared.crypto") : Res.get("shared.fiat")); paymentType.getStyleClass().add("currency-label-small"); Label paymentMethod = new AutoTooltipLabel(Res.get(id)); From 11adc99f3cd01254575b84b725ab49455458e3b2 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Mar 2019 01:31:26 -0500 Subject: [PATCH 2/6] Use super classes for cryptCurrencyAccount and payload --- .../core/payment/AccountAgeWitnessService.java | 2 +- .../java/bisq/core/proto/CoreProtoResolver.java | 3 +++ .../paymentmethods/CryptoCurrencyForm.java | 4 ++-- .../paymentmethods/PaymentMethodForm.java | 6 +++--- .../altcoinaccounts/AltCoinAccountsDataModel.java | 6 +++--- .../fiataccounts/FiatAccountsDataModel.java | 4 ++-- .../pendingtrades/steps/buyer/BuyerStep2View.java | 6 +++--- .../steps/seller/SellerStep3View.java | 14 +++++++------- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/core/src/main/java/bisq/core/payment/AccountAgeWitnessService.java b/core/src/main/java/bisq/core/payment/AccountAgeWitnessService.java index e30617ef8df..e3890d463f6 100644 --- a/core/src/main/java/bisq/core/payment/AccountAgeWitnessService.java +++ b/core/src/main/java/bisq/core/payment/AccountAgeWitnessService.java @@ -126,7 +126,7 @@ public void onUpdatedDataReceived() { private void republishAllFiatAccounts() { if (user.getPaymentAccounts() != null) user.getPaymentAccounts().stream() - .filter(e -> !(e instanceof CryptoCurrencyAccount)) + .filter(e -> !(e instanceof AssetAccount)) .forEach(e -> { // We delay with a random interval of 20-60 sec to ensure to be better connected and don't stress the // P2P network with publishing all at once at startup time. diff --git a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java index b5cd297bd42..4ab9737795d 100644 --- a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java @@ -30,6 +30,7 @@ import bisq.core.payment.payload.FasterPaymentsAccountPayload; import bisq.core.payment.payload.HalCashAccountPayload; import bisq.core.payment.payload.InteracETransferAccountPayload; +import bisq.core.payment.payload.LiveAssetsAccountPayload; import bisq.core.payment.payload.MoneyBeamAccountPayload; import bisq.core.payment.payload.MoneyGramAccountPayload; import bisq.core.payment.payload.NationalBankAccountPayload; @@ -132,6 +133,8 @@ public PaymentAccountPayload fromProto(PB.PaymentAccountPayload proto) { return PromptPayAccountPayload.fromProto(proto); case ADVANCED_CASH_ACCOUNT_PAYLOAD: return AdvancedCashAccountPayload.fromProto(proto); + case LIVE_ASSETS_ACCOUNT_PAYLOAD: + return LiveAssetsAccountPayload.fromProto(proto); default: throw new ProtobufferRuntimeException("Unknown proto message case(PB.PaymentAccountPayload). messageCase=" + messageCase); } diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java index 7a9039cdae8..4270ad0a64b 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java @@ -29,7 +29,7 @@ import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.AssetAccount; import bisq.core.payment.PaymentAccount; -import bisq.core.payment.payload.CryptoCurrencyAccountPayload; +import bisq.core.payment.payload.AssetsAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.validation.AltCoinAddressValidator; import bisq.core.util.BSFormatter; @@ -68,7 +68,7 @@ public static int addFormForBuyer(GridPane gridPane, PaymentAccountPayload paymentAccountPayload, String labelTitle) { addCompactTopLabelTextFieldWithCopyIcon(gridPane, ++gridRow, labelTitle, - ((CryptoCurrencyAccountPayload) paymentAccountPayload).getAddress()); + ((AssetsAccountPayload) paymentAccountPayload).getAddress()); return gridRow; } diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java index bf602956c81..61d965a7084 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java @@ -31,7 +31,7 @@ import bisq.core.locale.TradeCurrency; import bisq.core.offer.Offer; import bisq.core.payment.AccountAgeWitnessService; -import bisq.core.payment.CryptoCurrencyAccount; +import bisq.core.payment.AssetAccount; import bisq.core.payment.PaymentAccount; import bisq.core.util.BSFormatter; import bisq.core.util.validation.InputValidator; @@ -166,7 +166,7 @@ else if (paymentAccount.getSelectedTradeCurrency() != null) else if (!paymentAccount.getTradeCurrencies().isEmpty()) tradeCurrency = paymentAccount.getTradeCurrencies().get(0); else - tradeCurrency = paymentAccount instanceof CryptoCurrencyAccount ? + tradeCurrency = paymentAccount instanceof AssetAccount ? CurrencyUtil.getAllSortedCryptoCurrencies().get(0) : CurrencyUtil.getDefaultTradeCurrency(); @@ -174,7 +174,7 @@ else if (!paymentAccount.getTradeCurrencies().isEmpty()) final boolean isAddAccountScreen = paymentAccount.getAccountName() == null; final long accountAge = !isAddAccountScreen ? accountAgeWitnessService.getMyAccountAge(paymentAccount.getPaymentAccountPayload()) : 0L; - final String limitationsText = paymentAccount instanceof CryptoCurrencyAccount ? + final String limitationsText = paymentAccount instanceof AssetAccount ? Res.get("payment.maxPeriodAndLimitCrypto", getTimeText(hours), formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrency.getCode())))) diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java index cd333ed391a..11fbec3a87b 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsDataModel.java @@ -25,7 +25,7 @@ import bisq.core.locale.TradeCurrency; import bisq.core.offer.OpenOfferManager; import bisq.core.payment.AccountAgeWitnessService; -import bisq.core.payment.CryptoCurrencyAccount; +import bisq.core.payment.AssetAccount; import bisq.core.payment.PaymentAccount; import bisq.core.trade.TradeManager; import bisq.core.user.Preferences; @@ -116,7 +116,7 @@ public void onSaveNewAccount(PaymentAccount paymentAccount) { }); } - if (!(paymentAccount instanceof CryptoCurrencyAccount)) + if (!(paymentAccount instanceof AssetAccount)) accountAgeWitnessService.publishMyAccountAgeWitness(paymentAccount.getPaymentAccountPayload()); } @@ -142,7 +142,7 @@ public void onSelectAccount(PaymentAccount paymentAccount) { public void exportAccounts(Stage stage) { if (user.getPaymentAccounts() != null) { ArrayList accounts = new ArrayList<>(user.getPaymentAccounts().stream() - .filter(paymentAccount -> paymentAccount instanceof CryptoCurrencyAccount) + .filter(paymentAccount -> paymentAccount instanceof AssetAccount) .collect(Collectors.toList())); GUIUtil.exportAccounts(accounts, accountsFileName, preferences, stage, persistenceProtoResolver); } diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java index af180bbeed1..a60cc95e076 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/fiataccounts/FiatAccountsDataModel.java @@ -26,7 +26,7 @@ import bisq.core.locale.TradeCurrency; import bisq.core.offer.OpenOfferManager; import bisq.core.payment.AccountAgeWitnessService; -import bisq.core.payment.CryptoCurrencyAccount; +import bisq.core.payment.AssetAccount; import bisq.core.payment.PaymentAccount; import bisq.core.trade.TradeManager; import bisq.core.user.Preferences; @@ -145,7 +145,7 @@ public void onSelectAccount(PaymentAccount paymentAccount) { public void exportAccounts(Stage stage) { if (user.getPaymentAccounts() != null) { ArrayList accounts = new ArrayList<>(user.getPaymentAccounts().stream() - .filter(paymentAccount -> !(paymentAccount instanceof CryptoCurrencyAccount)) + .filter(paymentAccount -> !(paymentAccount instanceof AssetAccount)) .collect(Collectors.toList())); GUIUtil.exportAccounts(accounts, accountsFileName, preferences, stage, persistenceProtoResolver); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 7dbc0bd9481..717fa723c11 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -56,8 +56,8 @@ import bisq.core.offer.Offer; import bisq.core.payment.PaymentAccount; import bisq.core.payment.PaymentAccountUtil; +import bisq.core.payment.payload.AssetsAccountPayload; import bisq.core.payment.payload.CashDepositAccountPayload; -import bisq.core.payment.payload.CryptoCurrencyAccountPayload; import bisq.core.payment.payload.F2FAccountPayload; import bisq.core.payment.payload.FasterPaymentsAccountPayload; import bisq.core.payment.payload.HalCashAccountPayload; @@ -206,7 +206,7 @@ protected void addContent() { Layout.COMPACT_FIRST_ROW_AND_GROUP_DISTANCE).second; field.setCopyWithoutCurrencyPostFix(true); - if (!(paymentAccountPayload instanceof CryptoCurrencyAccountPayload) && + if (!(paymentAccountPayload instanceof AssetsAccountPayload) && !(paymentAccountPayload instanceof F2FAccountPayload)) addTopLabelTextFieldWithCopyIcon(gridPane, gridRow, 1, Res.get("shared.reasonForPayment"), model.dataModel.getReference(), @@ -496,7 +496,7 @@ private void showPopup() { String id = trade.getShortId(); String paddedId = " " + id + " "; String amount = model.btcFormatter.formatVolumeWithCode(trade.getTradeVolume()); - if (paymentAccountPayload instanceof CryptoCurrencyAccountPayload) { + if (paymentAccountPayload instanceof AssetsAccountPayload) { //noinspection UnusedAssignment message += Res.get("portfolio.pending.step2_buyer.altcoin", CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()), diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java index 312f32e5238..bc1c456e697 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/seller/SellerStep3View.java @@ -27,9 +27,9 @@ import bisq.core.locale.CurrencyUtil; import bisq.core.locale.Res; +import bisq.core.payment.payload.AssetsAccountPayload; import bisq.core.payment.payload.BankAccountPayload; import bisq.core.payment.payload.CashDepositAccountPayload; -import bisq.core.payment.payload.CryptoCurrencyAccountPayload; import bisq.core.payment.payload.F2FAccountPayload; import bisq.core.payment.payload.HalCashAccountPayload; import bisq.core.payment.payload.MoneyGramAccountPayload; @@ -183,9 +183,9 @@ protected void addContent() { if (contract != null) { PaymentAccountPayload myPaymentAccountPayload = contract.getSellerPaymentAccountPayload(); PaymentAccountPayload peersPaymentAccountPayload = contract.getBuyerPaymentAccountPayload(); - if (myPaymentAccountPayload instanceof CryptoCurrencyAccountPayload) { - myPaymentDetails = ((CryptoCurrencyAccountPayload) myPaymentAccountPayload).getAddress(); - peersPaymentDetails = ((CryptoCurrencyAccountPayload) peersPaymentAccountPayload).getAddress(); + if (myPaymentAccountPayload instanceof AssetsAccountPayload) { + myPaymentDetails = ((AssetsAccountPayload) myPaymentAccountPayload).getAddress(); + peersPaymentDetails = ((AssetsAccountPayload) peersPaymentAccountPayload).getAddress(); myTitle = Res.get("portfolio.pending.step3_seller.yourAddress", nameByCode); peersTitle = Res.get("portfolio.pending.step3_seller.buyersAddress", nameByCode); isBlockChain = true; @@ -284,7 +284,7 @@ private void onPaymentReceived() { if (!DevEnv.isDevMode() && DontShowAgainLookup.showAgain(key)) { PaymentAccountPayload paymentAccountPayload = model.dataModel.getSellersPaymentAccountPayload(); String message = Res.get("portfolio.pending.step3_seller.onPaymentReceived.part1", CurrencyUtil.getNameByCode(model.dataModel.getCurrencyCode())); - if (!(paymentAccountPayload instanceof CryptoCurrencyAccountPayload)) { + if (!(paymentAccountPayload instanceof AssetsAccountPayload)) { if (!(paymentAccountPayload instanceof WesternUnionAccountPayload) && !(paymentAccountPayload instanceof HalCashAccountPayload) && !(paymentAccountPayload instanceof F2FAccountPayload)) { @@ -323,8 +323,8 @@ private void showPopup() { String currencyName = CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode()); String part1 = Res.get("portfolio.pending.step3_seller.part", currencyName); String id = trade.getShortId(); - if (paymentAccountPayload instanceof CryptoCurrencyAccountPayload) { - String address = ((CryptoCurrencyAccountPayload) paymentAccountPayload).getAddress(); + if (paymentAccountPayload instanceof AssetsAccountPayload) { + String address = ((AssetsAccountPayload) paymentAccountPayload).getAddress(); String explorerOrWalletString = trade.getOffer().getCurrencyCode().equals("XMR") ? Res.get("portfolio.pending.step3_seller.altcoin.wallet", currencyName) : Res.get("portfolio.pending.step3_seller.altcoin.explorer", currencyName); From 54e39c30670075c977e637c99d9f5a650c6e5750 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Mar 2019 02:09:52 -0500 Subject: [PATCH 3/6] Remove dev button, add "trade instant" checkbox --- .../resources/i18n/displayStrings.properties | 8 +- ...ryptoCurrencyForm.java => AssetsForm.java} | 54 +++++++++--- .../altcoinaccounts/AltCoinAccountsView.java | 88 +------------------ .../steps/buyer/BuyerStep2View.java | 4 +- 4 files changed, 56 insertions(+), 98 deletions(-) rename desktop/src/main/java/bisq/desktop/components/paymentmethods/{CryptoCurrencyForm.java => AssetsForm.java} (79%) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 5b2b0ca6281..120139fb173 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2363,6 +2363,10 @@ payment.country=Country payment.extras=Extra requirements payment.email.mobile=Email or mobile no. payment.altcoin.address=Altcoin address +payment.altcoin.tradeInstantCheckbox=Trade instant +payment.altcoin.tradeInstant.popup=For instant trading it is required that both trading peers are online to be able \ + to complete the trade in less than 1 hour. If you have offers open and you are not available please disable \ + those offers. payment.altcoin=Altcoin payment.select.altcoin=Select or search altcoin payment.secret=Secret question @@ -2562,7 +2566,7 @@ PROMPT_PAY=PromptPay # suppress inspection "UnusedProperty" ADVANCED_CASH=Advanced Cash # suppress inspection "UnusedProperty" -LIVE_ASSETS=Live assets +LIVE_ASSETS=Altcoins Instant # suppress inspection "UnusedProperty" UPHOLD_SHORT=Uphold @@ -2601,7 +2605,7 @@ PROMPT_PAY_SHORT=PromptPay # suppress inspection "UnusedProperty" ADVANCED_CASH_SHORT=Advanced Cash # suppress inspection "UnusedProperty" -LIVE_ASSETS_SHORT=Live assets +LIVE_ASSETS_SHORT=Altcoins Instant #################################################################### diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java similarity index 79% rename from desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java rename to desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java index 4270ad0a64b..d65ce5d3a36 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/CryptoCurrencyForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java @@ -18,6 +18,7 @@ package bisq.desktop.components.paymentmethods; import bisq.desktop.components.InputTextField; +import bisq.desktop.main.overlays.popups.Popup; import bisq.desktop.util.FormBuilder; import bisq.desktop.util.Layout; @@ -28,6 +29,7 @@ import bisq.core.locale.TradeCurrency; import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.AssetAccount; +import bisq.core.payment.LiveAssetsAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.AssetsAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; @@ -39,6 +41,7 @@ import org.apache.commons.lang3.StringUtils; +import javafx.scene.control.CheckBox; import javafx.scene.control.Label; import javafx.scene.control.TextField; import javafx.scene.layout.GridPane; @@ -55,13 +58,15 @@ import static bisq.desktop.util.FormBuilder.addTopLabelTextField; import static bisq.desktop.util.GUIUtil.getComboBoxButtonCell; -public class CryptoCurrencyForm extends PaymentMethodForm { +public class AssetsForm extends PaymentMethodForm { private final AssetAccount assetAccount; private final AltCoinAddressValidator altCoinAddressValidator; private final AssetService assetService; private final FilterManager filterManager; private InputTextField addressInputTextField; + private CheckBox liveAssetCheckBox; + private boolean tradeInstant; public static int addFormForBuyer(GridPane gridPane, int gridRow, @@ -72,20 +77,22 @@ public static int addFormForBuyer(GridPane gridPane, return gridRow; } - public CryptoCurrencyForm(PaymentAccount paymentAccount, - AccountAgeWitnessService accountAgeWitnessService, - AltCoinAddressValidator altCoinAddressValidator, - InputValidator inputValidator, - GridPane gridPane, - int gridRow, - BSFormatter formatter, - AssetService assetService, - FilterManager filterManager) { + public AssetsForm(PaymentAccount paymentAccount, + AccountAgeWitnessService accountAgeWitnessService, + AltCoinAddressValidator altCoinAddressValidator, + InputValidator inputValidator, + GridPane gridPane, + int gridRow, + BSFormatter formatter, + AssetService assetService, + FilterManager filterManager) { super(paymentAccount, accountAgeWitnessService, inputValidator, gridPane, gridRow, formatter); this.assetAccount = (AssetAccount) paymentAccount; this.altCoinAddressValidator = altCoinAddressValidator; this.assetService = assetService; this.filterManager = filterManager; + + tradeInstant = paymentAccount instanceof LiveAssetsAccount; } @Override @@ -94,6 +101,16 @@ public void addFormForAddAccount() { addTradeCurrencyComboBox(); currencyComboBox.setPrefWidth(250); + + liveAssetCheckBox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow, + Res.get("payment.altcoin.tradeInstantCheckbox"), 10); + liveAssetCheckBox.setSelected(tradeInstant); + liveAssetCheckBox.setOnAction(e -> { + tradeInstant = liveAssetCheckBox.isSelected(); + if (tradeInstant) + new Popup<>().information(Res.get("payment.altcoin.tradeInstant.popup")).show(); + }); + addressInputTextField = FormBuilder.addInputTextField(gridPane, ++gridRow, Res.get("payment.altcoin.address")); addressInputTextField.setValidator(altCoinAddressValidator); @@ -107,6 +124,23 @@ public void addFormForAddAccount() { addAccountNameTextFieldWithAutoFillToggleButton(); } + @Override + public PaymentAccount getPaymentAccount() { + if (tradeInstant) { + LiveAssetsAccount liveAssetsAccount = new LiveAssetsAccount(); + liveAssetsAccount.init(); + liveAssetsAccount.setAccountName(paymentAccount.getAccountName()); + liveAssetsAccount.setSaltAsHex(paymentAccount.getSaltAsHex()); + liveAssetsAccount.setSalt(paymentAccount.getSalt()); + liveAssetsAccount.setSingleTradeCurrency(paymentAccount.getSingleTradeCurrency()); + liveAssetsAccount.setSelectedTradeCurrency(paymentAccount.getSelectedTradeCurrency()); + liveAssetsAccount.setAddress(assetAccount.getAddress()); + return liveAssetsAccount; + } else { + return paymentAccount; + } + } + @Override public void updateFromInputs() { if (addressInputTextField != null && assetAccount.getSingleTradeCurrency() != null) diff --git a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java index 23db2f58aa7..0a3a2f63369 100644 --- a/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java +++ b/desktop/src/main/java/bisq/desktop/main/account/content/altcoinaccounts/AltCoinAccountsView.java @@ -18,9 +18,8 @@ package bisq.desktop.main.account.content.altcoinaccounts; import bisq.desktop.common.view.FxmlView; -import bisq.desktop.components.AutoTooltipButton; import bisq.desktop.components.TitledGroupBg; -import bisq.desktop.components.paymentmethods.CryptoCurrencyForm; +import bisq.desktop.components.paymentmethods.AssetsForm; import bisq.desktop.components.paymentmethods.PaymentMethodForm; import bisq.desktop.main.account.content.PaymentAccountsView; import bisq.desktop.main.overlays.popups.Popup; @@ -46,7 +45,6 @@ import bisq.common.util.Tuple2; import bisq.common.util.Tuple3; -import bisq.common.util.Tuple4; import javax.inject.Inject; @@ -56,17 +54,14 @@ import javafx.scene.control.Label; import javafx.scene.control.ListView; import javafx.scene.layout.GridPane; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -import javafx.geometry.Insets; - import javafx.collections.ObservableList; import java.util.Optional; import static bisq.desktop.util.FormBuilder.add2ButtonsAfterGroup; +import static bisq.desktop.util.FormBuilder.add3ButtonsAfterGroup; import static bisq.desktop.util.FormBuilder.addTitledGroupBg; import static bisq.desktop.util.FormBuilder.addTopLabelListView; @@ -84,8 +79,6 @@ public class AltCoinAccountsView extends PaymentAccountsView tuple4 = add4Buttons(root, ++gridRow, Res.get("shared.addNewAccount"), - "Add Live Assets account", Res.get("shared.ExportAccounts"), Res.get("shared.importAccounts"), 15); - addAccountButton = tuple4.first; - addLiveAssetAccountButton = tuple4.second; - exportButton = tuple4.third; - importButton = tuple4.forth; - addLiveAssetAccountButton.setOnAction(event -> addNewLiveAssetAccount()); - - /* Tuple3 tuple3 = add3ButtonsAfterGroup(root, ++gridRow, Res.get("shared.addNewAccount"), + Tuple3 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; - */ - } - - //TODO just temp for dev - private Tuple4 add4Buttons(GridPane gridPane, - int rowIndex, - String title1, - String title2, - String title3, - String title4, - double top) { - HBox hBox = new HBox(); - hBox.setSpacing(10); - Button button1 = new AutoTooltipButton(title1); - - button1.getStyleClass().add("action-button"); - button1.setDefaultButton(true); - button1.setMaxWidth(Double.MAX_VALUE); - HBox.setHgrow(button1, Priority.ALWAYS); - - Button button2 = new AutoTooltipButton(title2); - button2.setMaxWidth(Double.MAX_VALUE); - HBox.setHgrow(button2, Priority.ALWAYS); - - Button button3 = new AutoTooltipButton(title3); - button3.setMaxWidth(Double.MAX_VALUE); - HBox.setHgrow(button3, Priority.ALWAYS); - - Button button4 = new AutoTooltipButton(title4); - button4.setMaxWidth(Double.MAX_VALUE); - HBox.setHgrow(button4, Priority.ALWAYS); - - hBox.getChildren().addAll(button1, button2, button3, button4); - GridPane.setRowIndex(hBox, rowIndex); - GridPane.setColumnIndex(hBox, 0); - GridPane.setMargin(hBox, new Insets(top, 10, 0, 0)); - gridPane.getChildren().add(hBox); - return new Tuple4<>(button1, button2, button3, button4); - } - - //TODO temp for dev - private void addNewLiveAssetAccount() { - paymentAccountsListView.getSelectionModel().clearSelection(); - removeAccountRows(); - addAccountButton.setDisable(true); - accountTitledGroupBg = addTitledGroupBg(root, ++gridRow, 1, Res.get("shared.createNewAccount"), Layout.GROUP_DISTANCE); - - if (paymentMethodForm != null) { - FormBuilder.removeRowsFromGridPane(root, 3, paymentMethodForm.getGridRow() + 1); - GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); - } - gridRow = 2; - // We don't separate here between normal altcoin and live assets - paymentMethodForm = getPaymentMethodForm(PaymentMethod.LIVE_ASSETS); - - paymentMethodForm.addFormForAddAccount(); - gridRow = paymentMethodForm.getGridRow(); - Tuple2 tuple2 = add2ButtonsAfterGroup(root, ++gridRow, Res.get("shared.saveNewAccount"), Res.get("shared.cancel")); - saveNewAccountButton = tuple2.first; - saveNewAccountButton.setOnAction(event -> onSaveNewAccount(paymentMethodForm.getPaymentAccount())); - saveNewAccountButton.disableProperty().bind(paymentMethodForm.allInputsValidProperty().not()); - Button cancelButton = tuple2.second; - cancelButton.setOnAction(event -> onCancelNewAccount()); - GridPane.setRowSpan(accountTitledGroupBg, paymentMethodForm.getRowSpan() + 1); } // Add new account form @@ -307,7 +227,7 @@ private PaymentMethodForm getPaymentMethodForm(PaymentMethod paymentMethod) { } private PaymentMethodForm getPaymentMethodForm(PaymentAccount paymentAccount) { - return new CryptoCurrencyForm(paymentAccount, accountAgeWitnessService, altCoinAddressValidator, + return new AssetsForm(paymentAccount, accountAgeWitnessService, altCoinAddressValidator, inputValidator, root, gridRow, formatter, assetService, filterManager); } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index 717fa723c11..fc2ed691c5c 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -22,10 +22,10 @@ import bisq.desktop.components.TitledGroupBg; import bisq.desktop.components.paymentmethods.AdvancedCashForm; import bisq.desktop.components.paymentmethods.AliPayForm; +import bisq.desktop.components.paymentmethods.AssetsForm; import bisq.desktop.components.paymentmethods.CashDepositForm; import bisq.desktop.components.paymentmethods.ChaseQuickPayForm; import bisq.desktop.components.paymentmethods.ClearXchangeForm; -import bisq.desktop.components.paymentmethods.CryptoCurrencyForm; import bisq.desktop.components.paymentmethods.F2FForm; import bisq.desktop.components.paymentmethods.FasterPaymentsForm; import bisq.desktop.components.paymentmethods.HalCashForm; @@ -284,7 +284,7 @@ protected void addContent() { case PaymentMethod.LIVE_ASSETS_ID: String labelTitle = Res.get("portfolio.pending.step2_buyer.sellersAddress", CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode())); - gridRow = CryptoCurrencyForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, labelTitle); + gridRow = AssetsForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, labelTitle); break; case PaymentMethod.PROMPT_PAY_ID: gridRow = PromptPayForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload); From 992480d3a7062e8764cdf12b0a522010393ae790 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Mar 2019 02:28:37 -0500 Subject: [PATCH 4/6] Refactoring: Renaming --- common/src/main/proto/pb.proto | 4 +-- ...java => InstantCryptoCurrencyAccount.java} | 10 +++--- .../core/payment/PaymentAccountFactory.java | 4 +-- ...java => InstantCryptoCurrencyPayload.java} | 22 ++++++------- .../core/payment/payload/PaymentMethod.java | 8 ++--- .../bisq/core/proto/CoreProtoResolver.java | 6 ++-- .../resources/i18n/displayStrings.properties | 4 +-- .../components/paymentmethods/AssetsForm.java | 32 +++++++++---------- .../steps/buyer/BuyerStep2View.java | 2 +- 9 files changed, 46 insertions(+), 46 deletions(-) rename core/src/main/java/bisq/core/payment/{LiveAssetsAccount.java => InstantCryptoCurrencyAccount.java} (76%) rename core/src/main/java/bisq/core/payment/payload/{LiveAssetsAccountPayload.java => InstantCryptoCurrencyPayload.java} (69%) diff --git a/common/src/main/proto/pb.proto b/common/src/main/proto/pb.proto index 602b3628a3c..7ba510f4807 100644 --- a/common/src/main/proto/pb.proto +++ b/common/src/main/proto/pb.proto @@ -725,7 +725,7 @@ message PaymentAccountPayload { HalCashAccountPayload hal_cash_account_payload = 24; PromptPayAccountPayload prompt_pay_account_payload = 25; AdvancedCashAccountPayload advanced_cash_account_payload = 26; - LiveAssetsAccountPayload live_assets_account_payload = 27; + InstantCryptoCurrencyAccountPayload instant_crypto_currency_account_payload = 27; } map exclude_from_json_data = 15; } @@ -837,7 +837,7 @@ message CryptoCurrencyAccountPayload { string address = 1; } -message LiveAssetsAccountPayload { +message InstantCryptoCurrencyAccountPayload { string address = 1; } diff --git a/core/src/main/java/bisq/core/payment/LiveAssetsAccount.java b/core/src/main/java/bisq/core/payment/InstantCryptoCurrencyAccount.java similarity index 76% rename from core/src/main/java/bisq/core/payment/LiveAssetsAccount.java rename to core/src/main/java/bisq/core/payment/InstantCryptoCurrencyAccount.java index 9375220e836..17ddf5eca77 100644 --- a/core/src/main/java/bisq/core/payment/LiveAssetsAccount.java +++ b/core/src/main/java/bisq/core/payment/InstantCryptoCurrencyAccount.java @@ -17,21 +17,21 @@ package bisq.core.payment; -import bisq.core.payment.payload.LiveAssetsAccountPayload; +import bisq.core.payment.payload.InstantCryptoCurrencyPayload; import bisq.core.payment.payload.PaymentAccountPayload; import bisq.core.payment.payload.PaymentMethod; import lombok.EqualsAndHashCode; @EqualsAndHashCode(callSuper = true) -public final class LiveAssetsAccount extends AssetAccount { +public final class InstantCryptoCurrencyAccount extends AssetAccount { - public LiveAssetsAccount() { - super(PaymentMethod.LIVE_ASSETS); + public InstantCryptoCurrencyAccount() { + super(PaymentMethod.BLOCK_CHAINS_INSTANT); } @Override protected PaymentAccountPayload createPayload() { - return new LiveAssetsAccountPayload(paymentMethod.getId(), id); + return new InstantCryptoCurrencyPayload(paymentMethod.getId(), id); } } diff --git a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java index d452e95da3f..ed9462e25dc 100644 --- a/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java +++ b/core/src/main/java/bisq/core/payment/PaymentAccountFactory.java @@ -74,8 +74,8 @@ public static PaymentAccount getPaymentAccount(PaymentMethod paymentMethod) { return new PromptPayAccount(); case PaymentMethod.ADVANCED_CASH_ID: return new AdvancedCashAccount(); - case PaymentMethod.LIVE_ASSETS_ID: - return new LiveAssetsAccount(); + case PaymentMethod.BLOCK_CHAINS_INSTANT_ID: + return new InstantCryptoCurrencyAccount(); default: throw new RuntimeException("Not supported PaymentMethod: " + paymentMethod); } diff --git a/core/src/main/java/bisq/core/payment/payload/LiveAssetsAccountPayload.java b/core/src/main/java/bisq/core/payment/payload/InstantCryptoCurrencyPayload.java similarity index 69% rename from core/src/main/java/bisq/core/payment/payload/LiveAssetsAccountPayload.java rename to core/src/main/java/bisq/core/payment/payload/InstantCryptoCurrencyPayload.java index 9b4f7517c47..bc112d213d2 100644 --- a/core/src/main/java/bisq/core/payment/payload/LiveAssetsAccountPayload.java +++ b/core/src/main/java/bisq/core/payment/payload/InstantCryptoCurrencyPayload.java @@ -39,9 +39,9 @@ @Setter @Getter @Slf4j -public final class LiveAssetsAccountPayload extends AssetsAccountPayload { +public final class InstantCryptoCurrencyPayload extends AssetsAccountPayload { - public LiveAssetsAccountPayload(String paymentMethod, String id) { + public InstantCryptoCurrencyPayload(String paymentMethod, String id) { super(paymentMethod, id); } @@ -50,11 +50,11 @@ public LiveAssetsAccountPayload(String paymentMethod, String id) { // PROTO BUFFER /////////////////////////////////////////////////////////////////////////////////////////// - private LiveAssetsAccountPayload(String paymentMethod, - String id, - String address, - long maxTradePeriod, - @Nullable Map excludeFromJsonDataMap) { + private InstantCryptoCurrencyPayload(String paymentMethod, + String id, + String address, + long maxTradePeriod, + @Nullable Map excludeFromJsonDataMap) { super(paymentMethod, id, address, @@ -65,15 +65,15 @@ private LiveAssetsAccountPayload(String paymentMethod, @Override public Message toProtoMessage() { return getPaymentAccountPayloadBuilder() - .setLiveAssetsAccountPayload(PB.LiveAssetsAccountPayload.newBuilder() + .setInstantCryptoCurrencyAccountPayload(PB.InstantCryptoCurrencyAccountPayload.newBuilder() .setAddress(address)) .build(); } - public static LiveAssetsAccountPayload fromProto(PB.PaymentAccountPayload proto) { - return new LiveAssetsAccountPayload(proto.getPaymentMethodId(), + public static InstantCryptoCurrencyPayload fromProto(PB.PaymentAccountPayload proto) { + return new InstantCryptoCurrencyPayload(proto.getPaymentMethodId(), proto.getId(), - proto.getLiveAssetsAccountPayload().getAddress(), + proto.getInstantCryptoCurrencyAccountPayload().getAddress(), proto.getMaxTradePeriod(), CollectionUtils.isEmpty(proto.getExcludeFromJsonDataMap()) ? null : new HashMap<>(proto.getExcludeFromJsonDataMap())); } diff --git a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java index e307311ef7d..6bfc2f5e69c 100644 --- a/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java +++ b/core/src/main/java/bisq/core/payment/payload/PaymentMethod.java @@ -89,7 +89,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable { public static final String BLOCK_CHAINS_ID = "BLOCK_CHAINS"; public static final String PROMPT_PAY_ID = "PROMPT_PAY"; public static final String ADVANCED_CASH_ID = "ADVANCED_CASH"; - public static final String LIVE_ASSETS_ID = "LIVE_ASSETS"; + public static final String BLOCK_CHAINS_INSTANT_ID = "BLOCK_CHAINS_INSTANT"; public static PaymentMethod UPHOLD; public static PaymentMethod MONEY_BEAM; @@ -117,7 +117,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable { public static PaymentMethod BLOCK_CHAINS; public static PaymentMethod PROMPT_PAY; public static PaymentMethod ADVANCED_CASH; - public static PaymentMethod LIVE_ASSETS; + public static PaymentMethod BLOCK_CHAINS_INSTANT; // The limit and duration assignment must not be changed as that could break old offers (if amount would be higher // than new trade limit) and violate the maker expectation when he created the offer (duration). @@ -170,7 +170,7 @@ public final class PaymentMethod implements PersistablePayload, Comparable { // Altcoins BLOCK_CHAINS = new PaymentMethod(BLOCK_CHAINS_ID, DAY, DEFAULT_TRADE_LIMIT_VERY_LOW_RISK), // Altcoins with 1 hour trade period - LIVE_ASSETS = new PaymentMethod(LIVE_ASSETS_ID, TimeUnit.HOURS.toMillis(1), DEFAULT_TRADE_LIMIT_VERY_LOW_RISK) + BLOCK_CHAINS_INSTANT = new PaymentMethod(BLOCK_CHAINS_INSTANT_ID, TimeUnit.HOURS.toMillis(1), DEFAULT_TRADE_LIMIT_VERY_LOW_RISK) )); static { @@ -298,6 +298,6 @@ public int compareTo(@NotNull Object other) { } public boolean isAsset() { - return this.equals(LIVE_ASSETS) || this.equals(BLOCK_CHAINS); + return this.equals(BLOCK_CHAINS_INSTANT) || this.equals(BLOCK_CHAINS); } } diff --git a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java index 4ab9737795d..69262e6b5c5 100644 --- a/core/src/main/java/bisq/core/proto/CoreProtoResolver.java +++ b/core/src/main/java/bisq/core/proto/CoreProtoResolver.java @@ -29,8 +29,8 @@ import bisq.core.payment.payload.F2FAccountPayload; import bisq.core.payment.payload.FasterPaymentsAccountPayload; import bisq.core.payment.payload.HalCashAccountPayload; +import bisq.core.payment.payload.InstantCryptoCurrencyPayload; import bisq.core.payment.payload.InteracETransferAccountPayload; -import bisq.core.payment.payload.LiveAssetsAccountPayload; import bisq.core.payment.payload.MoneyBeamAccountPayload; import bisq.core.payment.payload.MoneyGramAccountPayload; import bisq.core.payment.payload.NationalBankAccountPayload; @@ -133,8 +133,8 @@ public PaymentAccountPayload fromProto(PB.PaymentAccountPayload proto) { return PromptPayAccountPayload.fromProto(proto); case ADVANCED_CASH_ACCOUNT_PAYLOAD: return AdvancedCashAccountPayload.fromProto(proto); - case LIVE_ASSETS_ACCOUNT_PAYLOAD: - return LiveAssetsAccountPayload.fromProto(proto); + case INSTANT_CRYPTO_CURRENCY_ACCOUNT_PAYLOAD: + return InstantCryptoCurrencyPayload.fromProto(proto); default: throw new ProtobufferRuntimeException("Unknown proto message case(PB.PaymentAccountPayload). messageCase=" + messageCase); } diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 120139fb173..93e3dee35e5 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2566,7 +2566,7 @@ PROMPT_PAY=PromptPay # suppress inspection "UnusedProperty" ADVANCED_CASH=Advanced Cash # suppress inspection "UnusedProperty" -LIVE_ASSETS=Altcoins Instant +BLOCK_CHAINS_INSTANT=Altcoins Instant # suppress inspection "UnusedProperty" UPHOLD_SHORT=Uphold @@ -2605,7 +2605,7 @@ PROMPT_PAY_SHORT=PromptPay # suppress inspection "UnusedProperty" ADVANCED_CASH_SHORT=Advanced Cash # suppress inspection "UnusedProperty" -LIVE_ASSETS_SHORT=Altcoins Instant +BLOCK_CHAINS_INSTANT_SHORT=Altcoins Instant #################################################################### diff --git a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java index d65ce5d3a36..140ff98c2d4 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/AssetsForm.java @@ -29,7 +29,7 @@ import bisq.core.locale.TradeCurrency; import bisq.core.payment.AccountAgeWitnessService; import bisq.core.payment.AssetAccount; -import bisq.core.payment.LiveAssetsAccount; +import bisq.core.payment.InstantCryptoCurrencyAccount; import bisq.core.payment.PaymentAccount; import bisq.core.payment.payload.AssetsAccountPayload; import bisq.core.payment.payload.PaymentAccountPayload; @@ -65,7 +65,7 @@ public class AssetsForm extends PaymentMethodForm { private final FilterManager filterManager; private InputTextField addressInputTextField; - private CheckBox liveAssetCheckBox; + private CheckBox tradeInstantCheckBox; private boolean tradeInstant; public static int addFormForBuyer(GridPane gridPane, @@ -92,7 +92,7 @@ public AssetsForm(PaymentAccount paymentAccount, this.assetService = assetService; this.filterManager = filterManager; - tradeInstant = paymentAccount instanceof LiveAssetsAccount; + tradeInstant = paymentAccount instanceof InstantCryptoCurrencyAccount; } @Override @@ -102,11 +102,11 @@ public void addFormForAddAccount() { addTradeCurrencyComboBox(); currencyComboBox.setPrefWidth(250); - liveAssetCheckBox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow, + tradeInstantCheckBox = FormBuilder.addLabelCheckBox(gridPane, ++gridRow, Res.get("payment.altcoin.tradeInstantCheckbox"), 10); - liveAssetCheckBox.setSelected(tradeInstant); - liveAssetCheckBox.setOnAction(e -> { - tradeInstant = liveAssetCheckBox.isSelected(); + tradeInstantCheckBox.setSelected(tradeInstant); + tradeInstantCheckBox.setOnAction(e -> { + tradeInstant = tradeInstantCheckBox.isSelected(); if (tradeInstant) new Popup<>().information(Res.get("payment.altcoin.tradeInstant.popup")).show(); }); @@ -127,15 +127,15 @@ public void addFormForAddAccount() { @Override public PaymentAccount getPaymentAccount() { if (tradeInstant) { - LiveAssetsAccount liveAssetsAccount = new LiveAssetsAccount(); - liveAssetsAccount.init(); - liveAssetsAccount.setAccountName(paymentAccount.getAccountName()); - liveAssetsAccount.setSaltAsHex(paymentAccount.getSaltAsHex()); - liveAssetsAccount.setSalt(paymentAccount.getSalt()); - liveAssetsAccount.setSingleTradeCurrency(paymentAccount.getSingleTradeCurrency()); - liveAssetsAccount.setSelectedTradeCurrency(paymentAccount.getSelectedTradeCurrency()); - liveAssetsAccount.setAddress(assetAccount.getAddress()); - return liveAssetsAccount; + InstantCryptoCurrencyAccount instantCryptoCurrencyAccount = new InstantCryptoCurrencyAccount(); + instantCryptoCurrencyAccount.init(); + instantCryptoCurrencyAccount.setAccountName(paymentAccount.getAccountName()); + instantCryptoCurrencyAccount.setSaltAsHex(paymentAccount.getSaltAsHex()); + instantCryptoCurrencyAccount.setSalt(paymentAccount.getSalt()); + instantCryptoCurrencyAccount.setSingleTradeCurrency(paymentAccount.getSingleTradeCurrency()); + instantCryptoCurrencyAccount.setSelectedTradeCurrency(paymentAccount.getSelectedTradeCurrency()); + instantCryptoCurrencyAccount.setAddress(assetAccount.getAddress()); + return instantCryptoCurrencyAccount; } else { return paymentAccount; } diff --git a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java index fc2ed691c5c..01c7f17d9a0 100644 --- a/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java +++ b/desktop/src/main/java/bisq/desktop/main/portfolio/pendingtrades/steps/buyer/BuyerStep2View.java @@ -281,7 +281,7 @@ protected void addContent() { gridRow = F2FForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, model.dataModel.getTrade().getOffer(), 0); break; case PaymentMethod.BLOCK_CHAINS_ID: - case PaymentMethod.LIVE_ASSETS_ID: + case PaymentMethod.BLOCK_CHAINS_INSTANT_ID: String labelTitle = Res.get("portfolio.pending.step2_buyer.sellersAddress", CurrencyUtil.getNameByCode(trade.getOffer().getCurrencyCode())); gridRow = AssetsForm.addFormForBuyer(gridPane, gridRow, paymentAccountPayload, labelTitle); From 997819eab4c96f577bb222e1ed3ef5d0c9b132d3 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Sun, 3 Mar 2019 20:01:10 -0500 Subject: [PATCH 5/6] Add line break --- core/src/main/resources/i18n/displayStrings.properties | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index c25a9861286..41dd1d168ff 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2365,8 +2365,9 @@ payment.email.mobile=Email or mobile no. payment.altcoin.address=Altcoin address payment.altcoin.tradeInstantCheckbox=Trade instant payment.altcoin.tradeInstant.popup=For instant trading it is required that both trading peers are online to be able \ - to complete the trade in less than 1 hour. If you have offers open and you are not available please disable \ - those offers. + to complete the trade in less than 1 hour.\n\n\ + If you have offers open and you are not available please disable \ + those offers under the 'Portfolio' screen. payment.altcoin=Altcoin payment.select.altcoin=Select or search altcoin payment.secret=Secret question From 804f8e9abf57ed01a839a22aa1e59e00efe08eb4 Mon Sep 17 00:00:00 2001 From: Manfred Karrer Date: Mon, 4 Mar 2019 11:10:26 -0500 Subject: [PATCH 6/6] Improve wording --- core/src/main/resources/i18n/displayStrings.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 2c5742b075b..7751f86a7de 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2381,7 +2381,7 @@ payment.country=Country payment.extras=Extra requirements payment.email.mobile=Email or mobile no. payment.altcoin.address=Altcoin address -payment.altcoin.tradeInstantCheckbox=Trade instant +payment.altcoin.tradeInstantCheckbox=Trade instant (within 1 hour) with this Altcoin payment.altcoin.tradeInstant.popup=For instant trading it is required that both trading peers are online to be able \ to complete the trade in less than 1 hour.\n\n\ If you have offers open and you are not available please disable \