internal override byte[] GenerateBytes() { var builder = new FlatBufferBuilder(1); // create vectors var signatureVector = SecretProofTransactionBuffer.CreateSignatureVector(builder, new byte[64]); var signerVector = SecretProofTransactionBuffer.CreateSignerVector(builder, GetSigner()); var feeVector = SecretProofTransactionBuffer.CreateMaxFeeVector(builder, MaxFee?.ToUInt8Array()); var deadlineVector = SecretProofTransactionBuffer.CreateDeadlineVector(builder, Deadline.Ticks.ToUInt8Array()); var secretVector = SecretLockTransactionBuffer.CreateSecretVector(builder, Secret.DecodeHexString()); var proofVector = SecretProofTransactionBuffer.CreateProofVector(builder, Proof.DecodeHexString()); var version = int.Parse(NetworkType.GetValueInByte().ToString("X") + "0" + Version.ToString("X"), NumberStyles.HexNumber); var recipientVector = SecretProofTransactionBuffer.CreateRecipientVector(builder, Recipient.GetBytes()); int totalSize = GetSerializedSize(); SecretProofTransactionBuffer.StartSecretProofTransactionBuffer(builder); SecretProofTransactionBuffer.AddSize(builder, (uint)totalSize); SecretProofTransactionBuffer.AddSignature(builder, signatureVector); SecretProofTransactionBuffer.AddSigner(builder, signerVector); SecretProofTransactionBuffer.AddVersion(builder, (uint)version); SecretProofTransactionBuffer.AddType(builder, TransactionType.GetValue()); SecretProofTransactionBuffer.AddMaxFee(builder, feeVector); SecretProofTransactionBuffer.AddDeadline(builder, deadlineVector); SecretProofTransactionBuffer.AddHashAlgorithm(builder, HashType.GetValueInByte()); SecretProofTransactionBuffer.AddRecipient(builder, recipientVector); SecretProofTransactionBuffer.AddSecret(builder, secretVector); SecretProofTransactionBuffer.AddProofSize(builder, Convert.ToUInt16(Proof.DecodeHexString().Length)); SecretProofTransactionBuffer.AddProof(builder, proofVector); var codedSecretProof = SecretProofTransactionBuffer.EndSecretProofTransactionBuffer(builder); builder.Finish(codedSecretProof.Value); var output = new SecretProofTransactionSchema().Serialize(builder.SizedByteArray()); if (output.Length != totalSize) { throw new SerializationException("Serialized form has incorrect length"); } return(output); }
internal override byte[] GenerateBytes() { var builder = new FlatBufferBuilder(1); // create vectors var signatureVector = SecretLockTransactionBuffer.CreateSignatureVector(builder, new byte[64]); var signerVector = SecretLockTransactionBuffer.CreateSignerVector(builder, GetSigner()); var feeVector = SecretLockTransactionBuffer.CreateMaxFeeVector(builder, MaxFee?.ToUInt8Array()); var deadlineVector = SecretLockTransactionBuffer.CreateDeadlineVector(builder, Deadline.Ticks.ToUInt8Array()); var mosaicIdVector = SecretLockTransactionBuffer.CreateMosaicIdVector(builder, Mosaic.Id.Id.ToUInt8Array()); var mosaicAmountVector = SecretLockTransactionBuffer.CreateMosaicAmountVector(builder, Mosaic.Amount.ToUInt8Array()); var durationVector = SecretLockTransactionBuffer.CreateDurationVector(builder, Duration.ToUInt8Array()); var secretVector = SecretLockTransactionBuffer.CreateSecretVector(builder, Secret.DecodeHexString()); var recipientVector = SecretLockTransactionBuffer.CreateRecipientVector(builder, Recipient.Plain.FromBase32String()); var version = int.Parse(NetworkType.GetValueInByte().ToString("X") + "0" + Version.ToString("X"), NumberStyles.HexNumber); // mosaicID, amount, duration, hash algo, secret, recipient var totalSize = GetSerializedSize(); SecretLockTransactionBuffer.StartSecretLockTransactionBuffer(builder); SecretLockTransactionBuffer.AddSize(builder, (uint)totalSize); SecretLockTransactionBuffer.AddSignature(builder, signatureVector); SecretLockTransactionBuffer.AddSigner(builder, signerVector); SecretLockTransactionBuffer.AddVersion(builder, (uint)version); SecretLockTransactionBuffer.AddType(builder, TransactionType.GetValue()); SecretLockTransactionBuffer.AddMaxFee(builder, feeVector); SecretLockTransactionBuffer.AddDeadline(builder, deadlineVector); SecretLockTransactionBuffer.AddMosaicId(builder, mosaicIdVector); SecretLockTransactionBuffer.AddMosaicAmount(builder, mosaicAmountVector); SecretLockTransactionBuffer.AddDuration(builder, durationVector); SecretLockTransactionBuffer.AddHashAlgorithm(builder, HashType.GetValueInByte()); SecretLockTransactionBuffer.AddSecret(builder, secretVector); SecretLockTransactionBuffer.AddRecipient(builder, recipientVector); // end build var codedTransfer = SecretLockTransactionBuffer.EndSecretLockTransactionBuffer(builder); builder.Finish(codedTransfer.Value); var output = new SecretLockTransactionSchema().Serialize(builder.SizedByteArray()); if (output.Length != totalSize) { throw new SerializationException("Serialized form has incorrect length"); } return(output); }