package bisq.cli;

import java.text.DecimalFormat;
import java.text.NumberFormat;

import java.math.BigDecimal;
import java.math.RoundingMode;

import java.util.Locale;

class CurrencyFormat {

    private static final NumberFormat NUMBER_FORMAT = NumberFormat.getInstance(Locale.US);

    static final BigDecimal SATOSHI_DIVISOR = new BigDecimal(100000000);
    static final DecimalFormat BTC_FORMAT = new DecimalFormat("###,##0.00000000");

    @SuppressWarnings("BigDecimalMethodWithoutRoundingCalled")
    static String formatSatoshis(long sats) {
        return BTC_FORMAT.format(BigDecimal.valueOf(sats).divide(SATOSHI_DIVISOR));
    }

    static String formatAmountRange(long minAmount, long amount) {
        return minAmount != amount
                ? formatSatoshis(minAmount) + " - " + formatSatoshis(amount)
                : formatSatoshis(amount);
    }

    static String formatVolumeRange(long minVolume, long volume) {
        return minVolume != volume
                ? formatOfferVolume(minVolume) + " - " + formatOfferVolume(volume)
                : formatOfferVolume(volume);
    }

    static String formatOfferPrice(long price) {
        NUMBER_FORMAT.setMaximumFractionDigits(4);
        NUMBER_FORMAT.setMinimumFractionDigits(4);
        NUMBER_FORMAT.setRoundingMode(RoundingMode.UNNECESSARY);
        return NUMBER_FORMAT.format((double) price / 10000);
    }

    static String formatOfferVolume(long volume) {
        NUMBER_FORMAT.setMaximumFractionDigits(0);
        NUMBER_FORMAT.setRoundingMode(RoundingMode.UNNECESSARY);
        return NUMBER_FORMAT.format((double) volume / 10000);
    }
}

@@ -1,8 +1,690 @@
+/*%0A * This file is part of Bisq.%0A *%0A * Bisq is free software: you can redistribute it and/or modify it%0A * under the terms of the GNU Affero General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or (at%0A * your option) any later version.%0A *%0A * Bisq is distributed in the hope that it will be useful, but WITHOUT%0A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or%0A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public%0A * License for more details.%0A *%0A * You should have received a copy of the GNU Affero General Public License%0A * along with Bisq. If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0A%0A
 package 
@@ -845,16 +845,56 @@
 ocale;%0A%0A
+import static java.lang.String.format;%0A%0A
 class Cu
@@ -2341,11 +2341,418 @@
 );%0A    %7D
+%0A%0A    static long toSatoshis(String btc) %7B%0A        if (btc.startsWith(%22-%22))%0A            throw new IllegalArgumentException(format(%22'%25s' is not a positive number%22, btc));%0A%0A        try %7B%0A            return new BigDecimal(btc).multiply(SATOSHI_DIVISOR).longValue();%0A        %7D catch (NumberFormatException e) %7B%0A            throw new IllegalArgumentException(format(%22'%25s' is not a number%22, btc));%0A        %7D%0A    %7D
 %0A%7D%0A

Add license comment and btc-string to satoshi converter