/// <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);
        }
Beispiel #3
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);
        }