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

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

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

Utils.uint64ToByteStreamLE介绍

暂无

代码示例

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

public void serializeToStream(OutputStream bos) throws IOException {
  Utils.uint64ToByteStreamLE(BigInteger.valueOf(value.value), bos);
  byte[] scriptBytes = script.getProgram();
  bos.write(0xFF & scriptBytes.length);
  bos.write(0xFF & scriptBytes.length >> 8);
  bos.write(0xFF & (scriptBytes.length >> 16));
  bos.write(0xFF & (scriptBytes.length >> 24));
  bos.write(scriptBytes);
  bos.write(hash.getBytes());
  Utils.uint32ToByteStreamLE(index, bos);
  bos.write(0xFF & (height));
  bos.write(0xFF & (height >> 8));
  bos.write(0xFF & (height >> 16));
  bos.write(0xFF & (height >> 24));
  bos.write(new byte[] { (byte)(coinbase ? 1 : 0) });
}

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

public void serializeToStream(OutputStream bos) throws IOException {
    Utils.uint64ToByteStreamLE(BigInteger.valueOf(value.value), bos);

    byte[] scriptBytes = script.getProgram();
    bos.write(0xFF & scriptBytes.length);
    bos.write(0xFF & scriptBytes.length >> 8);
    bos.write(0xFF & (scriptBytes.length >> 16));
    bos.write(0xFF & (scriptBytes.length >> 24));
    bos.write(scriptBytes);

    bos.write(hash.getBytes());
    Utils.uint32ToByteStreamLE(index, bos);

    bos.write(0xFF & (height));
    bos.write(0xFF & (height >> 8));
    bos.write(0xFF & (height >> 16));
    bos.write(0xFF & (height >> 24));

    bos.write(new byte[] { (byte)(coinbase ? 1 : 0) });
  }
}

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

public void serializeToStream(OutputStream bos) throws IOException {
  Utils.uint64ToByteStreamLE(BigInteger.valueOf(value.value), bos);
  byte[] scriptBytes = script.getProgram();
  bos.write(0xFF & scriptBytes.length);
  bos.write(0xFF & scriptBytes.length >> 8);
  bos.write(0xFF & (scriptBytes.length >> 16));
  bos.write(0xFF & (scriptBytes.length >> 24));
  bos.write(scriptBytes);
  bos.write(hash.getBytes());
  Utils.uint32ToByteStreamLE(index, bos);
  bos.write(0xFF & (height));
  bos.write(0xFF & (height >> 8));
  bos.write(0xFF & (height >> 16));
  bos.write(0xFF & (height >> 24));
  bos.write(new byte[] { (byte)(coinbase ? 1 : 0) });
}

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

public void serializeToStream(OutputStream bos) throws IOException {
    Utils.uint64ToByteStreamLE(BigInteger.valueOf(value.value), bos);

    byte[] scriptBytes = script.getProgram();
    bos.write(0xFF & scriptBytes.length);
    bos.write(0xFF & scriptBytes.length >> 8);
    bos.write(0xFF & (scriptBytes.length >> 16));
    bos.write(0xFF & (scriptBytes.length >> 24));
    bos.write(scriptBytes);

    bos.write(hash.getBytes());
    Utils.uint32ToByteStreamLE(index, bos);

    bos.write(0xFF & (height));
    bos.write(0xFF & (height >> 8));
    bos.write(0xFF & (height >> 16));
    bos.write(0xFF & (height >> 24));

    bos.write(new byte[] { (byte)(coinbase ? 1 : 0) });
  }
}

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

@Override
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
  if (protocolVersion >= 31402) {
    //TODO this appears to be dynamic because the client only ever sends out it's own address
    //so assumes itself to be up.  For a fuller implementation this needs to be dynamic only if
    //the address refers to this client.
    int secs = (int) (Utils.currentTimeSeconds());
    uint32ToByteStreamLE(secs, stream);
  }
  uint64ToByteStreamLE(services, stream);  // nServices.
  // Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it by hand.
  byte[] ipBytes = addr.getAddress();
  if (ipBytes.length == 4) {
    byte[] v6addr = new byte[16];
    System.arraycopy(ipBytes, 0, v6addr, 12, 4);
    v6addr[10] = (byte) 0xFF;
    v6addr[11] = (byte) 0xFF;
    ipBytes = v6addr;
  }
  stream.write(ipBytes);
  // And write out the port. Unlike the rest of the protocol, address and port is in big endian byte order.
  stream.write((byte) (0xFF & port >> 8));
  stream.write((byte) (0xFF & port));
}

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

@Override
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
  if (protocolVersion >= 31402) {
    //TODO this appears to be dynamic because the client only ever sends out it's own address
    //so assumes itself to be up.  For a fuller implementation this needs to be dynamic only if
    //the address refers to this client.
    int secs = (int) (Utils.currentTimeSeconds());
    uint32ToByteStreamLE(secs, stream);
  }
  uint64ToByteStreamLE(services, stream);  // nServices.
  // Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it by hand.
  byte[] ipBytes = addr.getAddress();
  if (ipBytes.length == 4) {
    byte[] v6addr = new byte[16];
    System.arraycopy(ipBytes, 0, v6addr, 12, 4);
    v6addr[10] = (byte) 0xFF;
    v6addr[11] = (byte) 0xFF;
    ipBytes = v6addr;
  }
  stream.write(ipBytes);
  // And write out the port. Unlike the rest of the protocol, address and port is in big endian byte order.
  stream.write((byte) (0xFF & port >> 8));
  stream.write((byte) (0xFF & port));
}

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

@Override
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
  if (protocolVersion >= 31402) {
    //TODO this appears to be dynamic because the client only ever sends out it's own address
    //so assumes itself to be up.  For a fuller implementation this needs to be dynamic only if
    //the address refers to this client.
    int secs = (int) (Utils.currentTimeSeconds());
    uint32ToByteStreamLE(secs, stream);
  }
  uint64ToByteStreamLE(services, stream);  // nServices.
  // Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it by hand.
  byte[] ipBytes = addr.getAddress();
  if (ipBytes.length == 4) {
    byte[] v6addr = new byte[16];
    System.arraycopy(ipBytes, 0, v6addr, 12, 4);
    v6addr[10] = (byte) 0xFF;
    v6addr[11] = (byte) 0xFF;
    ipBytes = v6addr;
  }
  stream.write(ipBytes);
  // And write out the port. Unlike the rest of the protocol, address and port is in big endian byte order.
  stream.write((byte) (0xFF & port >> 8));
  stream.write((byte) (0xFF & port));
}

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

@Override
protected void bitcoinSerializeToStream(OutputStream stream) throws IOException {
  if (protocolVersion >= 31402) {
    //TODO this appears to be dynamic because the client only ever sends out it's own address
    //so assumes itself to be up.  For a fuller implementation this needs to be dynamic only if
    //the address refers to this client.
    int secs = (int) (Utils.currentTimeSeconds());
    uint32ToByteStreamLE(secs, stream);
  }
  uint64ToByteStreamLE(services, stream);  // nServices.
  // Java does not provide any utility to map an IPv4 address into IPv6 space, so we have to do it by hand.
  byte[] ipBytes = addr.getAddress();
  if (ipBytes.length == 4) {
    byte[] v6addr = new byte[16];
    System.arraycopy(ipBytes, 0, v6addr, 12, 4);
    v6addr[10] = (byte) 0xFF;
    v6addr[11] = (byte) 0xFF;
    ipBytes = v6addr;
  }
  stream.write(ipBytes);
  // And write out the port. Unlike the rest of the protocol, address and port is in big endian byte order.
  stream.write((byte) (0xFF & port >> 8));
  stream.write((byte) (0xFF & port));
}

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

ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256);
  for (int i = 0; i < this.outputs.size(); ++i) {
    uint64ToByteStreamLE(
        BigInteger.valueOf(this.outputs.get(i).getValue().getValue()),
        bosHashOutputs
} else if (type == SigHash.SINGLE && inputIndex < outputs.size()) {
  ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256);
  uint64ToByteStreamLE(
      BigInteger.valueOf(this.outputs.get(inputIndex).getValue().getValue()),
      bosHashOutputs
bos.write(new VarInt(connectedScript.length).encode());
bos.write(connectedScript);
uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos);
uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos);
bos.write(hashOutputs);

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

ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256);
  for (int i = 0; i < this.outputs.size(); ++i) {
    uint64ToByteStreamLE(
        BigInteger.valueOf(this.outputs.get(i).getValue().getValue()),
        bosHashOutputs
} else if (type == SigHash.SINGLE && inputIndex < outputs.size()) {
  ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256);
  uint64ToByteStreamLE(
      BigInteger.valueOf(this.outputs.get(inputIndex).getValue().getValue()),
      bosHashOutputs
bos.write(new VarInt(connectedScript.length).encode());
bos.write(connectedScript);
uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos);
uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos);
bos.write(hashOutputs);

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

ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256);
  for (int i = 0; i < this.outputs.size(); ++i) {
    uint64ToByteStreamLE(
        BigInteger.valueOf(this.outputs.get(i).getValue().getValue()),
        bosHashOutputs
} else if (type == SigHash.SINGLE && inputIndex < outputs.size()) {
  ByteArrayOutputStream bosHashOutputs = new UnsafeByteArrayOutputStream(256);
  uint64ToByteStreamLE(
      BigInteger.valueOf(this.outputs.get(inputIndex).getValue().getValue()),
      bosHashOutputs
bos.write(new VarInt(connectedScript.length).encode());
bos.write(connectedScript);
uint64ToByteStreamLE(BigInteger.valueOf(prevValue.getValue()), bos);
uint32ToByteStreamLE(inputs.get(inputIndex).getSequenceNumber(), bos);
bos.write(hashOutputs);

相关文章