public IActionResult GetColdStakingInfo([FromQuery] GetColdStakingInfoRequest request)
        {
            Guard.NotNull(request, nameof(request));

            this.logger.LogDebug("({0}:'{1}')", nameof(request), request);

            // Checks that the request is valid.
            if (!this.ModelState.IsValid)
            {
                this.logger.LogTrace("(-)[MODEL_STATE_INVALID]");
                return(ModelStateErrors.BuildErrorResponse(this.ModelState));
            }

            try
            {
                GetColdStakingInfoResponse model = this.ColdStakingManager.GetColdStakingInfo(request.WalletName);

                this.logger.LogTrace("(-):'{0}'", model);
                return(this.Json(model));
            }
            catch (Exception e)
            {
                this.logger.LogError("Exception occurred: {0}", e.ToString());
                this.logger.LogTrace("(-)[ERROR]");
                return(ErrorHelpers.BuildErrorResponse(HttpStatusCode.BadRequest, e.Message, e.ToString()));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Returns information related to cold staking.
        /// </summary>
        /// <param name="walletName">The wallet to return the information for.</param>
        /// <returns>A <see cref="GetColdStakingInfoResponse"/> object containing the information.</returns>
        public GetColdStakingInfoResponse GetColdStakingInfo(string walletName)
        {
            Wallet.Types.Wallet wallet = this.GetWalletByName(walletName);

            var response = new GetColdStakingInfoResponse()
            {
                ColdWalletAccountExists = this.GetColdStakingAccount(wallet, true) != null,
                HotWalletAccountExists  = this.GetColdStakingAccount(wallet, false) != null
            };

            this.logger.LogTrace("(-):'{0}'", response);
            return(response);
        }
Esempio n. 3
0
        /// <summary>
        ///     Returns information related to cold staking.
        /// </summary>
        /// <param name="walletName">The wallet to return the information for.</param>
        /// <returns>A <see cref="Models.GetColdStakingInfoResponse" /> object containing the information.</returns>
        internal GetColdStakingInfoResponse GetColdStakingInfo(string walletName)
        {
            var wallet = GetWalletByName(walletName);

            var response = new GetColdStakingInfoResponse
            {
                ColdWalletAccountExists = GetColdStakingAccount(wallet, true) != null,
                HotWalletAccountExists  = GetColdStakingAccount(wallet, false) != null
            };

            this.logger.LogTrace("(-):'{0}'", response);
            return(response);
        }