public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.ManageOfferOp();

            op.Selling = Selling.ToXdr();
            op.Buying  = Buying.ToXdr();
            var amount = new sdkxdr.Int64();

            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;
            var price = stellar_dotnet_sdk.Price.FromString(Price);

            op.Price = price.ToXdr();
            var offerId = new sdkxdr.Uint64();

            offerId.InnerValue = OfferId;
            op.OfferID         = offerId;

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant  = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.MANAGE_OFFER);
            body.ManageOfferOp = op;

            return(body);
        }
        public xdr.FeeBumpTransaction ToXdr()
        {
            var fee = new Int64 {
                InnerValue = Fee
            };
            var feeSource = FeeSource.MuxedAccount;

            var inner = new xdr.FeeBumpTransaction.FeeBumpTransactionInnerTx
            {
                Discriminant = new EnvelopeType {
                    InnerValue = EnvelopeType.EnvelopeTypeEnum.ENVELOPE_TYPE_TX
                },
                V1 = new TransactionV1Envelope
                {
                    Tx         = InnerTransaction.ToXdrV1(),
                    Signatures = InnerTransaction.Signatures.ToArray()
                }
            };

            var ext = new xdr.FeeBumpTransaction.FeeBumpTransactionExt {
                Discriminant = 0
            };

            var transaction = new xdr.FeeBumpTransaction
            {
                Fee       = fee,
                FeeSource = feeSource,
                InnerTx   = inner,
                Ext       = ext,
            };

            return(transaction);
        }
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.PathPaymentStrictReceiveOp();

            // sendAsset
            op.SendAsset = SendAsset.ToXdr();
            // sendMax
            var sendMax = new sdkxdr.Int64();

            sendMax.InnerValue = ToXdrAmount(SendMax);
            op.SendMax         = sendMax;
            // destination
            op.Destination = Destination.MuxedAccount;
            // destAsset
            op.DestAsset = DestAsset.ToXdr();
            // destAmount
            var destAmount = new sdkxdr.Int64();

            destAmount.InnerValue = ToXdrAmount(DestAmount);
            op.DestAmount         = destAmount;
            // path
            var path = new sdkxdr.Asset[Path.Length];

            for (var i = 0; i < Path.Length; i++)
            {
                path[i] = Path[i].ToXdr();
            }
            op.Path = path;

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.PATH_PAYMENT_STRICT_RECEIVE);
            body.PathPaymentStrictReceiveOp = op;
            return(body);
        }
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.ChangeTrustOp();

            op.Line = Asset.ToXdr();
            var limit = new sdkxdr.Int64();

            limit.InnerValue = ToXdrAmount(Limit);
            op.Limit         = limit;

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant  = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.CHANGE_TRUST);
            body.ChangeTrustOp = op;
            return(body);
        }
        /// <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);
        }
Example #6
0
        public override xdr.Operation.OperationBody ToOperationBody()
        {
            var op          = new CreateAccountOp();
            var destination = new AccountID();

            destination.InnerValue = Destination.XdrPublicKey;
            op.Destination         = destination;
            var startingBalance = new Int64();

            startingBalance.InnerValue = ToXdrAmount(StartingBalance);
            op.StartingBalance         = startingBalance;

            var body = new xdr.Operation.OperationBody();

            body.Discriminant    = OperationType.Create(OperationType.OperationTypeEnum.CREATE_ACCOUNT);
            body.CreateAccountOp = op;
            return(body);
        }
Example #7
0
        /// <summary>
        ///     Generates Transaction XDR object.
        /// </summary>
        /// <returns></returns>
        public xdr.Transaction ToXdr()
        {
            // fee
            var fee = new Uint32 {
                InnerValue = Fee
            };

            // sequenceNumber
            var sequenceNumberUint = new xdr.Int64(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);
        }
        public override OperationBody ToOperationBody()
        {
            var op     = new BumpSequenceOp();
            var bumpTo = new xdr.Int64 {
                InnerValue = BumpTo
            };
            var sequenceNumber = new SequenceNumber {
                InnerValue = bumpTo
            };

            op.BumpTo = sequenceNumber;

            var body = new OperationBody
            {
                Discriminant   = OperationType.Create(OperationType.OperationTypeEnum.BUMP_SEQUENCE),
                BumpSequenceOp = op
            };

            return(body);
        }
Example #9
0
        public override xdr.Operation.OperationBody ToOperationBody()
        {
            var op = new PaymentOp();

            // destination
            op.Destination = Destination.MuxedAccount;
            // asset
            op.Asset = Asset.ToXdr();
            // amount
            var amount = new Int64();

            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;

            var body = new xdr.Operation.OperationBody();

            body.Discriminant = OperationType.Create(OperationType.OperationTypeEnum.PAYMENT);
            body.PaymentOp    = op;
            return(body);
        }
Example #10
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.CreatePassiveSellOfferOp();

            op.Selling = Selling.ToXdr();
            op.Buying  = Buying.ToXdr();
            var amount = new sdkxdr.Int64();

            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;
            var price = stellar_dotnet_sdk.Price.FromString(Price);

            op.Price = price.ToXdr();

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant             = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.CREATE_PASSIVE_SELL_OFFER);
            body.CreatePassiveSellOfferOp = op;

            return(body);
        }
Example #11
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.PathPaymentStrictSendOp();

            // sendAsset
            op.SendAsset = SendAsset.ToXdr();
            // sendAmount
            var sendAmount = new sdkxdr.Int64();

            sendAmount.InnerValue = ToXdrAmount(SendAmount);
            op.SendAmount         = sendAmount;
            // destination
            var destination = new sdkxdr.AccountID();

            destination.InnerValue = Destination.XdrPublicKey;
            op.Destination         = destination;
            // destAsset
            op.DestAsset = DestAsset.ToXdr();
            // destMin
            var destMin = new sdkxdr.Int64();

            destMin.InnerValue = ToXdrAmount(DestMin);
            op.DestMin         = destMin;
            // path
            var path = new sdkxdr.Asset[Path.Length];

            for (var i = 0; i < Path.Length; i++)
            {
                path[i] = Path[i].ToXdr();
            }
            op.Path = path;

            var body = new sdkxdr.Operation.OperationBody();

            body.Discriminant            = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.PATH_PAYMENT_STRICT_SEND);
            body.PathPaymentStrictSendOp = op;
            return(body);
        }
Example #12
0
 public static void Encode(XdrDataOutputStream stream, TransactionResult encodedTransactionResult)
 {
     Int64.Encode(stream, encodedTransactionResult.FeeCharged);
     TransactionResultResult.Encode(stream, encodedTransactionResult.Result);
     TransactionResultExt.Encode(stream, encodedTransactionResult.Ext);
 }