public byte[] Stream()
        {
            using var ts = new Helper.TangramStream();
            ts
            .Append(Hash)
            .Append(Node);

            foreach (var @ulong in Nodes)
            {
                ts.Append(@ulong);
            }

            foreach (var @ulong in WaitingOn)
            {
                ts.Append(@ulong);
            }

            ts
            .Append(TotalNodes)
            .Append(ExpectedTotalNodes)
            .Append(Status.ToString());

            foreach (var blockGraph in BlockGraphs)
            {
                ts.Append(blockGraph.ToIdentifier());
            }

            return(ts.ToArray());;
        }
Exemple #2
0
        public byte[] Stream()
        {
            using var ts = new Helper.TangramStream();
            ts
            .Append(Key.Image)
            .Append(Key.Offsets);

            return(ts.ToArray());;
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] ToHash()
        {
            using var ts = new Helper.TangramStream();
            ts
            .Append(MerkleRoot)
            .Append(PrevMerkelRoot);

            return(NBitcoin.Crypto.Hashes.DoubleSHA256(ts.ToArray()).ToBytes(false));;
        }
Exemple #4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] ToFinalStream()
        {
            using var ts = new Helper.TangramStream();

            ts.Append(ToStream());
            ts.Append(MerkelRoot);

            return(ts.ToArray());
        }
Exemple #5
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public byte[] ToStream()
 {
     using var ts = new Helper.TangramStream();
     ts.Append(Hash)
     .Append(Node)
     .Append(PreviousHash ?? string.Empty)
     .Append(Round)
     .Append(PublicKey ?? string.Empty)
     .Append(Signature ?? string.Empty);
     return(ts.ToArray());
 }
Exemple #6
0
        public byte[] ToStream()
        {
            if (Validate().Any())
            {
                return(null);
            }

            using var ts = new Helper.TangramStream();
            ts.Append(Key.Image)
            .Append(Key.Offsets);
            return(ts.ToArray());;
        }
Exemple #7
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] ToStream()
        {
            if (Validate().Any())
            {
                return(null);
            }

            using var ts = new Helper.TangramStream();
            ts.Append(Bits)
            .Append(Solution)
            .Append(Nonce)
            .Append(VrfProof)
            .Append(VrfSig)
            .Append(PublicKey);
            return(ts.ToArray());
        }
Exemple #8
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] ToStream()
        {
            if (Validate().Any())
            {
                return(null);
            }

            using var ts = new Helper.TangramStream();

            ts.Append(Version)
            .Append(PrevBlockHash)
            .Append(MerkleRoot)
            .Append(Height)
            .Append(Locktime)
            .Append(LocktimeScript);
            return(ts.ToArray());
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] Stream()
        {
            using var ts = new Helper.TangramStream();
            ts
            .Append(TxnId)
            .Append(Mix)
            .Append(Ver);

            foreach (var bp in Bp)
            {
                ts.Append(bp.Proof);
            }

            foreach (var vin in Vin)
            {
                ts.Append(vin.Key.Image);
                ts.Append(vin.Key.Offsets);
            }

            foreach (var vout in Vout)
            {
                ts
                .Append(vout.A)
                .Append(vout.C)
                .Append(vout.E)
                .Append(vout.L)
                .Append(vout.N)
                .Append(vout.P)
                .Append(vout.S ?? string.Empty)
                .Append(vout.T.ToString());
            }

            foreach (var rct in Rct)
            {
                ts
                .Append(rct.I)
                .Append(rct.M)
                .Append(rct.P)
                .Append(rct.S);
            }

            return(ts.ToArray());;
        }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] Stream()
        {
            byte[] stream;
            using (var ts = new Helper.TangramStream())
            {
                ts
                .Append(TxnId ?? Array.Empty <byte>())
                .Append(Mix)
                .Append(Ver);

                foreach (var vin in Vin)
                {
                    ts.Append(vin.Key.K_Image);
                    ts.Append(vin.Key.K_Offsets);
                }

                foreach (var vout in Vout)
                {
                    ts
                    .Append(vout.A)
                    .Append(vout.C)
                    .Append(vout.E)
                    .Append(vout.L)
                    .Append(vout.N)
                    .Append(vout.P)
                    .Append(vout.S ?? string.Empty)
                    .Append(vout.T.ToString());
                }

                foreach (var rct in Rct)
                {
                    ts
                    .Append(rct.I)
                    .Append(rct.M)
                    .Append(rct.P)
                    .Append(rct.S);
                }

                stream = ts.ToArray();
            }

            return(stream);
        }
Exemple #11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] ToStream()
        {
            if (Validate().Any())
            {
                return(null);
            }

            using var ts = new Helper.TangramStream();
            ts.Append(Height);
            if (Size != 0)
            {
                ts.Append(Size);
            }

            ts.Append(BlockHeader.ToStream())
            .Append(NrTx)
            .Append(Helper.Util.Combine(Txs.Select(x => x.ToHash()).ToArray()))
            .Append(BlockPos.ToStream());
            return(ts.ToArray());
        }
Exemple #12
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] ToStream()
        {
            using var ts = new Helper.TangramStream();
            ts
            .Append(Bits)
            .Append(Nonce)
            .Append(PrevMerkelRoot)
            .Append(Proof)
            .Append(Sec)
            .Append(Seed)
            .Append(Solution)
            .Append(Locktime)
            .Append(LocktimeScript)
            .Append(NBitcoin.Crypto.Hashes.DoubleSHA256(
                        Helper.Util.Combine(Transactions.Select(x => x.ToHash()).ToArray())).ToBytes(false))
            .Append(Version)
            .Append(VrfSignature);

            return(ts.ToArray());
        }
Exemple #13
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public byte[] Stream()
        {
            using var ts = new Helper.TangramStream();

            if (Block != null)
            {
                ts
                .Append(Block.Data)
                .Append(Block.Hash)
                .Append(Block.Node)
                .Append(Block.Round);
            }

            if (Prev != null)
            {
                ts
                .Append(Prev.Data ?? Array.Empty <byte>())
                .Append(Prev.Hash ?? string.Empty)
                .Append(Prev.Node)
                .Append(Prev.Round);
            }

            return(ts.ToArray());
        }