From f91db182d88e08c03e756ea0697d7772aea7f804 Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 6 Mar 2023 12:03:59 -0500 Subject: [PATCH] desktop app creates offers with floating market price --- core/src/main/java/bisq/core/offer/CreateOfferService.java | 6 ++++++ .../java/bisq/desktop/main/offer/MutableOfferDataModel.java | 2 +- .../java/bisq/desktop/main/offer/MutableOfferViewModel.java | 3 --- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/core/src/main/java/bisq/core/offer/CreateOfferService.java b/core/src/main/java/bisq/core/offer/CreateOfferService.java index b72cedd37d..a0f7184b4a 100644 --- a/core/src/main/java/bisq/core/offer/CreateOfferService.java +++ b/core/src/main/java/bisq/core/offer/CreateOfferService.java @@ -133,6 +133,12 @@ public class CreateOfferService { minAmount, buyerSecurityDepositAsDouble); + // verify fixed price xor market price with margin + if (price != null) { + if (useMarketBasedPrice) throw new IllegalArgumentException("Can create offer with fixed price or floating market price but not both"); + if (marketPriceMargin != 0) throw new IllegalArgumentException("Cannot set market price margin with fixed price"); + } + long creationTime = new Date().getTime(); NodeAddress makerAddress = p2PService.getAddress(); boolean useMarketBasedPriceValue = price == null && 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 897d582a56..d45b6426d6 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferDataModel.java @@ -293,7 +293,7 @@ public abstract class MutableOfferDataModel extends OfferDataModel { tradeCurrencyCode.get(), amount.get(), minAmount.get(), - price.get(), + useMarketBasedPrice.get() ? null : price.get(), Coin.ZERO, useMarketBasedPrice.get(), marketPriceMargin, 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 8ca9388ad9..60a3bd4405 100644 --- a/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/bisq/desktop/main/offer/MutableOfferViewModel.java @@ -676,11 +676,8 @@ public abstract class MutableOfferViewModel ext // On focus out we do validation and apply the data to the model void onFocusOutAmountTextField(boolean oldValue, boolean newValue) { if (oldValue && !newValue) { - System.out.println("Checking if input valid: " + amount.get()); InputValidator.ValidationResult result = isXmrInputValid(amount.get()); amountValidationResult.set(result); - System.out.println("Result is valid: " + result.isValid); - System.out.println("Result error: " + result.errorMessage); if (result.isValid) { setAmountToModel(); ignoreAmountStringListener = true;