Ejemplo n.º 1
0
 private static Sha256Hash calcHash(int height, int pos, List<Sha256Hash> hashes) {
   if (height == 0) {
     // Hash at height 0 is just the regular tx hash itself.
     return hashes.get(pos);
   }
   int h = height - 1;
   int p = pos * 2;
   Sha256Hash left = calcHash(h, p, hashes);
   // Calculate right hash if not beyond the end of the array - copy left hash otherwise.
   Sha256Hash right;
   if (p + 1 < getTreeWidth(hashes.size(), h)) {
     right = calcHash(h, p + 1, hashes);
   } else {
     right = left;
   }
   return combineLeftRight(left.getBytes(), right.getBytes());
 }
Ejemplo n.º 2
0
  @Override
  public void neoscoinSerializeToStream(OutputStream stream) throws IOException {
    uint32ToByteStreamLE(transactionCount, stream);

    stream.write(new VarInt(hashes.size()).encode());
    for (Sha256Hash hash : hashes) stream.write(reverseBytes(hash.getBytes()));

    stream.write(new VarInt(matchedChildBits.length).encode());
    stream.write(matchedChildBits);
  }