package com.msgilligan.bitcoin;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

/**
 * Utility class for converting from satoshis (BigInteger) to bitcoins (BigDecimal) and vice-versa
 */
public class BTC  {
    public static final long satoshisPerBitcoin = 100000000;
    public static final BigInteger satoshisPerBTC = BigInteger.valueOf(satoshisPerBitcoin);
    public static final BigDecimal satoshisPerBTCDecimal = new BigDecimal(satoshisPerBTC);

    public static BigDecimal satoshisToBTC(BigInteger satoshis) {
        BigDecimal decimalSatoshis = new BigDecimal(satoshis);
        return decimalSatoshis.divide(satoshisPerBTCDecimal);
    }
    public static BigInteger btcToSatoshis(BigDecimal btc) {
        BigDecimal satoshisDecimal = btc.multiply(BTC.satoshisPerBTCDecimal);
        return satoshisDecimal.toBigInteger();
    }
}

@@ -26,16 +26,48 @@
 tcoin;%0A%0A
+import org.bitcoinj.core.Coin;%0A%0A
 import j
@@ -908,10 +908,302 @@
 ;%0A    %7D%0A
+    public static Coin btcToCoin(BigDecimal btc) %7B%0A        return Coin.valueOf(BTC.btcToSatoshis(btc).longValue());%0A    %7D%0A    public static BigDecimal coinToBTC(Coin coin) %7B%0A        BigInteger satoshis = BigInteger.valueOf(coin.longValue());%0A        return BTC.satoshisToBTC(satoshis);%0A    %7D%0A
 %7D%0A

Add conversions between BigDecimal & bitcoinj Coin