public async Task <ActionResult <FeeQuoteViewModelGet> > GetFeeQuote()
        {
            if (!IdentityProviderStore.GetUserAndIssuer(User, Request.Headers, out var identity))
            {
                return(Unauthorized("Incorrectly formatted token"));
            }

            logger.LogInformation($"Get FeeQuote for user { ((identity == null) ? "/" : identity.ToString() )} ...");
            FeeQuote feeQuote = feeQuoteRepository.GetCurrentFeeQuoteByIdentity(identity);


            if (feeQuote == null)
            {
                logger.LogInformation($"There are no active feeQuotes.");

                return(NotFound());
            }

            var feeQuoteViewModelGet = new FeeQuoteViewModelGet(feeQuote, callbackIPAddressesArray)
            {
                Timestamp = clock.UtcNow(),
            };

            return(await FillFeeQuoteViewModelWithInfo(feeQuoteViewModelGet));
        }
Beispiel #2
0
        public async Task <ActionResult <FeeQuoteViewModelGet> > GetFeeQuote()
        {
            if (!IdentityProviderStore.GetUserAndIssuer(User, Request.Headers, out var identity))
            {
                return(Unauthorized("Incorrectly formatted token"));
            }

            logger.LogInformation($"Get FeeQuote for user { ((identity == null) ? "/" : identity.ToString() )} ...");
            FeeQuote feeQuote = feeQuoteRepository.GetCurrentFeeQuoteByIdentity(identity);


            if (feeQuote == null)
            {
                logger.LogInformation($"There are no active feeQuotes.");

                return(NotFound());
            }

            var feeQuoteViewModelGet = new FeeQuoteViewModelGet(feeQuote)
            {
                Timestamp = clock.UtcNow(),
            };

            feeQuoteViewModelGet.ExpiryTime = feeQuoteViewModelGet.Timestamp.Add(TimeSpan.FromMinutes(quoteExpiryMinutes));

            var info = blockChainInfo.GetInfo();

            feeQuoteViewModelGet.MinerId = await minerId.GetCurrentMinerIdAsync();

            feeQuoteViewModelGet.CurrentHighestBlockHash   = info.BestBlockHash;
            feeQuoteViewModelGet.CurrentHighestBlockHeight = info.BestBlockHeight;

            logger.LogInformation($"Returning feeQuote with ExpiryTime: {feeQuoteViewModelGet.ExpiryTime}.");

            return(await SignIfRequiredAsync(feeQuoteViewModelGet, feeQuoteViewModelGet.MinerId));
        }