Beispiel #1
0
 public byte[] GetBytes()
 {
     using (MemoryStream stream = new MemoryStream())
     {
         using (BinaryWriter writer = new BinaryWriter(stream))
         {
             writer.Write(Version);
             writer.Write(Timestamp);
             if (PreviousBlock != null)
             {
                 writer.Write(PreviousBlock.ToByteArray());
             }
             else
             {
                 writer.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
             }
             writer.Write(NumberOfTransactions);
             writer.Write(TotalAmount);
             writer.Write(TotalFee);
             writer.Write(PayloadLength);
             writer.Write(PayloadHash.FromHex());
             writer.Write(GeneratorPublicKey.FromHex());
             if (!string.IsNullOrWhiteSpace(BlockSignature))
             {
                 writer.Write(BlockSignature.FromHex());
             }
         }
         return(stream.ToArray());
     }
 }
Beispiel #2
0
        public byte[] GetBytes(bool skipSignature = false)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write(PreviousBlockId.ToByteArray());
                    writer.Write(Height);
                    writer.Write(Timestamp);

                    writer.Write(PayloadLength);
                    writer.Write(PayloadHash.FromHex());
                    writer.Write(Delegate.FromHex());
                    writer.Write(PointId.ToByteArray());
                    writer.Write(PointHeight);
                    writer.Write(BlockCount);
                    writer.Write(Height);

                    if (!skipSignature && !string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }