internal override byte[] GenerateBytes() { var builder = new FlatBufferBuilder(1); // create transaction bytes var transactionsBytes = new byte[0]; transactionsBytes = InnerTransactions.Aggregate(transactionsBytes, (current, innerTransaction) => current.Concat(innerTransaction.ToAggregate()).ToArray()); // Create Vectors var signatureVector = AggregateTransactionBuffer.CreateSignatureVector(builder, new byte[64]); var signerVector = AggregateTransactionBuffer.CreateSignerVector(builder, GetSigner()); var deadlineVector = AggregateTransactionBuffer.CreateDeadlineVector(builder, Deadline.Ticks.ToUInt8Array()); var feeVector = AggregateTransactionBuffer.CreateMaxFeeVector(builder, MaxFee?.ToUInt8Array()); var transactionsVector = AggregateTransactionBuffer.CreateTransactionsVector(builder, transactionsBytes); // total size of transaction /*var totalSize = HEADER_SIZE + 4 + transactionsBytes.Length;*/ var totalSize = GetSerializedSize(); // create version var version = GetTxVersionSerialization(); // add vectors AggregateTransactionBuffer.StartAggregateTransactionBuffer(builder); AggregateTransactionBuffer.AddSize(builder, (uint)totalSize); AggregateTransactionBuffer.AddSignature(builder, signatureVector); AggregateTransactionBuffer.AddSigner(builder, signerVector); AggregateTransactionBuffer.AddVersion(builder, (uint)version); AggregateTransactionBuffer.AddType(builder, TransactionType.GetValue()); AggregateTransactionBuffer.AddMaxFee(builder, feeVector); AggregateTransactionBuffer.AddDeadline(builder, deadlineVector); AggregateTransactionBuffer.AddTransactionsSize(builder, (uint)transactionsBytes.Length); AggregateTransactionBuffer.AddTransactions(builder, transactionsVector); // end build var codedTransaction = AggregateTransactionBuffer.EndAggregateTransactionBuffer(builder).Value; builder.Finish(codedTransaction); var output = new AggregateTransactionSchema().Serialize(builder.SizedByteArray()); if (output.Length != totalSize) { throw new SerializationException("Serialized form has incorrect length"); } return(output); }