public Hash GetProof() { using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { bw.Write((UInt32)TxVersion); bw.Write((UInt32)Timestamp.ToEpoch()); bw.Write((byte)OpCode); bw.Write((UInt32)Inputs.Count); foreach (var(address, amount) in Inputs) { bw.Write((string)address); bw.Write((UInt64)amount); } bw.Write((UInt32)Outputs.Count); foreach (var(address, amount) in Outputs) { bw.Write((string)address); bw.Write((UInt64)amount); } return(HashUtil.Compute(HashUtil.Compute(ms.ToArray()))); } }
public void TestNullHash() { // Automatically 32 0-bytes var hash = new byte[32]; output.WriteLine(((Hash)HashUtil.Compute(hash)).ToString()); }
public Hash GetProof() { using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { bw.Write((UInt32)BlockVersion); bw.Write((byte[])PreviousBlock); bw.Write((byte[])TxMerkleRoot); bw.Write((UInt32)Timestamp.ToEpoch()); bw.Write((UInt32)Throttle); bw.Write((UInt32)Nonce); return(HashUtil.Compute(HashUtil.Compute(ms.ToArray()))); } }
private string ConstructAddress() { // TODO: FIX, but we want 160-bit hash var publicKeyHash = SHA1.Create().ComputeHash(HashUtil.Compute(PublicKey)); using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { bw.Write((byte)AddressType.Normal); bw.Write((byte[])publicKeyHash); bw.Write(HashUtil.Compute(HashUtil.Compute(ms.ToArray())).Take(4).ToArray()); return(new Base58CheckCodec().Encode(ms.ToArray())); } }