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 Builder(sdkxdr.PathPaymentStrictReceiveOp op)
 {
     _SendAsset   = Asset.FromXdr(op.SendAsset);
     _SendMax     = FromXdrAmount(op.SendMax.InnerValue);
     _Destination = MuxedAccount.FromXdrMuxedAccount(op.Destination);
     _DestAsset   = Asset.FromXdr(op.DestAsset);
     _DestAmount  = FromXdrAmount(op.DestAmount.InnerValue);
     _Path        = new Asset[op.Path.Length];
     for (var i = 0; i < op.Path.Length; i++)
     {
         _Path[i] = Asset.FromXdr(op.Path[i]);
     }
 }
        public static void Encode(XdrDataOutputStream stream, PathPaymentStrictReceiveOp encodedPathPaymentStrictReceiveOp)
        {
            Asset.Encode(stream, encodedPathPaymentStrictReceiveOp.SendAsset);
            Int64.Encode(stream, encodedPathPaymentStrictReceiveOp.SendMax);
            AccountID.Encode(stream, encodedPathPaymentStrictReceiveOp.Destination);
            Asset.Encode(stream, encodedPathPaymentStrictReceiveOp.DestAsset);
            Int64.Encode(stream, encodedPathPaymentStrictReceiveOp.DestAmount);
            int pathsize = encodedPathPaymentStrictReceiveOp.Path.Length;

            stream.WriteInt(pathsize);
            for (int i = 0; i < pathsize; i++)
            {
                Asset.Encode(stream, encodedPathPaymentStrictReceiveOp.Path[i]);
            }
        }
        public static PathPaymentStrictReceiveOp Decode(XdrDataInputStream stream)
        {
            PathPaymentStrictReceiveOp decodedPathPaymentStrictReceiveOp = new PathPaymentStrictReceiveOp();

            decodedPathPaymentStrictReceiveOp.SendAsset   = Asset.Decode(stream);
            decodedPathPaymentStrictReceiveOp.SendMax     = Int64.Decode(stream);
            decodedPathPaymentStrictReceiveOp.Destination = AccountID.Decode(stream);
            decodedPathPaymentStrictReceiveOp.DestAsset   = Asset.Decode(stream);
            decodedPathPaymentStrictReceiveOp.DestAmount  = Int64.Decode(stream);
            int pathsize = stream.ReadInt();

            decodedPathPaymentStrictReceiveOp.Path = new Asset[pathsize];
            for (int i = 0; i < pathsize; i++)
            {
                decodedPathPaymentStrictReceiveOp.Path[i] = Asset.Decode(stream);
            }
            return(decodedPathPaymentStrictReceiveOp);
        }
Exemplo n.º 5
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 = MuxedAccount.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;

                case OperationType.OperationTypeEnum.CREATE_CLAIMABLE_BALANCE:
                    decodedOperationBody.CreateClaimableBalanceOp = CreateClaimableBalanceOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.CLAIM_CLAIMABLE_BALANCE:
                    decodedOperationBody.ClaimClaimableBalanceOp = ClaimClaimableBalanceOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.BEGIN_SPONSORING_FUTURE_RESERVES:
                    decodedOperationBody.BeginSponsoringFutureReservesOp = BeginSponsoringFutureReservesOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.END_SPONSORING_FUTURE_RESERVES:
                    break;

                case OperationType.OperationTypeEnum.REVOKE_SPONSORSHIP:
                    decodedOperationBody.RevokeSponsorshipOp = RevokeSponsorshipOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.CLAWBACK:
                    decodedOperationBody.ClawbackOp = ClawbackOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.CLAWBACK_CLAIMABLE_BALANCE:
                    decodedOperationBody.ClawbackClaimableBalanceOp = ClawbackClaimableBalanceOp.Decode(stream);
                    break;

                case OperationType.OperationTypeEnum.SET_TRUST_LINE_FLAGS:
                    decodedOperationBody.SetTrustLineFlagsOp = SetTrustLineFlagsOp.Decode(stream);
                    break;
                }
                return(decodedOperationBody);
            }
Exemplo n.º 6
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:
                    MuxedAccount.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;

                case OperationType.OperationTypeEnum.CREATE_CLAIMABLE_BALANCE:
                    CreateClaimableBalanceOp.Encode(stream, encodedOperationBody.CreateClaimableBalanceOp);
                    break;

                case OperationType.OperationTypeEnum.CLAIM_CLAIMABLE_BALANCE:
                    ClaimClaimableBalanceOp.Encode(stream, encodedOperationBody.ClaimClaimableBalanceOp);
                    break;

                case OperationType.OperationTypeEnum.BEGIN_SPONSORING_FUTURE_RESERVES:
                    BeginSponsoringFutureReservesOp.Encode(stream, encodedOperationBody.BeginSponsoringFutureReservesOp);
                    break;

                case OperationType.OperationTypeEnum.END_SPONSORING_FUTURE_RESERVES:
                    break;

                case OperationType.OperationTypeEnum.REVOKE_SPONSORSHIP:
                    RevokeSponsorshipOp.Encode(stream, encodedOperationBody.RevokeSponsorshipOp);
                    break;

                case OperationType.OperationTypeEnum.CLAWBACK:
                    ClawbackOp.Encode(stream, encodedOperationBody.ClawbackOp);
                    break;

                case OperationType.OperationTypeEnum.CLAWBACK_CLAIMABLE_BALANCE:
                    ClawbackClaimableBalanceOp.Encode(stream, encodedOperationBody.ClawbackClaimableBalanceOp);
                    break;

                case OperationType.OperationTypeEnum.SET_TRUST_LINE_FLAGS:
                    SetTrustLineFlagsOp.Encode(stream, encodedOperationBody.SetTrustLineFlagsOp);
                    break;
                }
            }
Exemplo n.º 7
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);
            }
Exemplo n.º 8
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;
                }
            }