parse commas in xmr amounts to decimal

This commit is contained in:
woodser 2023-10-16 12:25:07 -04:00
parent 4217424c6e
commit 0294062312
2 changed files with 3 additions and 2 deletions

View File

@ -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);
}

View File

@ -687,7 +687,7 @@ public abstract class MutableOfferViewModel<M extends MutableOfferDataModel> 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()));