Exemplo n.º 1
0
        public byte[] GetBytes(bool skipSignature = false)
        {
            int assetSize = 0;

            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte)Type);
                    writer.Write(Timestamp);
                    writer.Write(SenderPublicKey.FromHex());
                    if (RecipientId != null)
                    {
                        var recId = new BigInteger(RecipientId.Replace("L", ""));
                        writer.Write(recId.ToByteArray());
                    }
                    else
                    {
                        writer.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
                    }
                    writer.Write(Amount);
                    if (Asset != null)
                    {
                        writer.Write(Asset.GetBytes());
                    }
                    if (!skipSignature && !string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }
Exemplo n.º 2
0
        public byte[] GetBytes()
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte)Type);
                    writer.Write(Timestamp);
                    writer.Write(SenderPublicKey.FromHex());

                    if (!string.IsNullOrWhiteSpace(RecipientId))
                    {
                        var recId = new BigInteger(RecipientId.Replace(Constants.AddressSuffix, ""));
                        writer.Write(recId.ToByteArray());
                    }
                    else
                    {
                        writer.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
                    }

                    writer.Write(Amount);

                    if (Asset != null)
                    {
                        writer.Write(Asset.GetBytes());
                    }

                    if (!string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }

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