C# Класс BitSharper.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.
Показать файл Открыть проект

Открытые методы

Метод Описание
BitcoinValueToFriendlyString ( long value ) : string

Returns the given value in nanocoins as a 0.12 type string.

BitcoinValueToFriendlyString ( ulong value ) : string

Returns the given value in nanocoins as a 0.12 type string.

BytesToHexString ( byte bytes ) : string

Returns the given byte array hex encoded.

DoubleDigest ( byte input ) : byte[]

See DoubleDigest(byte[], int, int).

DoubleDigest ( byte input, int offset, int length ) : byte[]

Calculates the SHA-256 hash of the given byte range, and then hashes the resulting hash again. This is standard procedure in BitCoin. The resulting hash is in big endian form.

DoubleDigestTwoBuffers ( byte input1, int offset1, int length1, byte input2, int offset2, int length2 ) : byte[]

Calculates SHA256(SHA256(byte range 1 + byte range 2)).

ReadUint16Be ( byte bytes, int offset ) : ushort
ReadUint32 ( byte bytes, int offset ) : uint
ReadUint32Be ( byte bytes, int offset ) : uint
ReverseBytes ( byte bytes ) : byte[]

Returns a copy of the given byte array in reverse order.

Sha256Hash160 ( byte input ) : byte[]

Calculates RIPEMD160(SHA256(input)). This is used in Address calculations.

ToNanoCoins ( string coins ) : ulong

Convert an amount expressed in the way humans are used to into nanocoins.

This takes string in a format understood by System.Double.Parse(string), for example "0", "1", "0.10", "1.23E3", "1234.5E-5".

ToNanoCoins ( uint coins, uint cents ) : ulong

Convert an amount expressed in the way humans are used to into nanocoins.

Uint32ToByteArrayBe ( uint val, byte @out, int offset ) : void
Uint32ToByteArrayLe ( uint val, byte @out, int offset ) : void
Uint32ToByteStreamLe ( uint val, Stream stream ) : void
Uint64ToByteStreamLe ( ulong val, Stream stream ) : void

Приватные методы

Метод Описание
DecodeCompactBits ( long compact ) : BigInteger
DecodeMpi ( byte mpi ) : BigInteger

MPI encoded numbers are produced by the OpenSSL BN_bn2mpi function. They consist of a 4 byte big endian length field, followed by the stated number of bytes representing the number in big endian format.

Описание методов

BitcoinValueToFriendlyString() публичный статический Метод

Returns the given value in nanocoins as a 0.12 type string.
public static BitcoinValueToFriendlyString ( long value ) : string
value long
Результат string

BitcoinValueToFriendlyString() публичный статический Метод

Returns the given value in nanocoins as a 0.12 type string.
public static BitcoinValueToFriendlyString ( ulong value ) : string
value ulong
Результат string

BytesToHexString() публичный статический Метод

Returns the given byte array hex encoded.
public static BytesToHexString ( byte bytes ) : string
bytes byte
Результат string

DoubleDigest() публичный статический Метод

See DoubleDigest(byte[], int, int).
public static DoubleDigest ( byte input ) : byte[]
input byte
Результат byte[]

DoubleDigest() публичный статический Метод

Calculates the SHA-256 hash of the given byte range, and then hashes the resulting hash again. This is standard procedure in BitCoin. The resulting hash is in big endian form.
public static DoubleDigest ( byte input, int offset, int length ) : byte[]
input byte
offset int
length int
Результат byte[]

DoubleDigestTwoBuffers() публичный статический Метод

Calculates SHA256(SHA256(byte range 1 + byte range 2)).
public static DoubleDigestTwoBuffers ( byte input1, int offset1, int length1, byte input2, int offset2, int length2 ) : byte[]
input1 byte
offset1 int
length1 int
input2 byte
offset2 int
length2 int
Результат byte[]

ReadUint16Be() публичный статический Метод

public static ReadUint16Be ( byte bytes, int offset ) : ushort
bytes byte
offset int
Результат ushort

ReadUint32() публичный статический Метод

public static ReadUint32 ( byte bytes, int offset ) : uint
bytes byte
offset int
Результат uint

ReadUint32Be() публичный статический Метод

public static ReadUint32Be ( byte bytes, int offset ) : uint
bytes byte
offset int
Результат uint

ReverseBytes() публичный статический Метод

Returns a copy of the given byte array in reverse order.
public static ReverseBytes ( byte bytes ) : byte[]
bytes byte
Результат byte[]

Sha256Hash160() публичный статический Метод

Calculates RIPEMD160(SHA256(input)). This is used in Address calculations.
public static Sha256Hash160 ( byte input ) : byte[]
input byte
Результат byte[]

ToNanoCoins() публичный статический Метод

Convert an amount expressed in the way humans are used to into nanocoins.
This takes string in a format understood by System.Double.Parse(string), for example "0", "1", "0.10", "1.23E3", "1234.5E-5".
If you try to specify fractional nanocoins.
public static ToNanoCoins ( string coins ) : ulong
coins string
Результат ulong

ToNanoCoins() публичный статический Метод

Convert an amount expressed in the way humans are used to into nanocoins.
public static ToNanoCoins ( uint coins, uint cents ) : ulong
coins uint
cents uint
Результат ulong

Uint32ToByteArrayBe() публичный статический Метод

public static Uint32ToByteArrayBe ( uint val, byte @out, int offset ) : void
val uint
@out byte
offset int
Результат void

Uint32ToByteArrayLe() публичный статический Метод

public static Uint32ToByteArrayLe ( uint val, byte @out, int offset ) : void
val uint
@out byte
offset int
Результат void

Uint32ToByteStreamLe() публичный статический Метод

public static Uint32ToByteStreamLe ( uint val, Stream stream ) : void
val uint
stream Stream
Результат void

Uint64ToByteStreamLe() публичный статический Метод

public static Uint64ToByteStreamLe ( ulong val, Stream stream ) : void
val ulong
stream Stream
Результат void