/// <summary> /// Adds a time-bounds to this transaction. /// See: https://www.stellar.org/developers/learn/concepts/transactions.html /// </summary> /// <param name="timeBounds">timeBounds</param> /// <returns>Builder object so you can chain methods.</returns> public Builder AddTimeBounds(TimeBounds timeBounds) { if (_timeBounds != null) { throw new ArgumentException("TimeBounds has been already added.", nameof(timeBounds)); } _timeBounds = timeBounds ?? throw new ArgumentNullException(nameof(timeBounds), "timeBounds cannot be null"); return(this); }
private Transaction(KeyPair sourceAccount, long sequenceNumber, Operation[] operations, Memo memo, TimeBounds timeBounds) { SourceAccount = sourceAccount ?? throw new ArgumentNullException(nameof(sourceAccount), "sourceAccount cannot be null"); SequenceNumber = sequenceNumber; Operations = operations ?? throw new ArgumentNullException(nameof(operations), "operations cannot be null"); if (operations.Length == 0) { throw new ArgumentNullException(nameof(operations), "At least one operation required"); } Fee = operations.Length * BaseFee; Signatures = new List <DecoratedSignature>(); Memo = memo ?? Memo.None(); TimeBounds = timeBounds; }
/// <summary> /// Generates Transaction XDR object. /// </summary> /// <returns></returns> public xdr.Transaction ToXdr() { // fee var fee = new Uint32 { InnerValue = Fee }; // sequenceNumber var sequenceNumberUint = new Uint64 { InnerValue = SequenceNumber }; var sequenceNumber = new SequenceNumber { InnerValue = sequenceNumberUint }; // sourceAccount var sourceAccount = new AccountID { InnerValue = SourceAccount.XdrPublicKey }; // operations var operations = new xdr.Operation[Operations.Length]; for (var i = 0; i < Operations.Length; i++) { operations[i] = Operations[i].ToXdr(); } // ext var ext = new xdr.Transaction.TransactionExt { Discriminant = 0 }; var transaction = new xdr.Transaction { Fee = fee, SeqNum = sequenceNumber, SourceAccount = sourceAccount, Operations = operations, Memo = Memo.ToXdr(), TimeBounds = TimeBounds?.ToXdr(), Ext = ext }; return(transaction); }