예제 #1
0
파일: Tx.cs 프로젝트: sshere/ShapeShift.NET
        private static async Task <List <Tx> > ParseResponseAsync(string response)
        {
            List <Tx> TxList = new List <Tx>();
            Tx        NewTx  = new Tx();

            using (JsonTextReader jtr = new JsonTextReader(new StringReader(response)))
            {
                while (await jtr.ReadAsync().ConfigureAwait(false))
                {
                    if (jtr.TokenType.ToString() == "StartObject")
                    {
                        if (!string.IsNullOrEmpty(NewTx.InputTxID))
                        {
                            TxList.Add(NewTx);
                        }
                        NewTx = new Tx();
                    }
                    else if (jtr.Value == null)
                    {
                        continue;
                    }
                    else if (jtr.Value.ToString() == "inputTXID")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.InputTxID = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "inputAddress")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.InputAddress = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "inputCurrency")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.InputCoin = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "inputAmount")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.InputAmount = Convert.ToDouble(jtr.Value.ToString());
                    }
                    else if (jtr.Value.ToString() == "outputTXID")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.OutputTxID = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "outputAddress")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.OutputAddress = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "outputCurrency")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.OutputCoin = jtr.Value.ToString();
                    }
                    else if (jtr.Value.ToString() == "outputAmount")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.OutputAmount = Convert.ToDouble(jtr.Value.ToString());
                    }
                    else if (jtr.Value.ToString() == "shiftRate")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.ShiftRate = Convert.ToDouble(jtr.Value.ToString());
                    }
                    else if (jtr.Value.ToString() == "status")
                    {
                        await jtr.ReadAsync().ConfigureAwait(false);

                        NewTx.Status =
                            jtr.Value.ToString() == "received" ? TxStatuses.Received :
                            jtr.Value.ToString() == "complete" ? TxStatuses.Complete :
                            jtr.Value.ToString() == "returned" ? TxStatuses.Returned :
                            jtr.Value.ToString() == "failed" ? TxStatuses.Failed : TxStatuses.NoDeposits;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
            if (!string.IsNullOrEmpty(NewTx.InputTxID))
            {
                TxList.Add(NewTx);
            }

            return(TxList);
        }
예제 #2
0
 /// <summary>
 /// Finds all transactions sent to specified address.
 /// </summary>
 /// <param name="Address">The address that output coin was sent to for the shift.</param>
 /// <param name="APIKey">The affiliate's PRIVATE api key.</param>
 /// <returns>List of transactions.</returns>
 public static async Task <List <Tx> > GetTransactionsAsync(string Address, string APIKey) =>
 await Tx.GetTransactionsByAddressAsync(Address, APIKey).ConfigureAwait(false);