Beispiel #1
0
        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())));
                }
        }
Beispiel #2
0
        public void TestNullHash()
        {
            // Automatically 32 0-bytes
            var hash = new byte[32];

            output.WriteLine(((Hash)HashUtil.Compute(hash)).ToString());
        }
Beispiel #3
0
        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())));
                }
        }
Beispiel #4
0
        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()));
                }
        }