Exemplo n.º 1
0
        public static void Encode(IByteWriter stream, Signature encodedSignature)
        {
            int SignatureSize = encodedSignature.InnerValue.Length;

            XdrEncoding.EncodeInt32(SignatureSize, stream);
            XdrEncoding.WriteFixOpaque(stream, (uint)SignatureSize, encodedSignature.InnerValue);
        }
        public static void Encode(IByteWriter stream, UpgradeType encodedUpgradeType)
        {
            int UpgradeTypeSize = encodedUpgradeType.InnerValue.Length;

            XdrEncoding.EncodeInt32(UpgradeTypeSize, stream);
            XdrEncoding.WriteFixOpaque(stream, (uint)UpgradeTypeSize, encodedUpgradeType.InnerValue);
        }
Exemplo n.º 3
0
        public static TransactionResultCode Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(TransactionResultCodeEnum.txSUCCESS));

            case -1: return(Create(TransactionResultCodeEnum.txFAILED));

            case -2: return(Create(TransactionResultCodeEnum.txTOO_EARLY));

            case -3: return(Create(TransactionResultCodeEnum.txTOO_LATE));

            case -4: return(Create(TransactionResultCodeEnum.txMISSING_OPERATION));

            case -5: return(Create(TransactionResultCodeEnum.txBAD_SEQ));

            case -6: return(Create(TransactionResultCodeEnum.txBAD_AUTH));

            case -7: return(Create(TransactionResultCodeEnum.txINSUFFICIENT_BALANCE));

            case -8: return(Create(TransactionResultCodeEnum.txNO_ACCOUNT));

            case -9: return(Create(TransactionResultCodeEnum.txINSUFFICIENT_FEE));

            case -10: return(Create(TransactionResultCodeEnum.txBAD_AUTH_EXTRA));

            case -11: return(Create(TransactionResultCodeEnum.txINTERNAL_ERROR));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Exemplo n.º 4
0
        public static PaymentResultCode Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(PaymentResultCodeEnum.PAYMENT_SUCCESS));

            case -1: return(Create(PaymentResultCodeEnum.PAYMENT_MALFORMED));

            case -2: return(Create(PaymentResultCodeEnum.PAYMENT_UNDERFUNDED));

            case -3: return(Create(PaymentResultCodeEnum.PAYMENT_SRC_NO_TRUST));

            case -4: return(Create(PaymentResultCodeEnum.PAYMENT_SRC_NOT_AUTHORIZED));

            case -5: return(Create(PaymentResultCodeEnum.PAYMENT_NO_DESTINATION));

            case -6: return(Create(PaymentResultCodeEnum.PAYMENT_NO_TRUST));

            case -7: return(Create(PaymentResultCodeEnum.PAYMENT_NOT_AUTHORIZED));

            case -8: return(Create(PaymentResultCodeEnum.PAYMENT_LINE_FULL));

            case -9: return(Create(PaymentResultCodeEnum.PAYMENT_NO_ISSUER));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Exemplo n.º 5
0
        public static Uint32 Decode(IByteReader stream)
        {
            Uint32 decodedUint32 = new Uint32();

            decodedUint32.InnerValue = XdrEncoding.DecodeUInt32(stream);
            return(decodedUint32);
        }
Exemplo n.º 6
0
        public static Memo Decode(IByteReader stream)
        {
            Memo decodedMemo = new Memo();

            decodedMemo.Discriminant = MemoType.Decode(stream);
            switch (decodedMemo.Discriminant.InnerValue)
            {
            case MemoType.MemoTypeEnum.MEMO_NONE:
                break;

            case MemoType.MemoTypeEnum.MEMO_TEXT:
                decodedMemo.Text = XdrEncoding.ReadString(stream);
                break;

            case MemoType.MemoTypeEnum.MEMO_ID:
                decodedMemo.Id = Uint64.Decode(stream);
                break;

            case MemoType.MemoTypeEnum.MEMO_HASH:
                decodedMemo.Hash = Hash.Decode(stream);
                break;

            case MemoType.MemoTypeEnum.MEMO_RETURN:
                decodedMemo.RetHash = Hash.Decode(stream);
                break;
            }
            return(decodedMemo);
        }
Exemplo n.º 7
0
        public static String32 Decode(IByteReader stream)
        {
            String32 decodedString32 = new String32();

            decodedString32.InnerValue = XdrEncoding.ReadString(stream);
            return(decodedString32);
        }
Exemplo n.º 8
0
        public static void Encode(IByteWriter stream, AccountEntry encodedAccountEntry)
        {
            AccountID.Encode(stream, encodedAccountEntry.AccountID);
            Int64.Encode(stream, encodedAccountEntry.Balance);
            SequenceNumber.Encode(stream, encodedAccountEntry.SeqNum);
            Uint32.Encode(stream, encodedAccountEntry.NumSubEntries);
            if (encodedAccountEntry.InflationDest != null)
            {
                XdrEncoding.EncodeInt32(1, stream);
                AccountID.Encode(stream, encodedAccountEntry.InflationDest);
            }
            else
            {
                XdrEncoding.EncodeInt32(0, stream);
            }
            Uint32.Encode(stream, encodedAccountEntry.Flags);
            String32.Encode(stream, encodedAccountEntry.HomeDomain);
            Thresholds.Encode(stream, encodedAccountEntry.Thresholds);
            int signerssize = encodedAccountEntry.Signers.Length;

            XdrEncoding.EncodeInt32(signerssize, stream);
            for (int i = 0; i < signerssize; i++)
            {
                Signer.Encode(stream, encodedAccountEntry.Signers[i]);
            }
            AccountEntryExt.Encode(stream, encodedAccountEntry.Ext);
        }
Exemplo n.º 9
0
 public static void Encode(IByteWriter stream, SCPStatementPrepare encodedSCPStatementPrepare)
 {
     Hash.Encode(stream, encodedSCPStatementPrepare.QuorumSetHash);
     SCPBallot.Encode(stream, encodedSCPStatementPrepare.Ballot);
     if (encodedSCPStatementPrepare.Prepared != null)
     {
         XdrEncoding.EncodeInt32(1, stream);
         SCPBallot.Encode(stream, encodedSCPStatementPrepare.Prepared);
     }
     else
     {
         XdrEncoding.EncodeInt32(0, stream);
     }
     if (encodedSCPStatementPrepare.PreparedPrime != null)
     {
         XdrEncoding.EncodeInt32(1, stream);
         SCPBallot.Encode(stream, encodedSCPStatementPrepare.PreparedPrime);
     }
     else
     {
         XdrEncoding.EncodeInt32(0, stream);
     }
     Uint32.Encode(stream, encodedSCPStatementPrepare.NC);
     Uint32.Encode(stream, encodedSCPStatementPrepare.NH);
 }
Exemplo n.º 10
0
        public static OperationType Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(OperationTypeEnum.CREATE_ACCOUNT));

            case 1: return(Create(OperationTypeEnum.PAYMENT));

            case 2: return(Create(OperationTypeEnum.PATH_PAYMENT));

            case 3: return(Create(OperationTypeEnum.MANAGE_OFFER));

            case 4: return(Create(OperationTypeEnum.CREATE_PASSIVE_OFFER));

            case 5: return(Create(OperationTypeEnum.SET_OPTIONS));

            case 6: return(Create(OperationTypeEnum.CHANGE_TRUST));

            case 7: return(Create(OperationTypeEnum.ALLOW_TRUST));

            case 8: return(Create(OperationTypeEnum.ACCOUNT_MERGE));

            case 9: return(Create(OperationTypeEnum.INFLATION));

            case 10: return(Create(OperationTypeEnum.MANAGE_DATA));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Exemplo n.º 11
0
        public static void Encode(IByteWriter stream, Memo encodedMemo)
        {
            XdrEncoding.EncodeInt32((int)encodedMemo.Discriminant.InnerValue, stream);
            switch (encodedMemo.Discriminant.InnerValue)
            {
            case MemoType.MemoTypeEnum.MEMO_NONE:
                break;

            case MemoType.MemoTypeEnum.MEMO_TEXT:
                XdrEncoding.WriteString(stream, encodedMemo.Text);
                break;

            case MemoType.MemoTypeEnum.MEMO_ID:
                Uint64.Encode(stream, encodedMemo.Id);
                break;

            case MemoType.MemoTypeEnum.MEMO_HASH:
                Hash.Encode(stream, encodedMemo.Hash);
                break;

            case MemoType.MemoTypeEnum.MEMO_RETURN:
                Hash.Encode(stream, encodedMemo.RetHash);
                break;
            }
        }
Exemplo n.º 12
0
        public static Uint64 Decode(IByteReader stream)
        {
            Uint64 decodedUint64 = new Uint64();

            decodedUint64.InnerValue = XdrEncoding.DecodeUInt64(stream);
            return(decodedUint64);
        }
Exemplo n.º 13
0
        public static String64 Decode(IByteReader stream)
        {
            String64 decodedString64 = new String64();

            decodedString64.InnerValue = XdrEncoding.ReadString(stream);
            return(decodedString64);
        }
Exemplo n.º 14
0
        public static SetOptionsResultCode Decode(IByteReader stream)
        {
            int value = XdrEncoding.DecodeInt32(stream);

            switch (value)
            {
            case 0: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_SUCCESS));

            case -1: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_LOW_RESERVE));

            case -2: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_TOO_MANY_SIGNERS));

            case -3: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_BAD_FLAGS));

            case -4: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_INVALID_INFLATION));

            case -5: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_CANT_CHANGE));

            case -6: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_UNKNOWN_FLAG));

            case -7: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_THRESHOLD_OUT_OF_RANGE));

            case -8: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_BAD_SIGNER));

            case -9: return(Create(SetOptionsResultCodeEnum.SET_OPTIONS_INVALID_HOME_DOMAIN));

            default:
                throw new System.Exception("Unknown enum value: " + value);
            }
        }
Exemplo n.º 15
0
        public static void Encode(IByteWriter stream, Value encodedValue)
        {
            int ValueSize = encodedValue.InnerValue.Length;

            XdrEncoding.EncodeInt32(ValueSize, stream);
            XdrEncoding.WriteFixOpaque(stream, (uint)ValueSize, encodedValue.InnerValue);
        }
Exemplo n.º 16
0
        public static AccountEntry Decode(IByteReader stream)
        {
            AccountEntry decodedAccountEntry = new AccountEntry();

            decodedAccountEntry.AccountID     = AccountID.Decode(stream);
            decodedAccountEntry.Balance       = Int64.Decode(stream);
            decodedAccountEntry.SeqNum        = SequenceNumber.Decode(stream);
            decodedAccountEntry.NumSubEntries = Uint32.Decode(stream);
            int inflationDestPresent = XdrEncoding.DecodeInt32(stream);

            if (inflationDestPresent != 0)
            {
                decodedAccountEntry.InflationDest = AccountID.Decode(stream);
            }
            decodedAccountEntry.Flags      = Uint32.Decode(stream);
            decodedAccountEntry.HomeDomain = String32.Decode(stream);
            decodedAccountEntry.Thresholds = Thresholds.Decode(stream);
            int signerssize = XdrEncoding.DecodeInt32(stream);

            decodedAccountEntry.Signers = new Signer[signerssize];
            for (int i = 0; i < signerssize; i++)
            {
                decodedAccountEntry.Signers[i] = Signer.Decode(stream);
            }
            decodedAccountEntry.Ext = AccountEntryExt.Decode(stream);
            return(decodedAccountEntry);
        }
Exemplo n.º 17
0
            public static void Encode(IByteWriter stream, AssetAlphaNum4 encodedAssetAlphaNum4)
            {
                int assetCodesize = encodedAssetAlphaNum4.AssetCode.Length;

                XdrEncoding.WriteFixOpaque(stream, (uint)assetCodesize, encodedAssetAlphaNum4.AssetCode);
                AccountID.Encode(stream, encodedAssetAlphaNum4.Issuer);
            }
Exemplo n.º 18
0
        public static Auth Decode(IByteReader stream)
        {
            Auth decodedAuth = new Auth();

            decodedAuth.Unused = XdrEncoding.DecodeInt32(stream);
            return(decodedAuth);
        }
Exemplo n.º 19
0
        public static SetOptionsOp Decode(IByteReader stream)
        {
            SetOptionsOp decodedSetOptionsOp  = new SetOptionsOp();
            int          inflationDestPresent = XdrEncoding.DecodeInt32(stream);

            if (inflationDestPresent != 0)
            {
                decodedSetOptionsOp.InflationDest = AccountID.Decode(stream);
            }
            int clearFlagsPresent = XdrEncoding.DecodeInt32(stream);

            if (clearFlagsPresent != 0)
            {
                decodedSetOptionsOp.ClearFlags = Uint32.Decode(stream);
            }
            int setFlagsPresent = XdrEncoding.DecodeInt32(stream);

            if (setFlagsPresent != 0)
            {
                decodedSetOptionsOp.SetFlags = Uint32.Decode(stream);
            }
            int masterWeightPresent = XdrEncoding.DecodeInt32(stream);

            if (masterWeightPresent != 0)
            {
                decodedSetOptionsOp.MasterWeight = Uint32.Decode(stream);
            }
            int lowThresholdPresent = XdrEncoding.DecodeInt32(stream);

            if (lowThresholdPresent != 0)
            {
                decodedSetOptionsOp.LowThreshold = Uint32.Decode(stream);
            }
            int medThresholdPresent = XdrEncoding.DecodeInt32(stream);

            if (medThresholdPresent != 0)
            {
                decodedSetOptionsOp.MedThreshold = Uint32.Decode(stream);
            }
            int highThresholdPresent = XdrEncoding.DecodeInt32(stream);

            if (highThresholdPresent != 0)
            {
                decodedSetOptionsOp.HighThreshold = Uint32.Decode(stream);
            }
            int homeDomainPresent = XdrEncoding.DecodeInt32(stream);

            if (homeDomainPresent != 0)
            {
                decodedSetOptionsOp.HomeDomain = String32.Decode(stream);
            }
            int signerPresent = XdrEncoding.DecodeInt32(stream);

            if (signerPresent != 0)
            {
                decodedSetOptionsOp.Signer = Signer.Decode(stream);
            }
            return(decodedSetOptionsOp);
        }
Exemplo n.º 20
0
        public static Error Decode(IByteReader stream)
        {
            Error decodedError = new Error();

            decodedError.Code = ErrorCode.Decode(stream);
            decodedError.Msg  = XdrEncoding.ReadString(stream);
            return(decodedError);
        }
Exemplo n.º 21
0
        public static Curve25519Public Decode(IByteReader stream)
        {
            Curve25519Public decodedCurve25519Public = new Curve25519Public();
            int keysize = 32;

            decodedCurve25519Public.Key = XdrEncoding.ReadFixOpaque(stream, (uint)keysize);
            return(decodedCurve25519Public);
        }
Exemplo n.º 22
0
        public static Curve25519Secret Decode(IByteReader stream)
        {
            Curve25519Secret decodedCurve25519Secret = new Curve25519Secret();
            int keysize = 32;

            decodedCurve25519Secret.Key = XdrEncoding.ReadFixOpaque(stream, (uint)keysize);
            return(decodedCurve25519Secret);
        }
Exemplo n.º 23
0
        public static HmacSha256Key Decode(IByteReader stream)
        {
            HmacSha256Key decodedHmacSha256Key = new HmacSha256Key();
            int           keysize = 32;

            decodedHmacSha256Key.Key = XdrEncoding.ReadFixOpaque(stream, (uint)keysize);
            return(decodedHmacSha256Key);
        }
Exemplo n.º 24
0
        public static Thresholds Decode(IByteReader stream)
        {
            Thresholds decodedThresholds = new Thresholds();
            int        Thresholdssize    = 4;

            decodedThresholds.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Thresholdssize);
            return(decodedThresholds);
        }
Exemplo n.º 25
0
        public static Signature Decode(IByteReader stream)
        {
            Signature decodedSignature = new Signature();
            int       Signaturesize    = XdrEncoding.DecodeInt32(stream);

            decodedSignature.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Signaturesize);
            return(decodedSignature);
        }
Exemplo n.º 26
0
        public static HmacSha256Mac Decode(IByteReader stream)
        {
            HmacSha256Mac decodedHmacSha256Mac = new HmacSha256Mac();
            int           macsize = 32;

            decodedHmacSha256Mac.Mac = XdrEncoding.ReadFixOpaque(stream, (uint)macsize);
            return(decodedHmacSha256Mac);
        }
Exemplo n.º 27
0
        public static Value Decode(IByteReader stream)
        {
            Value decodedValue = new Value();
            int   Valuesize    = XdrEncoding.DecodeInt32(stream);

            decodedValue.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Valuesize);
            return(decodedValue);
        }
Exemplo n.º 28
0
        public static UpgradeType Decode(IByteReader stream)
        {
            UpgradeType decodedUpgradeType = new UpgradeType();
            int         UpgradeTypesize    = XdrEncoding.DecodeInt32(stream);

            decodedUpgradeType.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)UpgradeTypesize);
            return(decodedUpgradeType);
        }
Exemplo n.º 29
0
        public static Hash Decode(IByteReader stream)
        {
            Hash decodedHash = new Hash();
            int  Hashsize    = 32;

            decodedHash.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)Hashsize);
            return(decodedHash);
        }
Exemplo n.º 30
0
        public static Uint256 Decode(IByteReader stream)
        {
            Uint256 decodedUint256 = new Uint256();
            int     uint256size    = 32;

            decodedUint256.InnerValue = XdrEncoding.ReadFixOpaque(stream, (uint)uint256size);
            return(decodedUint256);
        }