示例#1
0
  /* [receipt, blockHash, index] */
  public byte[] getEncoded() {

    byte[] receiptRLP = this.receipt.getEncoded();
    byte[] blockHashRLP = RLP.encodeElement(blockHash);
    byte[] indexRLP = RLP.encodeInt(index);

    byte[] rlpEncoded = RLP.encodeList(receiptRLP, blockHashRLP, indexRLP);

    return rlpEncoded;
  }
  public byte[] encode() {

    byte[] publicKey = new byte[64];
    System.arraycopy(ephemeralPublicKey.getEncoded(false), 1, publicKey, 0, publicKey.length);

    byte[] publicBytes = RLP.encode(publicKey);
    byte[] nonceBytes = RLP.encode(nonce);
    byte[] versionBytes = RLP.encodeInt(version);

    return RLP.encodeList(publicBytes, nonceBytes, versionBytes);
  }
示例#3
0
 public static byte[] rlpEncodeList(Object... elems) {
   byte[][] encodedElems = new byte[elems.length][];
   for (int i = 0; i < elems.length; i++) {
     if (elems[i] instanceof Byte) {
       encodedElems[i] = RLP.encodeByte((Byte) elems[i]);
     } else if (elems[i] instanceof Integer) {
       encodedElems[i] = RLP.encodeInt((Integer) elems[i]);
     } else if (elems[i] instanceof Long) {
       encodedElems[i] = rlpEncodeLong((Long) elems[i]);
     } else if (elems[i] instanceof String) {
       encodedElems[i] = RLP.encodeString((String) elems[i]);
     } else if (elems[i] instanceof byte[]) {
       encodedElems[i] = ((byte[]) elems[i]);
     } else {
       throw new RuntimeException("Unsupported object: " + elems[i]);
     }
   }
   return RLP.encodeList(encodedElems);
 }
示例#4
0
 public static byte[] rlpEncodeLong(long n) {
   // TODO for now leaving int cast
   return RLP.encodeInt((int) n);
 }