mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 02:05:53 +00:00
Remove weird constructors.
This commit is contained in:
parent
48a76a8a03
commit
ee4dec1835
@ -29,9 +29,9 @@ import com.google.common.math.LongMath;
|
||||
*/
|
||||
public final class Coin implements Comparable<Coin>, Serializable {
|
||||
|
||||
public static final Coin ZERO = new Coin(BigInteger.ZERO);
|
||||
public static final Coin ONE = new Coin(BigInteger.ONE);
|
||||
public static final Coin TEN = new Coin(BigInteger.TEN);
|
||||
public static final Coin ZERO = Coin.valueOf(0);
|
||||
public static final Coin ONE = Coin.valueOf(1);
|
||||
public static final Coin TEN = Coin.valueOf(10);
|
||||
public static final Coin NEGATIVE_ONE = Coin.valueOf(-1);
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public final class Coin implements Comparable<Coin>, Serializable {
|
||||
* The term nanocoin is very misleading, though, because there are only 100 million
|
||||
* of them in a coin (whereas one would expect 1 billion.
|
||||
*/
|
||||
public static final Coin COIN = new Coin("100000000", 10);
|
||||
public static final Coin COIN = Coin.valueOf(100000000);
|
||||
|
||||
/**
|
||||
* How many "nanocoins" there are in 0.01 BitCoins.
|
||||
@ -50,7 +50,7 @@ public final class Coin implements Comparable<Coin>, Serializable {
|
||||
* The term nanocoin is very misleading, though, because there are only 100 million
|
||||
* of them in a coin (whereas one would expect 1 billion).
|
||||
*/
|
||||
public static final Coin CENT = new Coin("1000000", 10);
|
||||
public static final Coin CENT = Coin.valueOf(1000000);
|
||||
|
||||
private final long value;
|
||||
|
||||
@ -58,18 +58,6 @@ public final class Coin implements Comparable<Coin>, Serializable {
|
||||
this.value = satoshis;
|
||||
}
|
||||
|
||||
public Coin(final BigInteger value) {
|
||||
this.value = value.longValue();
|
||||
}
|
||||
|
||||
public Coin(final String value, final int radix) {
|
||||
this(new BigInteger(value, radix));
|
||||
}
|
||||
|
||||
public Coin(final byte[] value) {
|
||||
this(new BigInteger(value));
|
||||
}
|
||||
|
||||
public static Coin valueOf(final long satoshis) {
|
||||
return new Coin(satoshis);
|
||||
}
|
||||
@ -141,7 +129,7 @@ public final class Coin implements Comparable<Coin>, Serializable {
|
||||
* @throws ArithmeticException if you try to specify fractional nanocoins, or nanocoins out of range.
|
||||
*/
|
||||
public static Coin toNanoCoins(String coins) {
|
||||
Coin bigint = new Coin(new BigDecimal(coins).movePointRight(8).toBigIntegerExact());
|
||||
Coin bigint = Coin.valueOf(new BigDecimal(coins).movePointRight(8).toBigIntegerExact().longValue());
|
||||
if (bigint.signum() < 0)
|
||||
throw new ArithmeticException("Negative coins specified");
|
||||
if (bigint.compareTo(NetworkParameters.MAX_MONEY) > 0)
|
||||
|
@ -650,7 +650,7 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
}
|
||||
// Parse it.
|
||||
int height = results.getInt(1);
|
||||
Coin value = new Coin(results.getBytes(2));
|
||||
Coin value = Coin.valueOf(new BigInteger(results.getBytes(2)).longValue());
|
||||
// Tell the StoredTransactionOutput that we are a coinbase, as that is encoded in height
|
||||
return new StoredTransactionOutput(hash, index, value, height, true, results.getBytes(3));
|
||||
} catch (SQLException ex) {
|
||||
|
@ -744,7 +744,7 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
}
|
||||
// Parse it.
|
||||
int height = results.getInt(1);
|
||||
Coin value = new Coin(results.getBytes(2));
|
||||
Coin value = Coin.valueOf(new BigInteger(results.getBytes(2)).longValue());
|
||||
// Tell the StoredTransactionOutput that we are a coinbase, as that is encoded in height
|
||||
StoredTransactionOutput txout = new StoredTransactionOutput(hash, index, value, height, true, results.getBytes(3));
|
||||
return txout;
|
||||
|
Loading…
x
Reference in New Issue
Block a user