Beispiel #1
0
        /// <summary>
        /// Submit a transaction to the network.
        ///
        /// This method will check if any of the destination accounts require a memo.
        /// </summary>
        /// <param name="transactionEnvelopeBase64"></param>
        /// <returns></returns>
        public Task <SubmitTransactionResponse> SubmitTransaction(string transactionEnvelopeBase64)
        {
            var options = new SubmitTransactionOptions {
                SkipMemoRequiredCheck = false
            };

            return(SubmitTransaction(transactionEnvelopeBase64, options));
        }
Beispiel #2
0
        /// <summary>
        /// Submit a transaction to the network.
        ///
        /// This method will check if any of the destination accounts require a memo.
        /// </summary>
        /// <param name="transaction"></param>
        /// <returns></returns>
        public Task <SubmitTransactionResponse> SubmitTransaction(Transaction transaction)
        {
            var options = new SubmitTransactionOptions {
                SkipMemoRequiredCheck = false
            };

            return(SubmitTransaction(transaction.ToEnvelopeXdrBase64(), options));
        }
Beispiel #3
0
        public Task <SubmitTransactionResponse> SubmitTransaction(FeeBumpTransaction feeBump)
        {
            var options = new SubmitTransactionOptions {
                FeeBumpTransaction = true
            };

            return(SubmitTransaction(feeBump.ToEnvelopeXdrBase64(), options));
        }
Beispiel #4
0
        /// <summary>
        /// Submit a transaction to the network.
        ///
        /// This method will check if any of the destination accounts require a memo.  Change the SkipMemoRequiredCheck
        /// options to change this behaviour.
        /// </summary>
        /// <param name="transactionEnvelopeBase64"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public async Task <SubmitTransactionResponse> SubmitTransaction(string transactionEnvelopeBase64, SubmitTransactionOptions options)
        {
            if (!options.SkipMemoRequiredCheck)
            {
                var tx = Transaction.FromEnvelopeXdr(transactionEnvelopeBase64);
                await CheckMemoRequired(tx);
            }

            var transactionUri = new UriBuilder(_serverUri).SetPath("/transactions").Uri;

            var paramsPairs = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("tx", transactionEnvelopeBase64)
            };

            var response = await _httpClient.PostAsync(transactionUri, new FormUrlEncodedContent(paramsPairs.ToArray()));

            if (response.Content != null)
            {
                var responseString = await response.Content.ReadAsStringAsync();

                var submitTransactionResponse = JsonSingleton.GetInstance <SubmitTransactionResponse>(responseString);
                return(submitTransactionResponse);
            }

            return(null);
        }
Beispiel #5
0
 /// <summary>
 /// Submit a transaction to the network.
 ///
 /// This method will check if any of the destination accounts require a memo.  Change the SkipMemoRequiredCheck
 /// options to change this behaviour.
 /// </summary>
 /// <param name="transaction"></param>
 /// <param name="options"></param>
 /// <returns></returns>
 public Task <SubmitTransactionResponse> SubmitTransaction(Transaction transaction, SubmitTransactionOptions options)
 {
     return(SubmitTransaction(transaction.ToEnvelopeXdrBase64(), options));
 }
Beispiel #6
0
 public Task <SubmitTransactionResponse> SubmitTransaction(FeeBumpTransaction feeBump, SubmitTransactionOptions options)
 {
     options.FeeBumpTransaction = true;
     return(SubmitTransaction(feeBump.ToEnvelopeXdrBase64(), options));
 }
Beispiel #7
0
        /// <summary>
        /// Submit a transaction to the network.
        ///
        /// This method will check if any of the destination accounts require a memo.  Change the SkipMemoRequiredCheck
        /// options to change this behaviour.
        /// </summary>
        /// <param name="transactionEnvelopeBase64"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        public async Task <SubmitTransactionResponse> SubmitTransaction(string transactionEnvelopeBase64, SubmitTransactionOptions options)
        {
            if (!options.SkipMemoRequiredCheck)
            {
                TransactionBase tx;

                if (options.FeeBumpTransaction)
                {
                    tx = FeeBumpTransaction.FromEnvelopeXdr(transactionEnvelopeBase64);
                }
                else
                {
                    tx = Transaction.FromEnvelopeXdr(transactionEnvelopeBase64);
                }

                await CheckMemoRequired(tx);
            }

            var transactionUri = new UriBuilder(_serverUri).SetPath("/transactions").Uri;

            var paramsPairs = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("tx", transactionEnvelopeBase64)
            };

            var response = await _httpClient.PostAsync(transactionUri, new FormUrlEncodedContent(paramsPairs.ToArray()));

            if (options.EnsureSuccess && !response.IsSuccessStatusCode)
            {
                string responseString = string.Empty;
                if (response.Content != null)
                {
                    responseString = await response.Content.ReadAsStringAsync();
                }

                throw new ConnectionErrorException($"Status code ({response.StatusCode}) is not success.{ (!string.IsNullOrEmpty(responseString) ? " Content: " + responseString : "") }");
            }

            if (response.Content != null)
            {
                var responseString = await response.Content.ReadAsStringAsync();

                var submitTransactionResponse = JsonSingleton.GetInstance <SubmitTransactionResponse>(responseString);
                return(submitTransactionResponse);
            }

            return(null);
        }