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 feb85be9e34..44371697167 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java @@ -174,7 +174,7 @@ public MutableOfferDataModel(CreateOfferService createOfferService, addressEntry = btcWalletService.getOrCreateAddressEntry(offerId, AddressEntry.Context.OFFER_FUNDING); useMarketBasedPrice.set(preferences.isUsePercentageBasedPrice()); - buyerSecurityDeposit.set(preferences.getBuyerSecurityDepositAsPercent(null)); + buyerSecurityDeposit.set(Restrictions.getMinBuyerSecurityDepositAsPercent()); btcBalanceListener = new BalanceListener(getAddressEntry().getAddress()) { @Override @@ -334,10 +334,10 @@ void onPaymentAccountSelected(PaymentAccount paymentAccount) { } private void setSuggestedSecurityDeposit(PaymentAccount paymentAccount) { - var minSecurityDeposit = preferences.getBuyerSecurityDepositAsPercent(getPaymentAccount()); + var minSecurityDeposit = Restrictions.getMinBuyerSecurityDepositAsPercent(); try { if (getTradeCurrency() == null) { - setBuyerSecurityDeposit(minSecurityDeposit, false); + setBuyerSecurityDeposit(minSecurityDeposit); return; } // Get average historic prices over for the prior trade period equaling the lock time @@ -360,7 +360,7 @@ private void setSuggestedSecurityDeposit(PaymentAccount paymentAccount) { var min = extremes[0]; var max = extremes[1]; if (min == 0d || max == 0d) { - setBuyerSecurityDeposit(minSecurityDeposit, false); + setBuyerSecurityDeposit(minSecurityDeposit); return; } // Suggested deposit is double the trade range over the previous lock time period, bounded by min/max deposit @@ -640,12 +640,8 @@ protected void setVolume(Volume volume) { this.volume.set(volume); } - void setBuyerSecurityDeposit(double value, boolean persist) { + void setBuyerSecurityDeposit(double value) { this.buyerSecurityDeposit.set(value); - if (persist) { - // Only expected to persist for manually changed deposit values - preferences.setBuyerSecurityDepositAsPercent(value, getPaymentAccount()); - } } protected boolean isUseMarketBasedPriceValue() { diff --git a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java index 588c06cb564..248da70bda1 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -421,7 +421,7 @@ private void createListeners() { securityDepositStringListener = (ov, oldValue, newValue) -> { if (!ignoreSecurityDepositStringListener) { if (securityDepositValidator.validate(newValue).isValid) { - setBuyerSecurityDepositToModel(false); + setBuyerSecurityDepositToModel(); dataModel.calculateTotalToPay(); } updateButtonDisableState(); @@ -898,7 +898,7 @@ void onFocusOutBuyerSecurityDepositTextField(boolean oldValue, boolean newValue) .width(800) .actionButtonText(Res.get("createOffer.resetToDefault")) .onAction(() -> { - dataModel.setBuyerSecurityDeposit(defaultSecurityDeposit, false); + dataModel.setBuyerSecurityDeposit(defaultSecurityDeposit); ignoreSecurityDepositStringListener = true; buyerSecurityDeposit.set(FormattingUtils.formatToPercent(dataModel.getBuyerSecurityDeposit().get())); ignoreSecurityDepositStringListener = false; @@ -915,7 +915,7 @@ void onFocusOutBuyerSecurityDepositTextField(boolean oldValue, boolean newValue) } private void applyBuyerSecurityDepositOnFocusOut() { - setBuyerSecurityDepositToModel(true); + setBuyerSecurityDepositToModel(); ignoreSecurityDepositStringListener = true; buyerSecurityDeposit.set(FormattingUtils.formatToPercent(dataModel.getBuyerSecurityDeposit().get())); ignoreSecurityDepositStringListener = false; @@ -1146,13 +1146,11 @@ private void setVolumeToModel() { } } - private void setBuyerSecurityDepositToModel(boolean persistPreference) { + private void setBuyerSecurityDepositToModel() { if (buyerSecurityDeposit.get() != null && !buyerSecurityDeposit.get().isEmpty()) { - dataModel.setBuyerSecurityDeposit(ParsingUtils.parsePercentStringToDouble(buyerSecurityDeposit.get()), - persistPreference); + dataModel.setBuyerSecurityDeposit(ParsingUtils.parsePercentStringToDouble(buyerSecurityDeposit.get())); } else { - dataModel.setBuyerSecurityDeposit(Restrictions.getDefaultBuyerSecurityDepositAsPercent(), - persistPreference); + dataModel.setBuyerSecurityDeposit(Restrictions.getDefaultBuyerSecurityDepositAsPercent()); } } @@ -1160,7 +1158,7 @@ private void validateAndSetBuyerSecurityDepositToModel() { // If the security deposit in the model is not valid percent String value = FormattingUtils.formatToPercent(dataModel.getBuyerSecurityDeposit().get()); if (!securityDepositValidator.validate(value).isValid) { - dataModel.setBuyerSecurityDeposit(Restrictions.getDefaultBuyerSecurityDepositAsPercent(), false); + dataModel.setBuyerSecurityDeposit(Restrictions.getDefaultBuyerSecurityDepositAsPercent()); } }