|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.bitcoin.core.Utils
public class Utils
A collection of various utility methods that are helpful for working with the BitCoin protocol. To enable debug logging from the library, run with -Dbitcoinj.logging=true on your command line.
Field Summary | |
---|---|
static BigInteger |
CENT
How many "nanocoins" there are in 0.01 BitCoins. |
static BigInteger |
COIN
How many "nanocoins" there are in a BitCoin. |
Constructor Summary | |
---|---|
Utils()
|
Method Summary | |
---|---|
static String |
bitcoinValueToFriendlyString(BigInteger value)
Returns the given value in nanocoins as a 0.12 type string. |
static String |
bytesToHexString(byte[] bytes)
Returns the given byte array hex encoded. |
static byte[] |
doubleDigest(byte[] input)
See doubleDigest(byte[],int,int) . |
static byte[] |
doubleDigest(byte[] input,
int offset,
int length)
Calculates the SHA-256 hash of the given byte range, and then hashes the resulting hash again. |
static byte[] |
doubleDigestTwoBuffers(byte[] input1,
int offset1,
int length1,
byte[] input2,
int offset2,
int length2)
Calculates SHA256(SHA256(byte range 1 + byte range 2)). |
static boolean |
isLessThanUnsigned(long n1,
long n2)
Work around lack of unsigned types in Java. |
static int |
readUint16BE(byte[] bytes,
int offset)
|
static long |
readUint32(byte[] bytes,
int offset)
|
static long |
readUint32BE(byte[] bytes,
int offset)
|
static byte[] |
reverseBytes(byte[] bytes)
Returns a copy of the given byte array in reverse order. |
static byte[] |
sha256hash160(byte[] input)
Calculates RIPEMD160(SHA256(input)). |
static BigInteger |
toNanoCoins(int coins,
int cents)
Convert an amount expressed in the way humans are used to into nanocoins. |
static BigInteger |
toNanoCoins(String coins)
Convert an amount expressed in the way humans are used to into nanocoins. |
static void |
uint32ToByteArrayBE(long val,
byte[] out,
int offset)
|
static void |
uint32ToByteArrayLE(long val,
byte[] out,
int offset)
|
static void |
uint32ToByteStreamLE(long val,
OutputStream stream)
|
static void |
uint64ToByteStreamLE(BigInteger val,
OutputStream stream)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final BigInteger COIN
public static final BigInteger CENT
Constructor Detail |
---|
public Utils()
Method Detail |
---|
public static BigInteger toNanoCoins(int coins, int cents)
public static BigInteger toNanoCoins(String coins)
This takes string in a format understood by BigDecimal.BigDecimal(String)
,
for example "0", "1", "0.10", "1.23E3", "1234.5E-5".
ArithmeticException
- if you try to specify fractional nanocoinspublic static void uint32ToByteArrayBE(long val, byte[] out, int offset)
public static void uint32ToByteArrayLE(long val, byte[] out, int offset)
public static void uint32ToByteStreamLE(long val, OutputStream stream) throws IOException
IOException
public static void uint64ToByteStreamLE(BigInteger val, OutputStream stream) throws IOException
IOException
public static byte[] doubleDigest(byte[] input)
doubleDigest(byte[],int,int)
.
public static byte[] doubleDigest(byte[] input, int offset, int length)
public static byte[] doubleDigestTwoBuffers(byte[] input1, int offset1, int length1, byte[] input2, int offset2, int length2)
public static boolean isLessThanUnsigned(long n1, long n2)
public static String bytesToHexString(byte[] bytes)
public static byte[] reverseBytes(byte[] bytes)
public static long readUint32(byte[] bytes, int offset)
public static long readUint32BE(byte[] bytes, int offset)
public static int readUint16BE(byte[] bytes, int offset)
public static byte[] sha256hash160(byte[] input)
public static String bitcoinValueToFriendlyString(BigInteger value)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |