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);
        }
        /// <summary>
        ///     Returns the Allow Trust XDR Operation Body
        /// </summary>
        /// <returns></returns>
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.AllowTrustOp op = new sdkxdr.AllowTrustOp();

            // trustor
            sdkxdr.AccountID trustor = new sdkxdr.AccountID();
            trustor.InnerValue = Trustor.XdrPublicKey;
            op.Trustor         = trustor;
            // asset
            sdkxdr.AllowTrustOp.AllowTrustOpAsset asset = new sdkxdr.AllowTrustOp.AllowTrustOpAsset();

            if (AssetCode.Length <= 4)
            {
                asset.Discriminant =
                    sdkxdr.AssetType.Create(sdkxdr.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4);
                asset.AssetCode4 = Util.PaddedByteArray(AssetCode, 4);
            }
            else
            {
                asset.Discriminant =
                    sdkxdr.AssetType.Create(sdkxdr.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM12);
                asset.AssetCode12 = Util.PaddedByteArray(AssetCode, 12);
            }

            op.Asset = asset;
            // authorize
            op.Authorize = Authorize;

            sdkxdr.Operation.OperationBody body = new sdkxdr.Operation.OperationBody();
            body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.ALLOW_TRUST);
            body.AllowTrustOp = 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);
        }
Exemplo n.º 4
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 sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.ManageDataOp op   = new sdkxdr.ManageDataOp();
            sdkxdr.String64     name = new sdkxdr.String64();
            name.InnerValue = Name;
            op.DataName     = name;

            if (Value != null)
            {
                sdkxdr.DataValue dataValue = new sdkxdr.DataValue();
                dataValue.InnerValue = Value;
                op.DataValue         = dataValue;
            }

            sdkxdr.Operation.OperationBody body = new sdkxdr.Operation.OperationBody();
            body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.MANAGE_DATA);
            body.ManageDataOp = op;

            return(body);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            sdkxdr.SetOptionsOp op = new sdkxdr.SetOptionsOp();

            if (InflationDestination != null)
            {
                sdkxdr.AccountID inflationDestination = new sdkxdr.AccountID();
                inflationDestination.InnerValue = InflationDestination.XdrPublicKey;
                op.InflationDest = inflationDestination;
            }

            if (ClearFlags != null)
            {
                sdkxdr.Uint32 clearFlags = new sdkxdr.Uint32();
                clearFlags.InnerValue = ClearFlags.Value;
                op.ClearFlags         = clearFlags;
            }

            if (SetFlags != null)
            {
                sdkxdr.Uint32 setFlags = new sdkxdr.Uint32();
                setFlags.InnerValue = SetFlags.Value;
                op.SetFlags         = setFlags;
            }

            if (MasterKeyWeight != null)
            {
                sdkxdr.Uint32 uint32 = new sdkxdr.Uint32();
                uint32.InnerValue = MasterKeyWeight.Value;
                op.MasterWeight   = uint32;
            }

            if (LowThreshold != null)
            {
                sdkxdr.Uint32 uint32 = new sdkxdr.Uint32();
                uint32.InnerValue = LowThreshold.Value;
                op.LowThreshold   = uint32;
            }

            if (MediumThreshold != null)
            {
                sdkxdr.Uint32 uint32 = new sdkxdr.Uint32();
                uint32.InnerValue = MediumThreshold.Value;
                op.MedThreshold   = uint32;
            }

            if (HighThreshold != null)
            {
                sdkxdr.Uint32 uint32 = new sdkxdr.Uint32();
                uint32.InnerValue = HighThreshold.Value;
                op.HighThreshold  = uint32;
            }

            if (HomeDomain != null)
            {
                sdkxdr.String32 homeDomain = new sdkxdr.String32();
                homeDomain.InnerValue = HomeDomain;
                op.HomeDomain         = homeDomain;
            }

            if (Signer != null)
            {
                sdkxdr.Signer signer = new sdkxdr.Signer();
                sdkxdr.Uint32 weight = new sdkxdr.Uint32();
                weight.InnerValue = SignerWeight.Value & 0xFF;
                signer.Key        = Signer;
                signer.Weight     = weight;
                op.Signer         = signer;
            }

            sdkxdr.Operation.OperationBody body = new sdkxdr.Operation.OperationBody();
            body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.SET_OPTIONS);
            body.SetOptionsOp = op;
            return(body);
        }