fix too much precision calculating security deposit
This commit is contained in:
parent
029a6133a6
commit
8a89be1636
@ -38,6 +38,7 @@ import haveno.core.util.ParsingUtils;
|
||||
import haveno.network.p2p.NodeAddress;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.net.URI;
|
||||
import java.security.PrivateKey;
|
||||
import java.text.DecimalFormat;
|
||||
@ -122,7 +123,7 @@ public class HavenoUtils {
|
||||
}
|
||||
|
||||
public static BigInteger xmrToAtomicUnits(double xmr) {
|
||||
return BigDecimal.valueOf(xmr).multiply(new BigDecimal(XMR_AU_MULTIPLIER)).setScale(8).toBigInteger();
|
||||
return BigDecimal.valueOf(xmr).setScale(8, RoundingMode.DOWN).multiply(new BigDecimal(XMR_AU_MULTIPLIER)).toBigInteger();
|
||||
}
|
||||
|
||||
public static long xmrToCentineros(double xmr) {
|
||||
|
@ -29,6 +29,7 @@ import org.bitcoinj.core.Coin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
@ -76,7 +77,7 @@ public class CoinUtil {
|
||||
*/
|
||||
public static BigInteger getPercentOfAmount(double percent, BigInteger amount) {
|
||||
if (amount == null) amount = BigInteger.valueOf(0);
|
||||
return BigDecimal.valueOf(percent).multiply(new BigDecimal(amount)).toBigInteger();
|
||||
return BigDecimal.valueOf(percent).multiply(new BigDecimal(amount)).setScale(8, RoundingMode.DOWN).toBigInteger();
|
||||
}
|
||||
|
||||
public static BigInteger getRoundedAmount(BigInteger amount, Price price, long maxTradeLimit, String currencyCode, String paymentMethodId) {
|
||||
|
Loading…
Reference in New Issue
Block a user