From 02940623122fba809650deafea305fe755f55c4c Mon Sep 17 00:00:00 2001 From: woodser Date: Mon, 16 Oct 2023 12:25:07 -0400 Subject: [PATCH] parse commas in xmr amounts to decimal --- core/src/main/java/haveno/core/trade/HavenoUtils.java | 3 ++- .../java/haveno/desktop/main/offer/MutableOfferViewModel.java | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/haveno/core/trade/HavenoUtils.java b/core/src/main/java/haveno/core/trade/HavenoUtils.java index 329a5f10..0c2ee27e 100644 --- a/core/src/main/java/haveno/core/trade/HavenoUtils.java +++ b/core/src/main/java/haveno/core/trade/HavenoUtils.java @@ -34,6 +34,7 @@ import haveno.core.trade.messages.InitTradeRequest; import haveno.core.trade.messages.PaymentReceivedMessage; import haveno.core.trade.messages.PaymentSentMessage; import haveno.core.util.JsonUtil; +import haveno.core.util.ParsingUtils; import haveno.network.p2p.NodeAddress; import java.math.BigDecimal; import java.math.BigInteger; @@ -189,7 +190,7 @@ public class HavenoUtils { public static BigInteger parseXmr(String input) { if (input == null || input.length() == 0) return BigInteger.valueOf(0); try { - return xmrToAtomicUnits(new BigDecimal(input).doubleValue()); + return xmrToAtomicUnits(new BigDecimal(ParsingUtils.parseNumberStringToDouble(input)).doubleValue()); } catch (Exception e) { return BigInteger.valueOf(0); } diff --git a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java index 50ce6571..6e486c23 100644 --- a/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java +++ b/desktop/src/main/java/haveno/desktop/main/offer/MutableOfferViewModel.java @@ -687,7 +687,7 @@ public abstract class MutableOfferViewModel ext if (minAmount.get() != null) minAmountValidationResult.set(isXmrInputValid(minAmount.get())); } else if (amount.get() != null && xmrValidator.getMaxTradeLimit() != null && xmrValidator.getMaxTradeLimit().longValueExact() == OfferRestrictions.TOLERATED_SMALL_TRADE_AMOUNT.longValueExact()) { - if (Double.parseDouble(amount.get()) < HavenoUtils.atomicUnitsToXmr(Restrictions.getMinTradeAmount())) { + if (ParsingUtils.parseNumberStringToDouble(amount.get()) < HavenoUtils.atomicUnitsToXmr(Restrictions.getMinTradeAmount())) { amountValidationResult.set(result); } else { amount.set(HavenoUtils.formatXmr(xmrValidator.getMaxTradeLimit()));