예제 #1
0
        /// <summary>
        /// Returns the Allow Trust XDR Operation Body
        /// </summary>
        /// <returns></returns>
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.AllowTrustOp();

            // trustor
            var trustor = new sdkxdr.AccountID();

            trustor.InnerValue = Trustor.XdrPublicKey;
            op.Trustor         = trustor;
            // asset
            var 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;

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

            body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.ALLOW_TRUST);
            body.AllowTrustOp = op;
            return(body);
        }
예제 #2
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);
        }
예제 #3
0
        public override sdkxdr.Operation.OperationBody ToOperationBody()
        {
            var op = new sdkxdr.SetOptionsOp();

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

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

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

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

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

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

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

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

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

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

            body.Discriminant = sdkxdr.OperationType.Create(sdkxdr.OperationType.OperationTypeEnum.SET_OPTIONS);
            body.SetOptionsOp = op;
            return(body);
        }
 public static void Encode(XdrDataOutputStream stream, CreateAccountOp encodedCreateAccountOp)
 {
     AccountID.Encode(stream, encodedCreateAccountOp.Destination);
     Int64.Encode(stream, encodedCreateAccountOp.StartingBalance);
 }
 public static void Encode(XdrDataOutputStream stream, InflationPayout encodedInflationPayout)
 {
     AccountID.Encode(stream, encodedInflationPayout.Destination);
     Int64.Encode(stream, encodedInflationPayout.Amount);
 }
예제 #6
0
 public static void Encode(XdrDataOutputStream stream, LedgerKeyData encodedLedgerKeyData)
 {
     AccountID.Encode(stream, encodedLedgerKeyData.AccountID);
     String64.Encode(stream, encodedLedgerKeyData.DataName);
 }
예제 #7
0
 public static void Encode(XdrDataOutputStream stream, AllowTrustOp encodedAllowTrustOp)
 {
     AccountID.Encode(stream, encodedAllowTrustOp.Trustor);
     AllowTrustOpAsset.Encode(stream, encodedAllowTrustOp.Asset);
     Uint32.Encode(stream, encodedAllowTrustOp.Authorize);
 }
예제 #8
0
 public static void Encode(XdrDataOutputStream stream, LedgerKeyTrustLine encodedLedgerKeyTrustLine)
 {
     AccountID.Encode(stream, encodedLedgerKeyTrustLine.AccountID);
     Asset.Encode(stream, encodedLedgerKeyTrustLine.Asset);
 }
예제 #9
0
 public static void Encode(XdrDataOutputStream stream, LedgerKeyOffer encodedLedgerKeyOffer)
 {
     AccountID.Encode(stream, encodedLedgerKeyOffer.SellerID);
     Uint64.Encode(stream, encodedLedgerKeyOffer.OfferID);
 }
예제 #10
0
 public static void Encode(XdrDataOutputStream stream, ClaimantV0 encodedClaimantV0)
 {
     AccountID.Encode(stream, encodedClaimantV0.Destination);
     ClaimPredicate.Encode(stream, encodedClaimantV0.Predicate);
 }
예제 #11
0
 public static void Encode(XdrDataOutputStream stream, SimplePaymentResult encodedSimplePaymentResult)
 {
     AccountID.Encode(stream, encodedSimplePaymentResult.Destination);
     Asset.Encode(stream, encodedSimplePaymentResult.Asset);
     Int64.Encode(stream, encodedSimplePaymentResult.Amount);
 }
예제 #12
0
 public static void Encode(XdrDataOutputStream stream, SetOptionsOp encodedSetOptionsOp)
 {
     if (encodedSetOptionsOp.InflationDest != null)
     {
         stream.WriteInt(1);
         AccountID.Encode(stream, encodedSetOptionsOp.InflationDest);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.ClearFlags != null)
     {
         stream.WriteInt(1);
         Uint32.Encode(stream, encodedSetOptionsOp.ClearFlags);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.SetFlags != null)
     {
         stream.WriteInt(1);
         Uint32.Encode(stream, encodedSetOptionsOp.SetFlags);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.MasterWeight != null)
     {
         stream.WriteInt(1);
         Uint32.Encode(stream, encodedSetOptionsOp.MasterWeight);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.LowThreshold != null)
     {
         stream.WriteInt(1);
         Uint32.Encode(stream, encodedSetOptionsOp.LowThreshold);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.MedThreshold != null)
     {
         stream.WriteInt(1);
         Uint32.Encode(stream, encodedSetOptionsOp.MedThreshold);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.HighThreshold != null)
     {
         stream.WriteInt(1);
         Uint32.Encode(stream, encodedSetOptionsOp.HighThreshold);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.HomeDomain != null)
     {
         stream.WriteInt(1);
         String32.Encode(stream, encodedSetOptionsOp.HomeDomain);
     }
     else
     {
         stream.WriteInt(0);
     }
     if (encodedSetOptionsOp.Signer != null)
     {
         stream.WriteInt(1);
         Signer.Encode(stream, encodedSetOptionsOp.Signer);
     }
     else
     {
         stream.WriteInt(0);
     }
 }
예제 #13
0
            public static OperationBody Decode(XdrDataInputStream stream)
            {
                OperationBody decodedOperationBody = new OperationBody();
                OperationType discriminant         = OperationType.Decode(stream);

                decodedOperationBody.Discriminant = discriminant;
                switch (decodedOperationBody.Discriminant.InnerValue)
                {
                case OperationType.OperationTypeEnum.CREATE_ACCOUNT:
                    decodedOperationBody.CreateAccountOp = CreateAccountOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.PAYMENT:
                    decodedOperationBody.PaymentOp = PaymentOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.PATH_PAYMENT_STRICT_RECEIVE:
                    decodedOperationBody.PathPaymentStrictReceiveOp = PathPaymentStrictReceiveOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.MANAGE_SELL_OFFER:
                    decodedOperationBody.ManageSellOfferOp = ManageSellOfferOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.CREATE_PASSIVE_SELL_OFFER:
                    decodedOperationBody.CreatePassiveSellOfferOp = CreatePassiveSellOfferOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.SET_OPTIONS:
                    decodedOperationBody.SetOptionsOp = SetOptionsOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.CHANGE_TRUST:
                    decodedOperationBody.ChangeTrustOp = ChangeTrustOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.ALLOW_TRUST:
                    decodedOperationBody.AllowTrustOp = AllowTrustOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.ACCOUNT_MERGE:
                    decodedOperationBody.Destination = AccountID.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.INFLATION:
                    break;

                case OperationType.OperationTypeEnum.MANAGE_DATA:
                    decodedOperationBody.ManageDataOp = ManageDataOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.BUMP_SEQUENCE:
                    decodedOperationBody.BumpSequenceOp = BumpSequenceOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.MANAGE_BUY_OFFER:
                    decodedOperationBody.ManageBuyOfferOp = ManageBuyOfferOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.PATH_PAYMENT_STRICT_SEND:
                    decodedOperationBody.PathPaymentStrictSendOp = PathPaymentStrictSendOp.Decode(stream);
                    break;
                }

                return(decodedOperationBody);
            }
예제 #14
0
            public static void Encode(XdrDataOutputStream stream, OperationBody encodedOperationBody)
            {
                stream.WriteInt((int)encodedOperationBody.Discriminant.InnerValue);
                switch (encodedOperationBody.Discriminant.InnerValue)
                {
                case OperationType.OperationTypeEnum.CREATE_ACCOUNT:
                    CreateAccountOp.Encode(stream, encodedOperationBody.CreateAccountOp);
                    break;

                case OperationType.OperationTypeEnum.PAYMENT:
                    PaymentOp.Encode(stream, encodedOperationBody.PaymentOp);
                    break;

                case OperationType.OperationTypeEnum.PATH_PAYMENT_STRICT_RECEIVE:
                    PathPaymentStrictReceiveOp.Encode(stream, encodedOperationBody.PathPaymentStrictReceiveOp);
                    break;

                case OperationType.OperationTypeEnum.MANAGE_SELL_OFFER:
                    ManageSellOfferOp.Encode(stream, encodedOperationBody.ManageSellOfferOp);
                    break;

                case OperationType.OperationTypeEnum.CREATE_PASSIVE_SELL_OFFER:
                    CreatePassiveSellOfferOp.Encode(stream, encodedOperationBody.CreatePassiveSellOfferOp);
                    break;

                case OperationType.OperationTypeEnum.SET_OPTIONS:
                    SetOptionsOp.Encode(stream, encodedOperationBody.SetOptionsOp);
                    break;

                case OperationType.OperationTypeEnum.CHANGE_TRUST:
                    ChangeTrustOp.Encode(stream, encodedOperationBody.ChangeTrustOp);
                    break;

                case OperationType.OperationTypeEnum.ALLOW_TRUST:
                    AllowTrustOp.Encode(stream, encodedOperationBody.AllowTrustOp);
                    break;

                case OperationType.OperationTypeEnum.ACCOUNT_MERGE:
                    AccountID.Encode(stream, encodedOperationBody.Destination);
                    break;

                case OperationType.OperationTypeEnum.INFLATION:
                    break;

                case OperationType.OperationTypeEnum.MANAGE_DATA:
                    ManageDataOp.Encode(stream, encodedOperationBody.ManageDataOp);
                    break;

                case OperationType.OperationTypeEnum.BUMP_SEQUENCE:
                    BumpSequenceOp.Encode(stream, encodedOperationBody.BumpSequenceOp);
                    break;

                case OperationType.OperationTypeEnum.MANAGE_BUY_OFFER:
                    ManageBuyOfferOp.Encode(stream, encodedOperationBody.ManageBuyOfferOp);
                    break;

                case OperationType.OperationTypeEnum.PATH_PAYMENT_STRICT_SEND:
                    PathPaymentStrictSendOp.Encode(stream, encodedOperationBody.PathPaymentStrictSendOp);
                    break;
                }
            }