コード例 #1
0
        /// <summary>
        ///     Generates Transaction XDR object.
        /// </summary>
        /// <returns></returns>
        public TransactionV0 ToXdrV0()
        {
            if (!(SourceAccount is KeyPair))
            {
                throw new Exception("TransactionEnvelope V0 expects a KeyPair source account");
            }

            // fee
            var fee = new Uint32 {
                InnerValue = Fee
            };

            // sequenceNumber
            var sequenceNumberUint = new xdr.Int64(SequenceNumber);
            var sequenceNumber     = new SequenceNumber {
                InnerValue = sequenceNumberUint
            };

            // sourceAccount
            var sourceAccount = new Uint256(SourceAccount.PublicKey);

            // 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 TransactionV0.TransactionV0Ext {
                Discriminant = 0
            };

            var transaction = new TransactionV0
            {
                Fee    = fee,
                SeqNum = sequenceNumber,
                SourceAccountEd25519 = sourceAccount,
                Operations           = operations,
                Memo       = Memo.ToXdr(),
                TimeBounds = TimeBounds?.ToXdr(),
                Ext        = ext
            };

            return(transaction);
        }
コード例 #2
0
        /// <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);
        }