Example #1
0
        /// <summary>
        ///     Get unconfirmed transactions for which an account is the sender or receiver.
        /// </summary>
        /// <param name="address">The address</param>
        /// <param name="query">The query parameters</param>
        /// <returns>IObservable&lt;TransactionSearch&gt;</returns>
        public IObservable <TransactionSearch> UnconfirmedTransactions(Address address, QueryParams query = null)
        {
            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            var route = $"{BasePath}/transactions/unconfirmed";

            if (address != null)
            {
                route = route.SetQueryParam("address", address.Plain);
            }
            if (query != null)
            {
                if (query.PageSize > 0)
                {
                    route = route.SetQueryParam("pageSize", query.PageSize);
                }

                if (!string.IsNullOrEmpty(query.Id))
                {
                    route = route.SetQueryParam("id", query.Id);
                }

                switch (query.Order)
                {
                case Order.ASC:
                    route = route.SetQueryParam("ordering", "id");
                    break;

                case Order.DESC:
                    route = route.SetQueryParam("ordering", "-id");
                    break;

                default:
                    route = route.SetQueryParam("ordering", "-id");
                    break;
                }
            }
            return(Observable.FromAsync(async ar => await route.GetJsonAsync <JObject>()).Select(t => TransactionSearchMapping.Apply(t)));
        }
        /// <summary>
        ///     Get transactions information
        /// </summary>
        /// <param name="transactionType">The transaction group type</param>
        /// <param name="query">The query params</param>
        /// <returns>IObservable&lt;TransactionSearch&gt;</returns>
        public IObservable <TransactionSearch> SearchTransactions(TransactionGroupType transactionType, TransactionQueryParams query = null)
        {
            var route = $"{BasePath}/transactions/{transactionType}";

            if (query != null)
            {
                if (query.PageSize > 0)
                {
                    if (query.PageSize < 10)
                    {
                        route = route.RemoveQueryParam("pageSize");
                    }
                    else if (query.PageSize > 100)
                    {
                        route = route.SetQueryParam("pageSize", 100);
                    }
                }
                if (query.Type != 0)
                {
                    route = route.SetQueryParam("type", query.Type);
                }
                if (query.Embedded != false)
                {
                    route = route.SetQueryParam("embedded", query.Embedded);
                }
                if (query.PageNumber <= 0)
                {
                    route = route.SetQueryParam("pageNumber", 1);
                }

                if (query.Height > 0)
                {
                    if (query.ToHeight > 0)
                    {
                        route = route.RemoveQueryParam("toheight");
                    }
                    if (query.FromHeight > 0)
                    {
                        route = route.RemoveQueryParam("fromHeight");
                    }
                }
                if (query.Address != null)
                {
                    if (query.RecipientAddress != null)
                    {
                        route = route.RemoveQueryParam("recipientAddress");
                    }
                    if (query.SignerPublicKey != null)
                    {
                        route = route.RemoveQueryParam("signerPublicKey");
                    }
                }

                switch (query.Order)
                {
                case Order.ASC:
                    route = route.SetQueryParam("ordering", "id");
                    route = route.SetQueryParam("block", "meta.height");

                    break;

                case Order.DESC:
                    route = route.SetQueryParam("ordering", "-id");
                    route = route.SetQueryParam("block", "meta.height");
                    break;

                default:
                    route = route.SetQueryParam("ordering", "-id");
                    route = route.SetQueryParam("block", "meta.height");
                    break;
                }
            }
            return(Observable.FromAsync(async ar => await route.GetJsonAsync <JObject>()).Select(t => TransactionSearchMapping.Apply(t)));
        }
Example #3
0
        /// <summary>
        ///     Get outgoing transactions for which an account is the sender or receiver.
        /// </summary>
        /// <param name="account">The public account</param>
        /// <param name="query">The query parameters</param>
        /// <returns>IObservable&lt;TransactionSearch&gt;</returns>
        public IObservable <TransactionSearch> OutgoingTransactions(PublicAccount account, TransactionQueryParams query = null)
        {
            if (account == null)
            {
                throw new ArgumentNullException(nameof(account));
            }

            var route = $"{BasePath}/transactions/confirmed";

            if (account != null)
            {
                route = route.SetQueryParam("signerPublicKey", account.PublicKey);
            }
            if (query != null)
            {
                if (query.PageSize > 0)
                {
                    if (query.PageSize < 10)
                    {
                        route = route.RemoveQueryParam("pageSize");
                    }
                    else if (query.PageSize > 100)
                    {
                        route = route.SetQueryParam("pageSize", 100);
                    }
                }
                if (query.Type != 0)
                {
                    route = route.SetQueryParam("type", query.Type);
                }
                if (query.Embedded != false)
                {
                    route = route.SetQueryParam("embedded", query.Embedded);
                }
                if (query.PageNumber <= 0)
                {
                    route = route.SetQueryParam("pageNumber", 1);
                }

                if (query.Height > 0)
                {
                    if (query.ToHeight > 0)
                    {
                        route = route.RemoveQueryParam("toheight");
                    }
                    if (query.FromHeight > 0)
                    {
                        route = route.RemoveQueryParam("fromHeight");
                    }
                }
                if (query.Address != null)
                {
                    if (query.RecipientAddress != null)
                    {
                        route = route.RemoveQueryParam("recipientAddress");
                    }
                    if (query.SignerPublicKey != null)
                    {
                        route = route.RemoveQueryParam("signerPublicKey");
                    }
                }

                switch (query.Order)
                {
                case Order.ASC:
                    route = route.SetQueryParam("ordering", "id");
                    route = route.SetQueryParam("block", "meta.height");

                    break;

                case Order.DESC:
                    route = route.SetQueryParam("ordering", "-id");
                    route = route.SetQueryParam("block", "meta.height");
                    break;

                default:
                    route = route.SetQueryParam("ordering", "-id");
                    route = route.SetQueryParam("block", "meta.height");
                    break;
                }
            }
            return(Observable.FromAsync(async ar => await route.GetJsonAsync <JObject>()).Select(t => TransactionSearchMapping.Apply(t)));
        }