/// <summary> /// Generates Transaction XDR object. /// </summary> /// <returns></returns> public Generated.Transaction ToXDR() { // fee Generated.Uint32 fee = new Generated.Uint32((uint)mFee); // sequenceNumber Generated.Uint64 sequenceNumberUint = new Generated.Uint64((ulong)SequenceNumber); Generated.SequenceNumber sequenceNumber = new Generated.SequenceNumber(sequenceNumberUint); // sourceAccount Generated.AccountID sourceAccount = new Generated.AccountID(SourceAccount.AccountId.InnerValue); // operations Generated.Operation[] operations = mOperations.Select(tx => tx.ToXDR()).ToArray(); // ext Generated.Transaction.TransactionExt ext = new Generated.Transaction.TransactionExt() { Discriminant = 0 }; Generated.Transaction transaction = new Generated.Transaction() { Fee = fee, SeqNum = sequenceNumber, SourceAccount = sourceAccount, Operations = operations, Memo = Memo.ToXDR(), Ext = ext, //TimeBounds = null, }; return(transaction); }
private string CreateEnvelopeXdrBase64(StellarBase.Generated.Transaction tx, DecoratedSignature signature) { var txEnvelope = new TransactionEnvelope { Tx = tx, Signatures = new[] { signature } }; var writer = new ByteWriter(); TransactionEnvelope.Encode(writer, txEnvelope); var data = writer.ToArray(); return(Convert.ToBase64String(data)); }
private byte[] GetTransactionHash(StellarBase.Generated.Transaction tx) { var writer = new ByteWriter(); // Hashed NetworkID writer.Write(Network.CurrentNetworkId); // Envelope Type - 4 bytes EnvelopeType.Encode(writer, EnvelopeType.Create(EnvelopeType.EnvelopeTypeEnum.ENVELOPE_TYPE_TX)); // Transaction XDR bytes var txWriter = new ByteWriter(); StellarBase.Generated.Transaction.Encode(txWriter, tx); writer.Write(txWriter.ToArray()); var data = writer.ToArray(); return(Utilities.Hash(data)); }