/// <summary> /// Generates the bytes. /// </summary> /// <returns>The transaction bytes.</returns> internal override byte[] GenerateBytes() { var builder = new FlatBufferBuilder(1); var signer = TransferTransactionBuffer.CreatePublicKeyVector(builder, GetSigner()); var recipientVector = TransferTransactionBuffer.CreateRecipientVector(builder, Encoding.UTF8.GetBytes(Address.Plain)); if (Message == null) { Message = EmptyMessage.Create(); } var messageBytePayload = Message.GetPayload(); var payload = MessageBuffer.CreatePayloadVector(builder, messageBytePayload); var messageBuff = new Offset <MessageBuffer> [1]; MessageBuffer.StartMessageBuffer(builder); if (messageBytePayload.Length > 0) { MessageBuffer.AddType(builder, Message.GetMessageType().GetValue()); } if (messageBytePayload.Length > 0) { MessageBuffer.AddPayloadLen(builder, messageBytePayload.Length); } if (messageBytePayload.Length > 0) { MessageBuffer.AddPayload(builder, payload); } messageBuff[0] = MessageBuffer.EndMessageBuffer(builder); var messageVector = TransferTransactionBuffer.CreateMessageVector(builder, messageBuff); var mosaics = new Offset <MosaicBuffer> [Mosaics.Count]; for (var index = 0; index < Mosaics.Count; index++) { var mosaic = Mosaics[index]; var namespaceVector = MosaicBuffer.CreateNamespaceStringVector(builder, Encoding.UTF8.GetBytes(mosaic.NamespaceName)); var mosaicNameVector = MosaicBuffer.CreateMosaicIdStringVector(builder, Encoding.UTF8.GetBytes(mosaic.MosaicName)); MosaicBuffer.StartMosaicBuffer(builder); var nsLen = Encoding.Default.GetBytes(mosaic.NamespaceName).Length; var msLen = Encoding.Default.GetBytes(mosaic.MosaicName).Length; MosaicBuffer.AddMosaicStructureLen(builder, 20 + nsLen + msLen); MosaicBuffer.AddMosaicIdStructureLen(builder, nsLen + msLen + 8); MosaicBuffer.AddNamespaceIdLen(builder, nsLen); MosaicBuffer.AddNamespaceString(builder, namespaceVector); MosaicBuffer.AddMosaicIdLen(builder, msLen); MosaicBuffer.AddMosaicIdString(builder, mosaicNameVector); MosaicBuffer.AddQuantity(builder, mosaic.Amount); mosaics[index] = MosaicBuffer.EndMosaicBuffer(builder); } var mosaicsVector = TransferTransactionBuffer.CreateMosaicsVector(builder, mosaics); TransferTransactionBuffer.StartTransferTransactionBuffer(builder); TransferTransactionBuffer.AddTransactionType(builder, TransactionType.GetValue()); TransferTransactionBuffer.AddVersion(builder, BitConverter.ToInt16(new byte[] { ExtractVersion(Version), 0 }, 0)); TransferTransactionBuffer.AddNetwork(builder, BitConverter.ToInt16(new byte[] { 0, NetworkType.GetNetwork() }, 0)); TransferTransactionBuffer.AddTimestamp(builder, NetworkTime.EpochTimeInMilliSeconds()); TransferTransactionBuffer.AddPublicKeyLen(builder, 32); TransferTransactionBuffer.AddPublicKey(builder, signer); TransferTransactionBuffer.AddFee(builder, Fee); TransferTransactionBuffer.AddDeadline(builder, Deadline.Ticks); TransferTransactionBuffer.AddRecipientLen(builder, 40); TransferTransactionBuffer.AddRecipient(builder, recipientVector); TransferTransactionBuffer.AddAmount(builder, 1000000); TransferTransactionBuffer.AddMessageFieldLen(builder, Message.GetLength() == 0 ? 0 : Message.GetLength() + 8); TransferTransactionBuffer.AddMessage(builder, messageVector); TransferTransactionBuffer.AddNoOfMosaics(builder, Mosaics.Count); TransferTransactionBuffer.AddMosaics(builder, mosaicsVector); var codedTransfer = TransferTransactionBuffer.EndTransferTransactionBuffer(builder); builder.Finish(codedTransfer.Value); return(new TransferTransactionSchema().Serialize(builder.SizedByteArray())); }