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 = Kin.Stellar.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 override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.PathPaymentOp op = new sdkxdr.PathPaymentOp();

            // sendAsset
            op.SendAsset = SendAsset.ToXdr();
            // sendMax
            sdkxdr.Int64 sendMax = new sdkxdr.Int64();
            sendMax.InnerValue = ToXdrAmount(SendMax);
            op.SendMax         = sendMax;
            // destination
            sdkxdr.AccountID destination = new sdkxdr.AccountID();
            destination.InnerValue = Destination.XdrPublicKey;
            op.Destination         = destination;
            // destAsset
            op.DestAsset = DestAsset.ToXdr();
            // destAmount
            sdkxdr.Int64 destAmount = new sdkxdr.Int64();
            destAmount.InnerValue = ToXdrAmount(DestAmount);
            op.DestAmount         = destAmount;
            // path
            sdkxdr.Asset[] path = new sdkxdr.Asset[Path.Length];

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

            op.Path = path;

            sdkxdr.Operation.OperationBody body = new sdkxdr.Operation.OperationBody();
            body.Discriminant  = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.PATH_PAYMENT);
            body.PathPaymentOp = op;
            return(body);
        }
Esempio n. 3
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.ChangeTrustOp op = new sdkxdr.ChangeTrustOp();
            op.Line = Asset.ToXdr();
            sdkxdr.Int64 limit = new sdkxdr.Int64();
            limit.InnerValue = ToXdrAmount(Limit);
            op.Limit         = limit;

            sdkxdr.Operation.OperationBody body = new sdkxdr.Operation.OperationBody();
            body.Discriminant  = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.CHANGE_TRUST);
            body.ChangeTrustOp = op;
            return(body);
        }
        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;
        }
Esempio n. 5
0
        /// <summary>
        ///     Generates Transaction XDR object.
        /// </summary>
        /// <returns></returns>
        public xdr.Transaction ToXdr()
        {
            // fee
            Uint32 fee = new Uint32 {
                InnerValue = Fee
            };

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

            // sourceAccount
            AccountID sourceAccount = new AccountID {
                InnerValue = SourceAccount.XdrPublicKey
            };

            // operations
            xdr.Operation[] operations = new xdr.Operation[Operations.Length];

            for (int i = 0; i < Operations.Length; i++)
            {
                operations[i] = Operations[i].ToXdr();
            }

            // ext
            xdr.Transaction.TransactionExt ext = new xdr.Transaction.TransactionExt {
                Discriminant = 0
            };

            xdr.Transaction transaction = new xdr.Transaction
            {
                Fee           = fee,
                SeqNum        = sequenceNumber,
                SourceAccount = sourceAccount,
                Operations    = operations,
                Memo          = Memo.ToXdr(),
                TimeBounds    = TimeBounds?.ToXdr(),
                Ext           = ext
            };
            return(transaction);
        }
Esempio n. 6
0
        public override OperationBody ToOperationBody()
        {
            BumpSequenceOp op     = new BumpSequenceOp();
            Int64          bumpTo = new Int64 {
                InnerValue = BumpTo
            };
            SequenceNumber sequenceNumber = new SequenceNumber {
                InnerValue = bumpTo
            };

            op.BumpTo = sequenceNumber;

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

            return(body);
        }
Esempio n. 7
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.CreatePassiveOfferOp op = new sdkxdr.CreatePassiveOfferOp();
            op.Selling = Selling.ToXdr();
            op.Buying  = Buying.ToXdr();
            sdkxdr.Int64 amount = new sdkxdr.Int64();
            amount.InnerValue = ToXdrAmount(Amount);
            op.Amount         = amount;
            Price price = Sdk.Price.FromString(Price);

            op.Price = price.ToXdr();

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

            body.Discriminant =
                sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.CREATE_PASSIVE_OFFER);
            body.CreatePassiveOfferOp = op;

            return(body);
        }
        public override xdr.Operation.OperationBody ToOperationBody()
        {
            PaymentOp op = new PaymentOp();

            // destination
            AccountID destination = new AccountID();

            destination.InnerValue = Destination.XdrPublicKey;
            op.Destination         = destination;
            // asset
            op.Asset = Asset.ToXdr();
            // amount
            Int64 amount = new Int64();

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

            xdr.Operation.OperationBody body = new xdr.Operation.OperationBody();
            body.Discriminant = OperationType.Create(OperationType.OperationTypeEnum.PAYMENT);
            body.PaymentOp    = op;
            return(body);
        }