public static void Encode(XdrDataOutputStream stream, FeeBumpTransaction encodedFeeBumpTransaction)
 {
     MuxedAccount.Encode(stream, encodedFeeBumpTransaction.FeeSource);
     Int64.Encode(stream, encodedFeeBumpTransaction.Fee);
     FeeBumpTransactionInnerTx.Encode(stream, encodedFeeBumpTransaction.InnerTx);
     FeeBumpTransactionExt.Encode(stream, encodedFeeBumpTransaction.Ext);
 }
Beispiel #2
0
        public static Transaction Decode(XdrDataInputStream stream)
        {
            Transaction decodedTransaction = new Transaction();

            decodedTransaction.SourceAccount = MuxedAccount.Decode(stream);
            decodedTransaction.Fee           = Uint32.Decode(stream);
            decodedTransaction.SeqNum        = SequenceNumber.Decode(stream);
            int TimeBoundsPresent = stream.ReadInt();

            if (TimeBoundsPresent != 0)
            {
                decodedTransaction.TimeBounds = TimeBounds.Decode(stream);
            }

            decodedTransaction.Memo = Memo.Decode(stream);
            int operationssize = stream.ReadInt();

            decodedTransaction.Operations = new Operation[operationssize];
            for (int i = 0; i < operationssize; i++)
            {
                decodedTransaction.Operations[i] = Operation.Decode(stream);
            }

            decodedTransaction.Ext = TransactionExt.Decode(stream);
            return(decodedTransaction);
        }
Beispiel #3
0
        public static void Encode(XdrDataOutputStream stream, Transaction encodedTransaction)
        {
            MuxedAccount.Encode(stream, encodedTransaction.SourceAccount);
            Uint32.Encode(stream, encodedTransaction.Fee);
            SequenceNumber.Encode(stream, encodedTransaction.SeqNum);
            if (encodedTransaction.TimeBounds != null)
            {
                stream.WriteInt(1);
                TimeBounds.Encode(stream, encodedTransaction.TimeBounds);
            }
            else
            {
                stream.WriteInt(0);
            }

            Memo.Encode(stream, encodedTransaction.Memo);
            int operationssize = encodedTransaction.Operations.Length;

            stream.WriteInt(operationssize);
            for (int i = 0; i < operationssize; i++)
            {
                Operation.Encode(stream, encodedTransaction.Operations[i]);
            }

            TransactionExt.Encode(stream, encodedTransaction.Ext);
        }
        public static ClawbackOp Decode(XdrDataInputStream stream)
        {
            ClawbackOp decodedClawbackOp = new ClawbackOp();

            decodedClawbackOp.Asset  = Asset.Decode(stream);
            decodedClawbackOp.From   = MuxedAccount.Decode(stream);
            decodedClawbackOp.Amount = Int64.Decode(stream);
            return(decodedClawbackOp);
        }
Beispiel #5
0
        public static PaymentOp Decode(XdrDataInputStream stream)
        {
            PaymentOp decodedPaymentOp = new PaymentOp();

            decodedPaymentOp.Destination = MuxedAccount.Decode(stream);
            decodedPaymentOp.Asset       = Asset.Decode(stream);
            decodedPaymentOp.Amount      = Int64.Decode(stream);
            return(decodedPaymentOp);
        }
            public static OperationIDId Decode(XdrDataInputStream stream)
            {
                OperationIDId decodedOperationIDId = new OperationIDId();

                decodedOperationIDId.SourceAccount = MuxedAccount.Decode(stream);
                decodedOperationIDId.SeqNum        = SequenceNumber.Decode(stream);
                decodedOperationIDId.OpNum         = Uint32.Decode(stream);
                return(decodedOperationIDId);
            }
        public static FeeBumpTransaction Decode(XdrDataInputStream stream)
        {
            FeeBumpTransaction decodedFeeBumpTransaction = new FeeBumpTransaction();

            decodedFeeBumpTransaction.FeeSource = MuxedAccount.Decode(stream);
            decodedFeeBumpTransaction.Fee       = Int64.Decode(stream);
            decodedFeeBumpTransaction.InnerTx   = FeeBumpTransactionInnerTx.Decode(stream);
            decodedFeeBumpTransaction.Ext       = FeeBumpTransactionExt.Decode(stream);
            return(decodedFeeBumpTransaction);
        }
Beispiel #8
0
        public static Operation Decode(XdrDataInputStream stream)
        {
            Operation decodedOperation     = new Operation();
            int       SourceAccountPresent = stream.ReadInt();

            if (SourceAccountPresent != 0)
            {
                decodedOperation.SourceAccount = MuxedAccount.Decode(stream);
            }
            decodedOperation.Body = OperationBody.Decode(stream);
            return(decodedOperation);
        }
Beispiel #9
0
 public static void Encode(XdrDataOutputStream stream, Operation encodedOperation)
 {
     if (encodedOperation.SourceAccount != null)
     {
         stream.WriteInt(1);
         MuxedAccount.Encode(stream, encodedOperation.SourceAccount);
     }
     else
     {
         stream.WriteInt(0);
     }
     OperationBody.Encode(stream, encodedOperation.Body);
 }
        public static IAccountId FromXdrMuxedAccount(xdr.MuxedAccount muxedAccount)
        {
            switch (muxedAccount.Discriminant.InnerValue)
            {
            case CryptoKeyType.CryptoKeyTypeEnum.KEY_TYPE_ED25519:
                return(KeyPair.FromPublicKey(muxedAccount.Ed25519.InnerValue));

            case CryptoKeyType.CryptoKeyTypeEnum.KEY_TYPE_MUXED_ED25519:
                return(MuxedAccountMed25519.FromMuxedAccountXdr(muxedAccount.Med25519));

            default:
                throw new InvalidOperationException("Invalid MuxedAccount type");
            }
        }
        public static void Encode(XdrDataOutputStream stream, MuxedAccount encodedMuxedAccount)
        {
            stream.WriteInt((int)encodedMuxedAccount.Discriminant.InnerValue);
            switch (encodedMuxedAccount.Discriminant.InnerValue)
            {
            case CryptoKeyType.CryptoKeyTypeEnum.KEY_TYPE_ED25519:
                Uint256.Encode(stream, encodedMuxedAccount.Ed25519);
                break;

            case CryptoKeyType.CryptoKeyTypeEnum.KEY_TYPE_MUXED_ED25519:
                MuxedAccountMed25519.Encode(stream, encodedMuxedAccount.Med25519);
                break;
            }
        }
Beispiel #12
0
        public static void Encode(XdrDataOutputStream stream, PathPaymentStrictReceiveOp encodedPathPaymentStrictReceiveOp)
        {
            Asset.Encode(stream, encodedPathPaymentStrictReceiveOp.SendAsset);
            Int64.Encode(stream, encodedPathPaymentStrictReceiveOp.SendMax);
            MuxedAccount.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]);
            }
        }
Beispiel #13
0
        public static PathPaymentStrictReceiveOp Decode(XdrDataInputStream stream)
        {
            PathPaymentStrictReceiveOp decodedPathPaymentStrictReceiveOp = new PathPaymentStrictReceiveOp();

            decodedPathPaymentStrictReceiveOp.SendAsset   = Asset.Decode(stream);
            decodedPathPaymentStrictReceiveOp.SendMax     = Int64.Decode(stream);
            decodedPathPaymentStrictReceiveOp.Destination = MuxedAccount.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);
        }
        public static MuxedAccount Decode(XdrDataInputStream stream)
        {
            MuxedAccount  decodedMuxedAccount = new MuxedAccount();
            CryptoKeyType discriminant        = CryptoKeyType.Decode(stream);

            decodedMuxedAccount.Discriminant = discriminant;
            switch (decodedMuxedAccount.Discriminant.InnerValue)
            {
            case CryptoKeyType.CryptoKeyTypeEnum.KEY_TYPE_ED25519:
                decodedMuxedAccount.Ed25519 = Uint256.Decode(stream);
                break;

            case CryptoKeyType.CryptoKeyTypeEnum.KEY_TYPE_MUXED_ED25519:
                decodedMuxedAccount.Med25519 = MuxedAccountMed25519.Decode(stream);
                break;
            }
            return(decodedMuxedAccount);
        }
Beispiel #15
0
 public static void Encode(XdrDataOutputStream stream, PaymentOp encodedPaymentOp)
 {
     MuxedAccount.Encode(stream, encodedPaymentOp.Destination);
     Asset.Encode(stream, encodedPaymentOp.Asset);
     Int64.Encode(stream, encodedPaymentOp.Amount);
 }
Beispiel #16
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);
            }
Beispiel #17
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;
                }
            }
Beispiel #18
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;
                }
            }
Beispiel #19
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;
                }

                return(decodedOperationBody);
            }
 public static void Encode(XdrDataOutputStream stream, ClawbackOp encodedClawbackOp)
 {
     Asset.Encode(stream, encodedClawbackOp.Asset);
     MuxedAccount.Encode(stream, encodedClawbackOp.From);
     Int64.Encode(stream, encodedClawbackOp.Amount);
 }
 public static void Encode(XdrDataOutputStream stream, OperationIDId encodedOperationIDId)
 {
     MuxedAccount.Encode(stream, encodedOperationIDId.SourceAccount);
     SequenceNumber.Encode(stream, encodedOperationIDId.SeqNum);
     Uint32.Encode(stream, encodedOperationIDId.OpNum);
 }