increase max trade limit for lowest risk payment from 2 to 20 xmr

This commit is contained in:
woodser 2022-07-11 14:40:00 -04:00
parent 31b0f4e184
commit f2cd9dd570
2 changed files with 15 additions and 4 deletions

View file

@ -34,7 +34,7 @@ import javax.annotation.Nullable;
@Slf4j
@Singleton
public class TradeLimits {
private static final Coin MAX_TRADE_LIMIT = Coin.parseCoin("2"); // max trade limit for lowest risk payment method. Others will get derived from that.
private static final Coin MAX_TRADE_LIMIT = Coin.parseCoin("20"); // max trade limit for lowest risk payment method. Others will get derived from that.
@Nullable
@Getter
private static TradeLimits INSTANCE;

View file

@ -9,7 +9,7 @@ import org.bitcoinj.core.Coin;
import org.bitcoinj.utils.MonetaryFormat;
import org.apache.commons.lang3.StringUtils;
import java.math.BigDecimal;
import java.math.BigInteger;
import lombok.extern.slf4j.Slf4j;
@ -23,7 +23,8 @@ public class ParsingUtils {
* TODO: change base unit to atomic units and long
* TODO: move these static utilities?
*/
private static BigInteger CENTINEROS_AU_MULTIPLIER = BigInteger.valueOf(10000);
private static BigInteger CENTINEROS_AU_MULTIPLIER = new BigInteger("10000");
private static BigInteger MONERO_AU_MULTIPLIER = new BigInteger("1000000000000");
/**
* Convert Coin (denominated in centineros) to atomic units.
@ -51,10 +52,20 @@ public class ParsingUtils {
* @param atomicUnits is an amount in atomic units
* @return the amount in centineros
*/
public static long atomicUnitsToCentineros(long atomicUnits) {
public static long atomicUnitsToCentineros(long atomicUnits) { // TODO: atomic units should be BigInteger, this should return double, else losing precision
return atomicUnits / CENTINEROS_AU_MULTIPLIER.longValue();
}
/**
* Convert atomic units to centineros.
*
* @param atomicUnits is an amount in atomic units
* @return the amount in centineros
*/
public static double atomicUnitsToXmr(BigInteger atomicUnits) {
return new BigDecimal(atomicUnits).divide(new BigDecimal(MONERO_AU_MULTIPLIER)).doubleValue();
}
public static Coin parseToCoin(String input, CoinFormatter coinFormatter) {
return parseToCoin(input, coinFormatter.getMonetaryFormat());
}