public static TransactionV0 Decode(XdrDataInputStream stream)
        {
            TransactionV0 decodedTransactionV0 = new TransactionV0();

            decodedTransactionV0.SourceAccountEd25519 = Uint256.Decode(stream);
            decodedTransactionV0.Fee    = Uint32.Decode(stream);
            decodedTransactionV0.SeqNum = SequenceNumber.Decode(stream);
            int TimeBoundsPresent = stream.ReadInt();

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

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

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

            decodedTransactionV0.Ext = TransactionV0Ext.Decode(stream);
            return(decodedTransactionV0);
        }
        public static void Encode(XdrDataOutputStream stream, TransactionV0 encodedTransactionV0)
        {
            Uint256.Encode(stream, encodedTransactionV0.SourceAccountEd25519);
            Uint32.Encode(stream, encodedTransactionV0.Fee);
            SequenceNumber.Encode(stream, encodedTransactionV0.SeqNum);
            if (encodedTransactionV0.TimeBounds != null)
            {
                stream.WriteInt(1);
                TimeBounds.Encode(stream, encodedTransactionV0.TimeBounds);
            }
            else
            {
                stream.WriteInt(0);
            }

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

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

            TransactionV0Ext.Encode(stream, encodedTransactionV0.Ext);
        }
Exemplo n.º 3
0
        public static DontHave Decode(XdrDataInputStream stream)
        {
            DontHave decodedDontHave = new DontHave();

            decodedDontHave.Type    = MessageType.Decode(stream);
            decodedDontHave.ReqHash = Uint256.Decode(stream);
            return(decodedDontHave);
        }
Exemplo n.º 4
0
            public static MuxedAccountMed25519 Decode(XdrDataInputStream stream)
            {
                MuxedAccountMed25519 decodedMuxedAccountMed25519 = new MuxedAccountMed25519();

                decodedMuxedAccountMed25519.Id      = Uint64.Decode(stream);
                decodedMuxedAccountMed25519.Ed25519 = Uint256.Decode(stream);
                return(decodedMuxedAccountMed25519);
            }
Exemplo n.º 5
0
        public static Uint256 Decode(XdrDataInputStream stream)
        {
            Uint256 decodedUint256 = new Uint256();
            int     uint256size    = 32;

            decodedUint256.InnerValue = new byte[uint256size];
            stream.Read(decodedUint256.InnerValue, 0, uint256size);
            return(decodedUint256);
        }
Exemplo n.º 6
0
 public static void Encode(XdrDataOutputStream stream, PublicKey encodedPublicKey)
 {
     stream.WriteInt((int)encodedPublicKey.Discriminant.InnerValue);
     switch (encodedPublicKey.Discriminant.InnerValue)
     {
     case PublicKeyType.PublicKeyTypeEnum.PUBLIC_KEY_TYPE_ED25519:
         Uint256.Encode(stream, encodedPublicKey.Ed25519);
         break;
     }
 }
Exemplo n.º 7
0
 public static void Encode(XdrDataOutputStream stream, Hello encodedHello)
 {
     Uint32.Encode(stream, encodedHello.LedgerVersion);
     Uint32.Encode(stream, encodedHello.OverlayVersion);
     Uint32.Encode(stream, encodedHello.OverlayMinVersion);
     Hash.Encode(stream, encodedHello.NetworkID);
     stream.WriteString(encodedHello.VersionStr);
     stream.WriteInt(encodedHello.ListeningPort);
     NodeID.Encode(stream, encodedHello.PeerID);
     AuthCert.Encode(stream, encodedHello.Cert);
     Uint256.Encode(stream, encodedHello.Nonce);
 }
Exemplo n.º 8
0
        /// <summary>
        ///     Creates a Uint256 from a byte hash.
        /// </summary>
        /// <param name="hash"></param>
        /// <returns>A Uint256</returns>
        private static sdkxdr.Uint256 CreateUint256(byte[] hash)
        {
            if (hash.Length != 32)
            {
                throw new ArgumentException("hash must be 32 bytes long");
            }

            var value = new sdkxdr.Uint256();

            value.InnerValue = hash;
            return(value);
        }
Exemplo n.º 9
0
        public static PublicKey Decode(XdrDataInputStream stream)
        {
            PublicKey     decodedPublicKey = new PublicKey();
            PublicKeyType discriminant     = PublicKeyType.Decode(stream);

            decodedPublicKey.Discriminant = discriminant;
            switch (decodedPublicKey.Discriminant.InnerValue)
            {
            case PublicKeyType.PublicKeyTypeEnum.PUBLIC_KEY_TYPE_ED25519:
                decodedPublicKey.Ed25519 = Uint256.Decode(stream);
                break;
            }
            return(decodedPublicKey);
        }
Exemplo n.º 10
0
        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;
            }
        }
Exemplo n.º 11
0
        public static Hello Decode(XdrDataInputStream stream)
        {
            Hello decodedHello = new Hello();

            decodedHello.LedgerVersion     = Uint32.Decode(stream);
            decodedHello.OverlayVersion    = Uint32.Decode(stream);
            decodedHello.OverlayMinVersion = Uint32.Decode(stream);
            decodedHello.NetworkID         = Hash.Decode(stream);
            decodedHello.VersionStr        = stream.ReadString();
            decodedHello.ListeningPort     = stream.ReadInt();
            decodedHello.PeerID            = NodeID.Decode(stream);
            decodedHello.Cert  = AuthCert.Decode(stream);
            decodedHello.Nonce = Uint256.Decode(stream);
            return(decodedHello);
        }
Exemplo n.º 12
0
        public static void Encode(XdrDataOutputStream stream, SignerKey encodedSignerKey)
        {
            stream.WriteInt((int)encodedSignerKey.Discriminant.InnerValue);
            switch (encodedSignerKey.Discriminant.InnerValue)
            {
            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_ED25519:
                Uint256.Encode(stream, encodedSignerKey.Ed25519);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX:
                Uint256.Encode(stream, encodedSignerKey.PreAuthTx);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_HASH_X:
                Uint256.Encode(stream, encodedSignerKey.HashX);
                break;
            }
        }
Exemplo n.º 13
0
        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);
        }
Exemplo n.º 14
0
        public static SignerKey Decode(XdrDataInputStream stream)
        {
            SignerKey     decodedSignerKey = new SignerKey();
            SignerKeyType discriminant     = SignerKeyType.Decode(stream);

            decodedSignerKey.Discriminant = discriminant;
            switch (decodedSignerKey.Discriminant.InnerValue)
            {
            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_ED25519:
                decodedSignerKey.Ed25519 = Uint256.Decode(stream);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_PRE_AUTH_TX:
                decodedSignerKey.PreAuthTx = Uint256.Decode(stream);
                break;

            case SignerKeyType.SignerKeyTypeEnum.SIGNER_KEY_TYPE_HASH_X:
                decodedSignerKey.HashX = Uint256.Decode(stream);
                break;
            }
            return(decodedSignerKey);
        }
Exemplo n.º 15
0
 public static void Encode(XdrDataOutputStream stream, MuxedAccountMed25519 encodedMuxedAccountMed25519)
 {
     Uint64.Encode(stream, encodedMuxedAccountMed25519.Id);
     Uint256.Encode(stream, encodedMuxedAccountMed25519.Ed25519);
 }
Exemplo n.º 16
0
        public static StellarMessage Decode(XdrDataInputStream stream)
        {
            StellarMessage decodedStellarMessage = new StellarMessage();
            MessageType    discriminant          = MessageType.Decode(stream);

            decodedStellarMessage.Discriminant = discriminant;
            switch (decodedStellarMessage.Discriminant.InnerValue)
            {
            case MessageType.MessageTypeEnum.ERROR_MSG:
                decodedStellarMessage.Error = Error.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.HELLO:
                decodedStellarMessage.Hello = Hello.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.AUTH:
                decodedStellarMessage.Auth = Auth.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.DONT_HAVE:
                decodedStellarMessage.DontHave = DontHave.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.GET_PEERS:
                break;

            case MessageType.MessageTypeEnum.PEERS:
                int peerssize = stream.ReadInt();
                decodedStellarMessage.Peers = new PeerAddress[peerssize];
                for (int i = 0; i < peerssize; i++)
                {
                    decodedStellarMessage.Peers[i] = PeerAddress.Decode(stream);
                }

                break;

            case MessageType.MessageTypeEnum.GET_TX_SET:
                decodedStellarMessage.TxSetHash = Uint256.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.TX_SET:
                decodedStellarMessage.TxSet = TransactionSet.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.TRANSACTION:
                decodedStellarMessage.Transaction = TransactionEnvelope.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.GET_SCP_QUORUMSET:
                decodedStellarMessage.QSetHash = Uint256.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.SCP_QUORUMSET:
                decodedStellarMessage.QSet = SCPQuorumSet.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.SCP_MESSAGE:
                decodedStellarMessage.Envelope = SCPEnvelope.Decode(stream);
                break;

            case MessageType.MessageTypeEnum.GET_SCP_STATE:
                decodedStellarMessage.GetSCPLedgerSeq = Uint32.Decode(stream);
                break;
            }

            return(decodedStellarMessage);
        }
Exemplo n.º 17
0
 public static void Encode(XdrDataOutputStream stream, DontHave encodedDontHave)
 {
     MessageType.Encode(stream, encodedDontHave.Type);
     Uint256.Encode(stream, encodedDontHave.ReqHash);
 }
Exemplo n.º 18
0
        public static void Encode(XdrDataOutputStream stream, StellarMessage encodedStellarMessage)
        {
            stream.WriteInt((int)encodedStellarMessage.Discriminant.InnerValue);
            switch (encodedStellarMessage.Discriminant.InnerValue)
            {
            case MessageType.MessageTypeEnum.ERROR_MSG:
                Error.Encode(stream, encodedStellarMessage.Error);
                break;

            case MessageType.MessageTypeEnum.HELLO:
                Hello.Encode(stream, encodedStellarMessage.Hello);
                break;

            case MessageType.MessageTypeEnum.AUTH:
                Auth.Encode(stream, encodedStellarMessage.Auth);
                break;

            case MessageType.MessageTypeEnum.DONT_HAVE:
                DontHave.Encode(stream, encodedStellarMessage.DontHave);
                break;

            case MessageType.MessageTypeEnum.GET_PEERS:
                break;

            case MessageType.MessageTypeEnum.PEERS:
                int peerssize = encodedStellarMessage.Peers.Length;
                stream.WriteInt(peerssize);
                for (int i = 0; i < peerssize; i++)
                {
                    PeerAddress.Encode(stream, encodedStellarMessage.Peers[i]);
                }

                break;

            case MessageType.MessageTypeEnum.GET_TX_SET:
                Uint256.Encode(stream, encodedStellarMessage.TxSetHash);
                break;

            case MessageType.MessageTypeEnum.TX_SET:
                TransactionSet.Encode(stream, encodedStellarMessage.TxSet);
                break;

            case MessageType.MessageTypeEnum.TRANSACTION:
                TransactionEnvelope.Encode(stream, encodedStellarMessage.Transaction);
                break;

            case MessageType.MessageTypeEnum.GET_SCP_QUORUMSET:
                Uint256.Encode(stream, encodedStellarMessage.QSetHash);
                break;

            case MessageType.MessageTypeEnum.SCP_QUORUMSET:
                SCPQuorumSet.Encode(stream, encodedStellarMessage.QSet);
                break;

            case MessageType.MessageTypeEnum.SCP_MESSAGE:
                SCPEnvelope.Encode(stream, encodedStellarMessage.Envelope);
                break;

            case MessageType.MessageTypeEnum.GET_SCP_STATE:
                Uint32.Encode(stream, encodedStellarMessage.GetSCPLedgerSeq);
                break;
            }
        }
Exemplo n.º 19
0
        public static void Encode(XdrDataOutputStream stream, Uint256 encodedUint256)
        {
            int uint256size = encodedUint256.InnerValue.Length;

            stream.Write(encodedUint256.InnerValue, 0, uint256size);
        }