/// <summary> /// Generates the bytes. /// </summary> /// <returns>The transaction bytes.</returns> internal override byte[] GenerateBytes() { var builder = new FlatBufferBuilder(1); // create vectors var signatureVector = TransferTransactionBuffer.CreateSignatureVector(builder, new byte[64]); var signerVector = TransferTransactionBuffer.CreateSignerVector(builder, GetSigner()); var feeVector = TransferTransactionBuffer.CreateFeeVector(builder, Fee.ToUInt8Array()); var deadlineVector = TransferTransactionBuffer.CreateDeadlineVector(builder, Deadline.Ticks.ToUInt8Array()); var recipientVector = TransferTransactionBuffer.CreateRecipientVector(builder, Address.Plain.FromBase32String()); ushort version = ushort.Parse(NetworkType.GetNetworkByte().ToString("X") + "0" + Version.ToString("X"), System.Globalization.NumberStyles.HexNumber); if (Message == null) { Message = EmptyMessage.Create(); } // create message vector var bytePayload = Message.GetPayload(); var payload = MessageBuffer.CreatePayloadVector(builder, bytePayload); MessageBuffer.StartMessageBuffer(builder); if (bytePayload != null) { MessageBuffer.AddType(builder, Message.GetMessageType()); } MessageBuffer.AddPayload(builder, payload); var message = MessageBuffer.EndMessageBuffer(builder); // create mosaics vector var mosaics = new Offset <MosaicBuffer> [Mosaics.Count]; for (var index = 0; index < Mosaics.Count; index++) { var mosaic = Mosaics[index]; var idPayload = MosaicBuffer.CreateIdVector(builder, mosaic.MosaicId.Id.ToUInt8Array()); var amountVector = MosaicBuffer.CreateAmountVector(builder, mosaic.Amount.ToUInt8Array()); MosaicBuffer.StartMosaicBuffer(builder); MosaicBuffer.AddId(builder, idPayload); MosaicBuffer.AddAmount(builder, amountVector); mosaics[index] = MosaicBuffer.EndMosaicBuffer(builder); } var mosaicsVector = TransferTransactionBuffer.CreateMosaicsVector(builder, mosaics); // add vectors TransferTransactionBuffer.StartTransferTransactionBuffer(builder); TransferTransactionBuffer.AddSize(builder, (uint)(/*fixed size*/ 148 + 16 * Mosaics.Count + Message.GetLength())); TransferTransactionBuffer.AddSignature(builder, signatureVector); TransferTransactionBuffer.AddSigner(builder, signerVector); TransferTransactionBuffer.AddVersion(builder, version); TransferTransactionBuffer.AddType(builder, TransactionTypes.Types.Transfer.GetValue()); TransferTransactionBuffer.AddFee(builder, feeVector); TransferTransactionBuffer.AddDeadline(builder, deadlineVector); TransferTransactionBuffer.AddRecipient(builder, recipientVector); TransferTransactionBuffer.AddNumMosaics(builder, (byte)Mosaics.Count); TransferTransactionBuffer.AddMessageSize(builder, (byte)Message.GetLength()); TransferTransactionBuffer.AddMessage(builder, message); TransferTransactionBuffer.AddMosaics(builder, mosaicsVector); // end build var codedTransfer = TransferTransactionBuffer.EndTransferTransactionBuffer(builder); builder.Finish(codedTransfer.Value); return(new TransferTransactionSchema().Serialize(builder.SizedByteArray())); }