mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-02-12 02:05:53 +00:00
Remove weird value accessors.
This commit is contained in:
parent
ee4dec1835
commit
3e846901cb
@ -104,22 +104,10 @@ public final class Coin implements Comparable<Coin>, Serializable {
|
||||
return new Coin(-this.value);
|
||||
}
|
||||
|
||||
public byte[] toByteArray() {
|
||||
return BigInteger.valueOf(this.value).toByteArray();
|
||||
}
|
||||
|
||||
public long longValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public double doubleValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public BigInteger toBigInteger() {
|
||||
return BigInteger.valueOf(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert an amount expressed in the way humans are used to into nanocoins.<p>
|
||||
* <p/>
|
||||
@ -158,7 +146,7 @@ public final class Coin implements Comparable<Coin>, Serializable {
|
||||
boolean negative = value.signum() < 0;
|
||||
if (negative)
|
||||
value = value.negate();
|
||||
BigDecimal bd = new BigDecimal(value.toBigInteger(), 8);
|
||||
BigDecimal bd = new BigDecimal(BigInteger.valueOf(value.longValue()), 8);
|
||||
String formatted = bd.toPlainString(); // Don't use scientific notation.
|
||||
int decimalPoint = formatted.indexOf(".");
|
||||
// Drop unnecessary zeros from the end.
|
||||
@ -180,7 +168,7 @@ public final class Coin implements Comparable<Coin>, Serializable {
|
||||
* </p>
|
||||
*/
|
||||
public String toPlainString() {
|
||||
BigDecimal valueInBTC = new BigDecimal(toBigInteger()).divide(new BigDecimal(COIN.toBigInteger()));
|
||||
BigDecimal valueInBTC = new BigDecimal(BigInteger.valueOf(value)).divide(new BigDecimal(BigInteger.valueOf(COIN.longValue())));
|
||||
return valueInBTC.toPlainString();
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.google.bitcoin.core;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
* A StoredTransactionOutput message contains the information necessary to check a spending transaction.
|
||||
@ -156,7 +157,7 @@ public class StoredTransactionOutput implements Serializable {
|
||||
}
|
||||
|
||||
public void serializeToStream(OutputStream bos) throws IOException {
|
||||
Utils.uint64ToByteStreamLE(value.toBigInteger(), bos);
|
||||
Utils.uint64ToByteStreamLE(BigInteger.valueOf(value.longValue()), bos);
|
||||
|
||||
bos.write(0xFF & scriptBytes.length >> 0);
|
||||
bos.write(0xFF & scriptBytes.length >> 8);
|
||||
|
@ -673,7 +673,7 @@ public class H2FullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
// index is actually an unsigned int
|
||||
s.setInt(2, (int)out.getIndex());
|
||||
s.setInt(3, out.getHeight());
|
||||
s.setBytes(4, out.getValue().toByteArray());
|
||||
s.setBytes(4, BigInteger.valueOf(out.getValue().longValue()).toByteArray());
|
||||
s.setBytes(5, out.getScriptBytes());
|
||||
s.executeUpdate();
|
||||
s.close();
|
||||
|
@ -808,7 +808,7 @@ public class PostgresFullPrunedBlockStore implements FullPrunedBlockStore {
|
||||
// index is actually an unsigned int
|
||||
s.setInt(2, (int)out.getIndex());
|
||||
s.setInt(3, out.getHeight());
|
||||
s.setBytes(4, out.getValue().toByteArray());
|
||||
s.setBytes(4, BigInteger.valueOf(out.getValue().longValue()).toByteArray());
|
||||
s.setBytes(5, out.getScriptBytes());
|
||||
s.setString(6, dbAddress);
|
||||
s.setInt(7, type);
|
||||
|
@ -56,8 +56,8 @@ public class DefaultCoinSelector implements CoinSelector {
|
||||
depth2 = conf2.getDepthInBlocks();
|
||||
Coin aValue = a.getValue();
|
||||
Coin bValue = b.getValue();
|
||||
BigInteger aCoinDepth = aValue.toBigInteger().multiply(BigInteger.valueOf(depth1));
|
||||
BigInteger bCoinDepth = bValue.toBigInteger().multiply(BigInteger.valueOf(depth2));
|
||||
BigInteger aCoinDepth = BigInteger.valueOf(aValue.longValue()).multiply(BigInteger.valueOf(depth1));
|
||||
BigInteger bCoinDepth = BigInteger.valueOf(bValue.longValue()).multiply(BigInteger.valueOf(depth2));
|
||||
int c1 = bCoinDepth.compareTo(aCoinDepth);
|
||||
if (c1 != 0) return c1;
|
||||
// The "coin*days" destroyed are equal, sort by value alone to get the lowest transaction size.
|
||||
|
@ -569,7 +569,7 @@ public class WalletTool {
|
||||
private static void send(PaymentSession session) {
|
||||
try {
|
||||
System.out.println("Payment Request");
|
||||
System.out.println("Coin: " + session.getValue().doubleValue() / 100000 + "mBTC");
|
||||
System.out.println("Coin: " + session.getValue().toFriendlyString() + " BTC");
|
||||
System.out.println("Date: " + session.getDate());
|
||||
System.out.println("Memo: " + session.getMemo());
|
||||
if (session.pkiVerificationData != null) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user