org.bitcoinj.core.Utils.readInt64()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(80)

本文整理了Java中org.bitcoinj.core.Utils.readInt64()方法的一些代码示例,展示了Utils.readInt64()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.readInt64()方法的具体详情如下:
包路径:org.bitcoinj.core.Utils
类名称:Utils
方法名:readInt64

Utils.readInt64介绍

[英]Parse 8 bytes from the byte array (starting at the offset) as signed 64-bit integer in little endian format.
[中]将字节数组中的8个字节(从偏移量开始)解析为little endian格式的有符号64位整数。

代码示例

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

protected long readInt64() throws ProtocolException {
  try {
    long u = Utils.readInt64(payload, cursor);
    cursor += 8;
    return u;
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ProtocolException(e);
  }
}

代码示例来源:origin: fr.acinq/bitcoinj-core

protected long readInt64() throws ProtocolException {
  try {
    long u = Utils.readInt64(payload, cursor);
    cursor += 8;
    return u;
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ProtocolException(e);
  }
}

代码示例来源:origin: greenaddress/GreenBits

protected long readInt64() throws ProtocolException {
  try {
    long u = Utils.readInt64(payload, cursor);
    cursor += 8;
    return u;
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ProtocolException(e);
  }
}

代码示例来源:origin: HashEngineering/dashj

protected long readInt64() throws ProtocolException {
  try {
    long u = Utils.readInt64(payload, cursor);
    cursor += 8;
    return u;
  } catch (ArrayIndexOutOfBoundsException e) {
    throw new ProtocolException(e);
  }
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

/**
 * Constructs a new VarInt with the value parsed from the specified offset of the given buffer.
 *
 * @param buf the buffer containing the value
 * @param offset the offset of the value
 */
public VarInt(byte[] buf, int offset) {
  int first = 0xFF & buf[offset];
  if (first < 253) {
    value = first;
    originallyEncodedSize = 1; // 1 data byte (8 bits)
  } else if (first == 253) {
    value = (0xFF & buf[offset + 1]) | ((0xFF & buf[offset + 2]) << 8);
    originallyEncodedSize = 3; // 1 marker + 2 data bytes (16 bits)
  } else if (first == 254) {
    value = Utils.readUint32(buf, offset + 1);
    originallyEncodedSize = 5; // 1 marker + 4 data bytes (32 bits)
  } else {
    value = Utils.readInt64(buf, offset + 1);
    originallyEncodedSize = 9; // 1 marker + 8 data bytes (64 bits)
  }
}

代码示例来源:origin: HashEngineering/dashj

/**
 * Constructs a new VarInt with the value parsed from the specified offset of the given buffer.
 *
 * @param buf the buffer containing the value
 * @param offset the offset of the value
 */
public VarInt(byte[] buf, int offset) {
  int first = 0xFF & buf[offset];
  if (first < 253) {
    value = first;
    originallyEncodedSize = 1; // 1 data byte (8 bits)
  } else if (first == 253) {
    value = (0xFF & buf[offset + 1]) | ((0xFF & buf[offset + 2]) << 8);
    originallyEncodedSize = 3; // 1 marker + 2 data bytes (16 bits)
  } else if (first == 254) {
    value = Utils.readUint32(buf, offset + 1);
    originallyEncodedSize = 5; // 1 marker + 4 data bytes (32 bits)
  } else {
    value = Utils.readInt64(buf, offset + 1);
    originallyEncodedSize = 9; // 1 marker + 8 data bytes (64 bits)
  }
}

代码示例来源:origin: fr.acinq/bitcoinj-core

/**
 * Constructs a new VarInt with the value parsed from the specified offset of the given buffer.
 *
 * @param buf the buffer containing the value
 * @param offset the offset of the value
 */
public VarInt(byte[] buf, int offset) {
  int first = 0xFF & buf[offset];
  if (first < 253) {
    value = first;
    originallyEncodedSize = 1; // 1 data byte (8 bits)
  } else if (first == 253) {
    value = (0xFF & buf[offset + 1]) | ((0xFF & buf[offset + 2]) << 8);
    originallyEncodedSize = 3; // 1 marker + 2 data bytes (16 bits)
  } else if (first == 254) {
    value = Utils.readUint32(buf, offset + 1);
    originallyEncodedSize = 5; // 1 marker + 4 data bytes (32 bits)
  } else {
    value = Utils.readInt64(buf, offset + 1);
    originallyEncodedSize = 9; // 1 marker + 8 data bytes (64 bits)
  }
}

代码示例来源:origin: greenaddress/GreenBits

/**
 * Constructs a new VarInt with the value parsed from the specified offset of the given buffer.
 *
 * @param buf the buffer containing the value
 * @param offset the offset of the value
 */
public VarInt(byte[] buf, int offset) {
  int first = 0xFF & buf[offset];
  if (first < 253) {
    value = first;
    originallyEncodedSize = 1; // 1 data byte (8 bits)
  } else if (first == 253) {
    value = (0xFF & buf[offset + 1]) | ((0xFF & buf[offset + 2]) << 8);
    originallyEncodedSize = 3; // 1 marker + 2 data bytes (16 bits)
  } else if (first == 254) {
    value = Utils.readUint32(buf, offset + 1);
    originallyEncodedSize = 5; // 1 marker + 4 data bytes (32 bits)
  } else {
    value = Utils.readInt64(buf, offset + 1);
    originallyEncodedSize = 9; // 1 marker + 8 data bytes (64 bits)
  }
}

代码示例来源:origin: fr.acinq/bitcoinj-core

public void deserializeFromStream(InputStream in) throws IOException {
  byte[] valueBytes = new byte[8];
  if (in.read(valueBytes, 0, 8) != 8)
    throw new EOFException();
  value = Coin.valueOf(Utils.readInt64(valueBytes, 0));
  int scriptBytesLength = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] scriptBytes = new byte[scriptBytesLength];
  if (in.read(scriptBytes) != scriptBytesLength)
    throw new EOFException();
  script = new Script(scriptBytes);
  byte[] hashBytes = new byte[32];
  if (in.read(hashBytes) != 32)
    throw new EOFException();
  hash = Sha256Hash.wrap(hashBytes);
  byte[] indexBytes = new byte[4];
  if (in.read(indexBytes) != 4)
    throw new EOFException();
  index = Utils.readUint32(indexBytes, 0);
  height = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] coinbaseByte = new byte[1];
  in.read(coinbaseByte);
  coinbase = coinbaseByte[0] == 1;
}

代码示例来源:origin: cash.bitcoinj/bitcoinj-core

public UTXO(InputStream in) throws IOException {
  byte[] valueBytes = new byte[8];
  if (in.read(valueBytes, 0, 8) != 8)
    throw new EOFException();
  value = Coin.valueOf(Utils.readInt64(valueBytes, 0));
  int scriptBytesLength = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] scriptBytes = new byte[scriptBytesLength];
  if (in.read(scriptBytes) != scriptBytesLength)
    throw new EOFException();
  script = new Script(scriptBytes);
  byte[] hashBytes = new byte[32];
  if (in.read(hashBytes) != 32)
    throw new EOFException();
  hash = Sha256Hash.wrap(hashBytes);
  byte[] indexBytes = new byte[4];
  if (in.read(indexBytes) != 4)
    throw new EOFException();
  index = Utils.readUint32(indexBytes, 0);
  height = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] coinbaseByte = new byte[1];
  in.read(coinbaseByte);
  coinbase = coinbaseByte[0] == 1;
}

代码示例来源:origin: greenaddress/GreenBits

public void deserializeFromStream(InputStream in) throws IOException {
  byte[] valueBytes = new byte[8];
  if (in.read(valueBytes, 0, 8) != 8)
    throw new EOFException();
  value = Coin.valueOf(Utils.readInt64(valueBytes, 0));
  int scriptBytesLength = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] scriptBytes = new byte[scriptBytesLength];
  if (in.read(scriptBytes) != scriptBytesLength)
    throw new EOFException();
  script = new Script(scriptBytes);
  byte[] hashBytes = new byte[32];
  if (in.read(hashBytes) != 32)
    throw new EOFException();
  hash = Sha256Hash.wrap(hashBytes);
  byte[] indexBytes = new byte[4];
  if (in.read(indexBytes) != 4)
    throw new EOFException();
  index = Utils.readUint32(indexBytes, 0);
  height = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] coinbaseByte = new byte[1];
  in.read(coinbaseByte);
  coinbase = coinbaseByte[0] == 1;
}

代码示例来源:origin: HashEngineering/dashj

public UTXO(InputStream in) throws IOException {
  byte[] valueBytes = new byte[8];
  if (in.read(valueBytes, 0, 8) != 8)
    throw new EOFException();
  value = Coin.valueOf(Utils.readInt64(valueBytes, 0));
  int scriptBytesLength = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] scriptBytes = new byte[scriptBytesLength];
  if (in.read(scriptBytes) != scriptBytesLength)
    throw new EOFException();
  script = new Script(scriptBytes);
  byte[] hashBytes = new byte[32];
  if (in.read(hashBytes) != 32)
    throw new EOFException();
  hash = Sha256Hash.wrap(hashBytes);
  byte[] indexBytes = new byte[4];
  if (in.read(indexBytes) != 4)
    throw new EOFException();
  index = Utils.readUint32(indexBytes, 0);
  height = ((in.read() & 0xFF)) |
      ((in.read() & 0xFF) << 8) |
      ((in.read() & 0xFF) << 16) |
      ((in.read() & 0xFF) << 24);
  byte[] coinbaseByte = new byte[1];
  in.read(coinbaseByte);
  coinbase = coinbaseByte[0] == 1;
}

相关文章