diff --git a/core/src/main/java/bisq/core/account/age/AccountCreationAgeService.java b/core/src/main/java/bisq/core/account/age/AccountCreationAgeService.java index ce278fb2954..e4b2695bfdf 100644 --- a/core/src/main/java/bisq/core/account/age/AccountCreationAgeService.java +++ b/core/src/main/java/bisq/core/account/age/AccountCreationAgeService.java @@ -67,7 +67,7 @@ public AccountCreationAgeService(AccountAgeWitnessService accountAgeWitnessServi public Coin getMyAccountMinDepositAsCoin(PaymentAccount myPaymentAccount) { long myAccountAge = accountAgeWitnessService.getMyAccountAge(myPaymentAccount.getPaymentAccountPayload()); - long phaseOnePeriod = getPhaseOnePeriod(myPaymentAccount.getPaymentMethod()); + long phaseOnePeriod = getPhaseOnePeriodAsMilli(); // Restrictions.getMinBuyerSecurityDepositAsCoin() is 0.001 BTC / 5 USD return Coin.valueOf(getMyAccountMinDepositAsCoin(myAccountAge, phaseOnePeriod, Restrictions.getMinBuyerSecurityDepositAsCoin().value)); } @@ -84,7 +84,7 @@ public Coin getMinDepositAsCoin(Offer offer) { long buyersAccountAge = accountAgeWitnessService.getMakersAccountAge(offer); - long phaseOnePeriod = getPhaseOnePeriod(offer.getPaymentMethod()); + long phaseOnePeriod = getPhaseOnePeriodAsMilli(); // Restrictions.getMinBuyerSecurityDepositAsCoin() is 0.001 BTC / 5 USD return Coin.valueOf(getMyAccountMinDepositAsCoin(buyersAccountAge, phaseOnePeriod, minBuyerSecurityDepositAsCoin.value)); } @@ -106,7 +106,7 @@ public Coin getMinDepositAsCoin(Trade trade) { } long buyersAccountAge = accountAgeWitnessService.getAccountAge(contract.getBuyerPaymentAccountPayload(), contract.getBuyerPubKeyRing()); - long phaseOnePeriod = getPhaseOnePeriod(offer.getPaymentMethod()); + long phaseOnePeriod = getPhaseOnePeriodAsMilli(); // Restrictions.getMinBuyerSecurityDepositAsCoin() is 0.001 BTC / 5 USD return Coin.valueOf(getMyAccountMinDepositAsCoin(buyersAccountAge, phaseOnePeriod, minBuyerSecurityDepositAsCoin.value)); } @@ -129,7 +129,7 @@ public static long getMyAccountMinDepositAsCoin(long accountAge, long phaseOnePe public double getMyAccountMinDepositAsPercent(PaymentAccount myPaymentAccount) { long myAccountAge = accountAgeWitnessService.getMyAccountAge(myPaymentAccount.getPaymentAccountPayload()); - long phaseOnePeriod = getPhaseOnePeriod(myPaymentAccount.getPaymentMethod()); + long phaseOnePeriod = getPhaseOnePeriodAsMilli(); // Restrictions.getMinBuyerSecurityDepositAsPercent() is 5% of trade amount. return getMyAccountMinDepositAsPercent(myAccountAge, phaseOnePeriod, Restrictions.getMinBuyerSecurityDepositAsPercent(myPaymentAccount)); } @@ -146,7 +146,7 @@ public double getMinDepositAsPercent(Offer offer) { } long buyersAccountAge = accountAgeWitnessService.getMakersAccountAge(offer); - long phaseOnePeriod = getPhaseOnePeriod(offer.getPaymentMethod()); + long phaseOnePeriod = getPhaseOnePeriodAsMilli(); return getMyAccountMinDepositAsPercent(buyersAccountAge, phaseOnePeriod, 0.1); } @@ -168,7 +168,7 @@ public double getMinDepositAsPercent(Trade trade) { } long buyersAccountAge = accountAgeWitnessService.getAccountAge(contract.getBuyerPaymentAccountPayload(), contract.getBuyerPubKeyRing()); - long phaseOnePeriod = getPhaseOnePeriod(offer.getPaymentMethod()); + long phaseOnePeriod = getPhaseOnePeriodAsMilli(); return getMyAccountMinDepositAsPercent(buyersAccountAge, phaseOnePeriod, 0.1); } @@ -225,7 +225,7 @@ public long getDelay(Trade trade) { } long buyersAccountAge = accountAgeWitnessService.getAccountAge(contract.getBuyerPaymentAccountPayload(), contract.getBuyerPubKeyRing()); - long requiredAccountAge = getPhaseOnePeriod(offer.getPaymentMethod()); + long requiredAccountAge = getPhaseOnePeriodAsMilli(); return getDelayInDays(buyersAccountAge, requiredAccountAge) * DateUtils.MILLIS_PER_DAY; } @@ -243,7 +243,7 @@ public long getDelayForOffer(Offer offer) { } long buyersAccountAge = accountAgeWitnessService.getMakersAccountAge(offer); - long requiredAccountAge = getPhaseOnePeriod(offer.getPaymentMethod()); + long requiredAccountAge = getPhaseOnePeriodAsMilli(); return getDelayInDays(buyersAccountAge, requiredAccountAge) * DateUtils.MILLIS_PER_DAY; } @@ -264,7 +264,7 @@ public long getDelayForMyOffer(PaymentAccount myPaymentAccount, String currencyC } long myAccountAge = accountAgeWitnessService.getMyAccountAge(myPaymentAccount.getPaymentAccountPayload()); - long requiredAccountAge = getPhaseOnePeriod(myPaymentAccount.getPaymentMethod()); + long requiredAccountAge = getPhaseOnePeriodAsMilli(); return getDelayInDays(myAccountAge, requiredAccountAge) * DateUtils.MILLIS_PER_DAY; } @@ -280,7 +280,7 @@ public long getDelayForMyPaymentAccount(PaymentAccount myPaymentAccount, String } long myAccountAge = accountAgeWitnessService.getMyAccountAge(myPaymentAccount.getPaymentAccountPayload()); - long requiredAccountAge = getPhaseOnePeriod(myPaymentAccount.getPaymentMethod()); + long requiredAccountAge = getPhaseOnePeriodAsMilli(); return getDelayInDays(myAccountAge, requiredAccountAge) * DateUtils.MILLIS_PER_DAY; } @@ -294,36 +294,6 @@ public Date getDelayedTradePayoutDate(Trade trade) { return new Date(delay + now); } - /** - * @param paymentMethod The paymentMethod which determines the max. period - * @return The period ofr phase one in ms (day units) - */ - public long getPhaseOnePeriod(PaymentMethod paymentMethod) { - switch (paymentMethod.getId()) { - case PaymentMethod.BLOCK_CHAINS_ID: - case PaymentMethod.BLOCK_CHAINS_INSTANT_ID: - - case PaymentMethod.US_POSTAL_MONEY_ORDER_ID: - case PaymentMethod.HAL_CASH_ID: - case PaymentMethod.F2F_ID: - case PaymentMethod.MONEY_GRAM_ID: - case PaymentMethod.WESTERN_UNION_ID: - - case PaymentMethod.SWISH_ID: - case PaymentMethod.PERFECT_MONEY_ID: - case PaymentMethod.ALI_PAY_ID: - case PaymentMethod.WECHAT_PAY_ID: - case PaymentMethod.ADVANCED_CASH_ID: - case PaymentMethod.PROMPT_PAY_ID: - case PaymentMethod.CASH_DEPOSIT_ID: - return 0; - - default: - // All other bank transfer methods - return getPhaseOnePeriodAsMilli(); - } - } - /////////////////////////////////////////////////////////////////////////////////////////// // Is in phase one period @@ -378,7 +348,7 @@ public boolean tradeInPhaseOnePeriod(Trade trade) { } long buyersAccountAge = accountAgeWitnessService.getAccountAge(contract.getBuyerPaymentAccountPayload(), contract.getBuyerPubKeyRing()); - long requiredAccountAge = getPhaseOnePeriod(offer.getPaymentMethod()); + long requiredAccountAge = getPhaseOnePeriodAsMilli(); return buyersAccountAge < requiredAccountAge; } @@ -448,7 +418,7 @@ private boolean accountInPhaseOnePeriod(PaymentMethod paymentMethod, return false; } - long requiredAccountAge = getPhaseOnePeriod(paymentMethod); + long requiredAccountAge = getPhaseOnePeriodAsMilli(); return accountAge < requiredAccountAge; } diff --git a/core/src/main/java/bisq/core/account/score/AccountScoreService.java b/core/src/main/java/bisq/core/account/score/AccountScoreService.java index bb6edb5ed17..a3e6921e6da 100644 --- a/core/src/main/java/bisq/core/account/score/AccountScoreService.java +++ b/core/src/main/java/bisq/core/account/score/AccountScoreService.java @@ -73,14 +73,43 @@ public AccountScoreService(AccountCreationAgeService accountCreationAgeService, // API /////////////////////////////////////////////////////////////////////////////////////////// - public long getPhaseOnePeriod(PaymentMethod paymentMethod) { - return accountCreationAgeService.getPhaseOnePeriod(paymentMethod); + public long getPhaseOnePeriodAsMilli() { + return accountCreationAgeService.getPhaseOnePeriodAsMilli(); } public boolean ignoreRestrictions(Coin tradeAmount) { return tradeAmount.value <= LOW_AMOUNT_THRESHOLD; } + public boolean ignoreRestrictions(Offer offer) { + return ignoreRestrictions(offer.getPaymentMethod()) || ignoreRestrictions(offer.getAmount()); + } + + public boolean ignoreRestrictions(PaymentMethod paymentMethod) { + switch (paymentMethod.getId()) { + case PaymentMethod.BLOCK_CHAINS_ID: + case PaymentMethod.BLOCK_CHAINS_INSTANT_ID: + + case PaymentMethod.US_POSTAL_MONEY_ORDER_ID: + case PaymentMethod.HAL_CASH_ID: + case PaymentMethod.F2F_ID: + case PaymentMethod.MONEY_GRAM_ID: + case PaymentMethod.WESTERN_UNION_ID: + + case PaymentMethod.SWISH_ID: + case PaymentMethod.PERFECT_MONEY_ID: + case PaymentMethod.ALI_PAY_ID: + case PaymentMethod.WECHAT_PAY_ID: + case PaymentMethod.ADVANCED_CASH_ID: + case PaymentMethod.PROMPT_PAY_ID: + case PaymentMethod.CASH_DEPOSIT_ID: + return true; + + default: + // All other bank transfer methods + return false; + } + } /////////////////////////////////////////////////////////////////////////////////////////// // Is in phase one period @@ -498,8 +527,4 @@ private AccountScoreCategory getAccountScoreCategory(long accountAge, boolean is return AccountScoreCategory.BRONZE; } } - - private long getPhaseOnePeriodAsMilli() { - return accountCreationAgeService.getPhaseOnePeriodAsMilli(); - } } diff --git a/core/src/main/resources/i18n/displayStrings.properties b/core/src/main/resources/i18n/displayStrings.properties index 1824050f5d9..258d168c8a6 100644 --- a/core/src/main/resources/i18n/displayStrings.properties +++ b/core/src/main/resources/i18n/displayStrings.properties @@ -2614,7 +2614,7 @@ payment.revolut.phoneNr=Registered phone no. payment.promptPay.promptPayId=Citizen ID/Tax ID or phone no. payment.supportedCurrencies=Supported currencies payment.limitations=Limitations -payment.accountAgeTitle=Account age +payment.accountAgeTitle=Account level payment.salt=Salt for account age verification payment.error.noHexSalt=The salt need to be in HEX format.\n\ It is only recommended to edit the salt field if you want to transfer the salt from an old account to keep your account age. \ @@ -2634,7 +2634,7 @@ payment.accountNr=Account number payment.emailOrMobile=Email or mobile nr payment.useCustomAccountName=Use custom account name payment.maxPeriod=Max. allowed trade period -payment.accountAge=Account age: {0} / Buyer''s min. account age: {1} +payment.accountAge=Account age: {0} / {1} payment.maxPeriodAndTradeLimits=Max. trade duration: {0} / Max. trade limit: {1} payment.currencyWithSymbol=Currency: {0} payment.nameOfAcceptedBank=Name of accepted bank diff --git a/desktop/src/main/java/bisq/desktop/components/PeerInfoIcon.java b/desktop/src/main/java/bisq/desktop/components/PeerInfoIcon.java index ef221bc42dc..d13a7f6d2e6 100644 --- a/desktop/src/main/java/bisq/desktop/components/PeerInfoIcon.java +++ b/desktop/src/main/java/bisq/desktop/components/PeerInfoIcon.java @@ -284,11 +284,15 @@ private PeerInfoIcon(NodeAddress nodeAddress, categoryIcon = new Label(); categoryIcon.setLayoutX(-20); categoryIcon.setLayoutY(5); + categoryIcon.setVisible(false); + categoryIcon.setManaged(false); delayIcon = new Label(); + AwesomeDude.setIcon(delayIcon, AwesomeIcon.TIME); delayIcon.setLayoutX(-40); delayIcon.setLayoutY(5); - AwesomeDude.setIcon(delayIcon, AwesomeIcon.TIME); + delayIcon.setVisible(false); + delayIcon.setManaged(false); delayLabel = new Label(); delayLabel.setLayoutX(-53); @@ -296,11 +300,15 @@ private PeerInfoIcon(NodeAddress nodeAddress, delayLabel.setMinWidth(40); delayLabel.setMaxWidth(40); delayLabel.getStyleClass().add("delay-label"); + delayLabel.setVisible(false); + delayLabel.setManaged(false); signIcon = new Label(); + AwesomeDude.setIcon(signIcon, AwesomeIcon.SHIELD); signIcon.setLayoutX(-60); signIcon.setLayoutY(5); - AwesomeDude.setIcon(signIcon, AwesomeIcon.SHIELD); + signIcon.setVisible(false); + signIcon.setManaged(false); getChildren().addAll(outerBackground, innerBackground, avatarImageView, tagPane, numTradesPane, categoryIcon, delayIcon, delayLabel, signIcon); @@ -376,46 +384,49 @@ protected void updatePeerInfoIcon() { numTradesPane.setVisible(numTrades > 0); tagPane.setVisible(!tag.isEmpty()); - Optional optionalScoreInfo; - if (trade == null) { - optionalScoreInfo = accountScoreService.getScoreInfoForMaker(offer); - } else { - optionalScoreInfo = accountScoreService.getScoreInfoForBuyer(trade); - } - boolean isScoreInfoPresent = optionalScoreInfo.isPresent(); - categoryIcon.setVisible(isScoreInfoPresent); - categoryIcon.setManaged(isScoreInfoPresent); - delayIcon.setVisible(isScoreInfoPresent); - delayIcon.setManaged(isScoreInfoPresent); - signIcon.setVisible(isScoreInfoPresent); - signIcon.setManaged(isScoreInfoPresent); - - if (isScoreInfoPresent) { - //TODO just dummy impl. - ScoreInfo scoreInfo = optionalScoreInfo.get(); - boolean canSign = scoreInfo.isCanSign(); - signIcon.setVisible(canSign); - signIcon.setManaged(canSign); - - long requiredDelay = scoreInfo.getRequiredDelay(); - String age = Utilities.toTruncatedString(formatter.formatAccountAge(requiredDelay), 8); - delayLabel.setText(age); - - boolean requireDelay = requiredDelay > 0; - delayIcon.setVisible(requireDelay); - delayIcon.setManaged(requireDelay); - delayLabel.setVisible(requireDelay); - delayLabel.setManaged(requireDelay); - - if (scoreInfo.getAccountScoreCategory() == AccountScoreCategory.GOLD) { - categoryIcon.getStyleClass().addAll("score-gold"); - AwesomeDude.setIcon(categoryIcon, AwesomeIcon.STAR); - } else if (scoreInfo.getAccountScoreCategory() == AccountScoreCategory.SILVER) { - categoryIcon.getStyleClass().addAll("score-silver"); - AwesomeDude.setIcon(categoryIcon, AwesomeIcon.STAR_HALF_EMPTY); - } else if (scoreInfo.getAccountScoreCategory() == AccountScoreCategory.BRONZE) { - categoryIcon.getStyleClass().addAll("score-bronze"); - AwesomeDude.setIcon(categoryIcon, AwesomeIcon.STAR_EMPTY); + + if (!accountScoreService.ignoreRestrictions(offer)) { + Optional optionalScoreInfo; + if (trade == null) { + optionalScoreInfo = accountScoreService.getScoreInfoForMaker(offer); + } else { + optionalScoreInfo = accountScoreService.getScoreInfoForBuyer(trade); + } + boolean isScoreInfoPresent = optionalScoreInfo.isPresent(); + categoryIcon.setVisible(isScoreInfoPresent); + categoryIcon.setManaged(isScoreInfoPresent); + delayIcon.setVisible(isScoreInfoPresent); + delayIcon.setManaged(isScoreInfoPresent); + signIcon.setVisible(isScoreInfoPresent); + signIcon.setManaged(isScoreInfoPresent); + + if (isScoreInfoPresent) { + //TODO just dummy impl. + ScoreInfo scoreInfo = optionalScoreInfo.get(); + boolean canSign = scoreInfo.isCanSign(); + signIcon.setVisible(canSign); + signIcon.setManaged(canSign); + + long requiredDelay = scoreInfo.getRequiredDelay(); + String age = Utilities.toTruncatedString(formatter.formatAccountAge(requiredDelay), 8); + delayLabel.setText(age); + + boolean requireDelay = requiredDelay > 0; + delayIcon.setVisible(requireDelay); + delayIcon.setManaged(requireDelay); + delayLabel.setVisible(requireDelay); + delayLabel.setManaged(requireDelay); + + if (scoreInfo.getAccountScoreCategory() == AccountScoreCategory.GOLD) { + categoryIcon.getStyleClass().addAll("score-gold"); + AwesomeDude.setIcon(categoryIcon, AwesomeIcon.STAR); + } else if (scoreInfo.getAccountScoreCategory() == AccountScoreCategory.SILVER) { + categoryIcon.getStyleClass().addAll("score-silver"); + AwesomeDude.setIcon(categoryIcon, AwesomeIcon.STAR_HALF_EMPTY); + } else if (scoreInfo.getAccountScoreCategory() == AccountScoreCategory.BRONZE) { + categoryIcon.getStyleClass().addAll("score-bronze"); + AwesomeDude.setIcon(categoryIcon, AwesomeIcon.STAR_EMPTY); + } } } } 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 39ffb3c776c..415834c0578 100644 --- a/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java +++ b/desktop/src/main/java/bisq/desktop/components/paymentmethods/PaymentMethodForm.java @@ -25,6 +25,7 @@ import bisq.desktop.util.Layout; import bisq.core.account.score.AccountScoreService; +import bisq.core.account.score.ScoreInfo; import bisq.core.account.witness.AccountAgeWitnessService; import bisq.core.locale.Country; import bisq.core.locale.CurrencyUtil; @@ -61,6 +62,7 @@ import javafx.util.StringConverter; import java.util.List; +import java.util.Optional; import lombok.extern.slf4j.Slf4j; @@ -168,10 +170,11 @@ protected void addLimitations(boolean isDisplayForm) { final TradeCurrency tradeCurrency; boolean isAltcoin = paymentAccount instanceof AssetAccount; + TradeCurrency selectedTradeCurrency = paymentAccount.getSelectedTradeCurrency(); if (paymentAccount.getSingleTradeCurrency() != null) tradeCurrency = paymentAccount.getSingleTradeCurrency(); - else if (paymentAccount.getSelectedTradeCurrency() != null) - tradeCurrency = paymentAccount.getSelectedTradeCurrency(); + else if (selectedTradeCurrency != null) + tradeCurrency = selectedTradeCurrency; else if (!paymentAccount.getTradeCurrencies().isEmpty()) tradeCurrency = paymentAccount.getTradeCurrencies().get(0); else @@ -183,11 +186,19 @@ else if (!paymentAccount.getTradeCurrencies().isEmpty()) String tradeLimit = formatter.formatCoinWithCode(Coin.valueOf(accountAgeWitnessService.getMyTradeLimit(paymentAccount, tradeCurrency.getCode()))); String limitationsText = Res.get("payment.maxPeriodAndTradeLimits", getTimeText(hours), tradeLimit); String accountAgeText = ""; + String canSign = ""; + long accountAge = 0; if (!isAltcoin) { - String requiredAccountAge = formatter.formatAccountAge(accountScoreService.getPhaseOnePeriod(paymentAccount.getPaymentMethod())); - long accountAge = !isAddAccountScreen ? accountAgeWitnessService.getMyAccountAge(paymentAccount.getPaymentAccountPayload()) : 0L; - accountAgeText = Res.get("payment.accountAge", formatter.formatAccountAge(accountAge), requiredAccountAge); + Optional optionalScoreInfo = accountScoreService.getScoreInfoForMyPaymentAccount(paymentAccount, tradeCurrency.getCode()); + if (optionalScoreInfo.isPresent()) { + ScoreInfo scoreInfo = optionalScoreInfo.get(); + + canSign = scoreInfo.isCanSign() ? Res.get("shared.yes") : Res.get("shared.no"); + canSign = "\n" + Res.getWithCol("peerInfo.canSign") + " " + canSign; + accountAge = !isAddAccountScreen ? scoreInfo.getAccountAge() : 0L; + } } + accountAgeText = Res.get("payment.accountAge", formatter.formatAccountAge(accountAge), canSign); if (isDisplayForm) { addCompactTopLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), limitationsText); @@ -196,9 +207,6 @@ else if (!paymentAccount.getTradeCurrencies().isEmpty()) } } else { addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.limitations"), limitationsText); - if (!isAltcoin) { - addTopLabelTextField(gridPane, ++gridRow, Res.get("payment.accountAgeTitle"), accountAgeText); - } } if (isAddAccountScreen) { InputTextField inputTextField = addInputTextField(gridPane, ++gridRow, Res.get("payment.salt"), 0); 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 341629e29f1..500be39d8c4 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 @@ -237,7 +237,7 @@ private void onSaveNewAccount(PaymentAccount paymentAccount) { .onAction(() -> doSaveNewAccount(paymentAccount)) .show(); } else { - String requiredAccountAge = formatter.formatAccountAge(accountScoreService.getPhaseOnePeriod(paymentAccount.getPaymentMethod())); + String requiredAccountAge = formatter.formatAccountAge(accountScoreService.getPhaseOnePeriodAsMilli()); String text = Res.get("payment.limits.info", formatter.formatCoinWithCode(maxTradeLimitFirstMonth), formatter.formatCoinWithCode(maxTradeLimitSecondMonth), diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java index db00e11c559..a9df3db683b 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java @@ -836,7 +836,7 @@ public boolean isHalCashAccount() { } long getPhaseOnePeriod() { - return accountScoreService.getPhaseOnePeriod(paymentAccount.getPaymentMethod()); + return accountScoreService.getPhaseOnePeriodAsMilli(); } Optional getMyScoreInfo() { @@ -844,7 +844,13 @@ Optional getMyScoreInfo() { } boolean ignoreRestrictions() { - return amount.get() == null || accountScoreService.ignoreRestrictions(amount.get()); + return amount.get() == null || + accountScoreService.ignoreRestrictions(amount.get()) || + accountScoreService.ignoreRestrictions(paymentAccount.getPaymentMethod()); + } + + boolean ignoreRestrictionsBasedOnPaymentMethod() { + return accountScoreService.ignoreRestrictions(paymentAccount.getPaymentMethod()); } boolean isRequireAuthorizedTaker() { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java index c1b00bb580b..513f5d46060 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferView.java @@ -180,6 +180,7 @@ public abstract class MutableOfferView extends buyerSecurityDepositInfoInputTextField; private AutoTooltipSlideToggleButton tradeFeeInBtcToggle, tradeFeeInBsqToggle, requireAuthorizedTakerToggle; private Text xIcon, fakeXIcon; + private ChangeListener amountListener; /////////////////////////////////////////////////////////////////////////////////////////// @@ -267,6 +268,8 @@ protected void doActivate() { } requireAuthorizedTakerToggle.setSelected(model.getDataModel().isRequireAuthorizedTaker()); + + updateRestrictionsFields(); } } @@ -544,6 +547,7 @@ protected void onPaymentAccountsComboBoxSelected() { model.onPaymentAccountSelected(paymentAccount); model.onCurrencySelected(model.getDataModel().getTradeCurrency()); } + updateRestrictionsFields(); } else { currencySelection.setVisible(false); currencySelection.setManaged(false); @@ -557,6 +561,16 @@ protected void onPaymentAccountsComboBoxSelected() { updatePriceToggle(); } + private void updateRestrictionsFields() { + boolean ignoreRestrictionsBasedOnPaymentMethod = model.getDataModel().ignoreRestrictionsBasedOnPaymentMethod(); + requireAuthorizedBuyerLabel.setVisible(!ignoreRestrictionsBasedOnPaymentMethod); + requireAuthorizedTakerToggle.setVisible(!ignoreRestrictionsBasedOnPaymentMethod); + takerRestrictionsLabel.setVisible(!ignoreRestrictionsBasedOnPaymentMethod); + requireAuthorizedBuyerLabel.setManaged(!ignoreRestrictionsBasedOnPaymentMethod); + requireAuthorizedTakerToggle.setManaged(!ignoreRestrictionsBasedOnPaymentMethod); + takerRestrictionsLabel.setManaged(!ignoreRestrictionsBasedOnPaymentMethod); + } + private void onCurrencyComboBoxSelected() { model.onCurrencySelected(currencyComboBox.getSelectionModel().getSelectedItem()); } @@ -855,6 +869,8 @@ private void createListeners() { requireAuthorizedTakerToggleListener = (observable, oldValue, newValue) -> { model.getDataModel().setRequireAuthorizedTaker(newValue); }; + + amountListener = (observable, oldValue, newValue) -> updateRestrictionsFields(); } private void setIsCurrencyForMakerFeeBtc(boolean isCurrencyForMakerFeeBtc) { @@ -892,6 +908,7 @@ private void addListeners() { model.volume.addListener(volumeListener); model.isTradeFeeVisible.addListener(tradeFeeVisibleListener); model.buyerSecurityDepositInBTC.addListener(buyerSecurityDepositInBTCListener); + model.getDataModel().amount.addListener(amountListener); tradeFeeInBtcToggle.selectedProperty().addListener(tradeFeeInBtcToggleListener); tradeFeeInBsqToggle.selectedProperty().addListener(tradeFeeInBsqToggleListener); @@ -926,6 +943,7 @@ private void removeListeners() { model.volume.removeListener(volumeListener); model.isTradeFeeVisible.removeListener(tradeFeeVisibleListener); model.buyerSecurityDepositInBTC.removeListener(buyerSecurityDepositInBTCListener); + model.getDataModel().amount.removeListener(amountListener); tradeFeeInBtcToggle.selectedProperty().removeListener(tradeFeeInBtcToggleListener); tradeFeeInBsqToggle.selectedProperty().removeListener(tradeFeeInBsqToggleListener); @@ -1070,7 +1088,7 @@ private void addOptionsGroup() { NewBadge securityDepositBoxWithNewBadge = new NewBadge(getBuyerSecurityDepositBox(), BUYER_SECURITY_DEPOSIT_NEWS, preferences); - advancedOptionsBox.getChildren().addAll(securityDepositBoxWithNewBadge, getTakerRestrictionFieldsBox(), getTradeFeeFieldsBox()); + advancedOptionsBox.getChildren().addAll(securityDepositBoxWithNewBadge, getTradeFeeFieldsBox(), getTakerRestrictionFieldsBox()); Tuple2 tuple = add2ButtonsAfterGroup(gridPane, ++gridRow, Res.get("shared.nextStep"), Res.get("shared.cancel")); @@ -1488,9 +1506,7 @@ private VBox getTakerRestrictionFieldsBox() { hBox.setMaxHeight(hBox.getMinHeight()); final Tuple2 tuple = getTradeInputBox(hBox, Res.get("createOffer.takerRestriction")); - takerRestrictionsLabel = tuple.first; - return tuple.second; } diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java index 0bea1e77607..9603f54dd36 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookView.java @@ -505,7 +505,7 @@ private void onTakeOffer(Offer offer) { return; } - if (offer.getDirection() == OfferPayload.Direction.BUY) { + if (offer.getDirection() == OfferPayload.Direction.BUY && !model.ignoreRestrictions(offer)) { Optional optionalScoreInfo = model.getScoreInfoForMaker(offer); if (optionalScoreInfo.isPresent()) { ScoreInfo scoreInfo = optionalScoreInfo.get(); diff --git a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java index f54da90ef65..b9305eb1367 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/offerbook/OfferBookViewModel.java @@ -484,6 +484,10 @@ long getMakersAccountAge(Offer offer) { return accountAgeWitnessService.getMakersAccountAge(offer); } + boolean ignoreRestrictions(Offer offer) { + return accountScoreService.ignoreRestrictions(offer); + } + Optional getScoreInfoForMaker(Offer offer) { return accountScoreService.getScoreInfoForMaker(offer); } @@ -523,7 +527,9 @@ boolean isAnyPaymentAccountValidForOffer(Offer offer) { } boolean hasAuthorizedAccount(Offer offer) { - return user.getPaymentAccounts() != null && PaymentAccountUtil.hasAuthorizedAccount(offer, user.getPaymentAccounts(), accountScoreService); + return user.getPaymentAccounts() != null && + PaymentAccountUtil.hasAuthorizedAccount(offer, user.getPaymentAccounts(), accountScoreService) || + accountScoreService.ignoreRestrictions(offer); } boolean hasPaymentAccountForCurrency() { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java index dee639eba47..30b091bb3e8 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/takeoffer/TakeOfferDataModel.java @@ -670,7 +670,7 @@ public boolean isBsqForFeeAvailable() { } long getPhaseOnePeriod() { - return accountScoreService.getPhaseOnePeriod(paymentAccount.getPaymentMethod()); + return accountScoreService.getPhaseOnePeriodAsMilli(); } Optional getMyScoreInfo() { @@ -678,6 +678,6 @@ Optional getMyScoreInfo() { } boolean ignoreRestrictions() { - return amount.get() == null || accountScoreService.ignoreRestrictions(amount.get()); + return accountScoreService.ignoreRestrictions(offer); } }