Commit 9b7ec9a4 authored by Clint.Network's avatar Clint.Network

Adding API Block Explorer Endpoint

parent 44370321
using System;
using System.Security.Cryptography.X509Certificates;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using NBitcoin;
using NBitcoin.Networks;
using Newtonsoft.Json;
using RestSharp;
using Stratis.Guru.Models;
using Stratis.Guru.Settings;
using RestClient = NBitcoin.RPC.RestClient;
namespace Stratis.Guru.Controllers
{
......@@ -10,11 +17,13 @@ namespace Stratis.Guru.Controllers
[ApiController]
public class ApiController : ControllerBase
{
private readonly NakoApiSettings _nakoApiSettings;
private readonly IMemoryCache _memoryCache;
public ApiController(IMemoryCache memoryCache)
public ApiController(IMemoryCache memoryCache, IOptions<NakoApiSettings> nakoApiSettings)
{
_memoryCache = memoryCache;
_nakoApiSettings = nakoApiSettings.Value;
}
[HttpGet]
......@@ -44,5 +53,43 @@ namespace Stratis.Guru.Controllers
return null;
}
}
[HttpGet]
[Route("create-address")]
public ActionResult<object> CreateAddress()
{
var key = new Key();
return new{PublicKey=key.PubKey.GetAddress(new StratisMain()).ToString(), PrivateKey=key.GetWif(new StratisMain()).ToString()};
}
[HttpGet]
[Route("address/{address}")]
public ActionResult<object> Address(string address)
{
var endpointClient = new RestSharp.RestClient($"{_nakoApiSettings.Endpoint}query/address/{address}/transactions");
var enpointRequest = new RestRequest(Method.GET);
var endpointResponse = endpointClient.Execute(enpointRequest);
return JsonConvert.DeserializeObject(endpointResponse.Content);
}
[HttpGet]
[Route("transaction/{transaction}")]
public ActionResult<object> Transaction(string transaction)
{
var endpointClient = new RestSharp.RestClient($"{_nakoApiSettings.Endpoint}query/transaction/{transaction}");
var enpointRequest = new RestRequest(Method.GET);
var endpointResponse = endpointClient.Execute(enpointRequest);
return JsonConvert.DeserializeObject(endpointResponse.Content);
}
[HttpGet]
[Route("block/{block}")]
public ActionResult<object> Block(string block)
{
var endpointClient = new RestSharp.RestClient($"{_nakoApiSettings.Endpoint}query/block/index/{block}/transactions");
var enpointRequest = new RestRequest(Method.GET);
var endpointResponse = endpointClient.Execute(enpointRequest);
return JsonConvert.DeserializeObject(endpointResponse.Content);
}
}
}
\ No newline at end of file
......@@ -45,6 +45,7 @@
<li><a asp-action="Index" asp-controller="BlockExplorer"><i class="fa fa-cube"></i> BLOCK EXPLORER</a></li>
<li><a asp-action="Vanity" asp-controller="Home"><i class="fa fa-at"></i> VANITY</a></li>
<li><a asp-action="Generator" asp-controller="Home"><i class="fa fa-qrcode"></i> ADDRESS GENERATOR</a></li>
<li><a asp-action="API" asp-controller="Home"><i class="fa fa-book"></i> API</a></li>
<li><a asp-action="About" asp-controller="Home"><i class="fa fa-info-circle"></i> ABOUT STRATIS.GURU</a></li>
@*<li><a asp-action="Contact" asp-controller="Home"><i class="fa fa-envelope"></i> CONTACT</a></li>*@
</ul>
......
This diff is collapsed.
(function(n){"use strict";function t(){}n(document).ready(function(){if(NProgress.start(),$('[data-toggle="tooltip"]').tooltip(),$(".copy-me").click(function(){$(this).parent().find(".to-copy").select();document.execCommand("copy")}),t(),n(".menu-trigger").length&&n(".menu-trigger").click(function(){n(this).toggleClass("active");n(".header-area .nav").slideToggle(200)}),n("body").click(function(t){var i=t.target;if(!n(i).parents(".flag-list").length&&!n(i).hasClass("flag-list")){if(n(".flag-list").css("display")==="block"){n(".flag-list").css("display","none");return}(n(i).hasClass("selected")||n(i).parents(".selected").length)&&n(".flag-list").css("display","block")}}),n(".countdown").length&&n(".countdown").downCount({date:"09/29/2018 12:00:00",offset:10}),n(".token .token-input").length&&(n(".token .token-input .fa-plus").click(function(){var t=n(this).parent().find("input").val(),r=n(this).parent().find("input").data("step"),i;t==""&&(t=0);i=parseInt(t,10)+parseInt(r,10);n(this).parent().find("input").val(i)}),n(".token .token-input .fa-minus").click(function(){var i=n(this).parent().find("input").val(),r=n(this).parent().find("input").data("step"),t;i==""&&(i=0);t=parseInt(i,10)-parseInt(r,10);t<=0&&(t=r);n(this).parent().find("input").val(t)})),window.sr=new scrollReveal,n("a[href*=#]:not([href=#])").click(function(){var t,i;if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname&&(t=n(this.hash),t=t.length?t:n("[name="+this.hash.slice(1)+"]"),t.length))return i=n(window).width(),i<991&&(n(".menu-trigger").removeClass("active"),n(".header-area .nav").slideUp(200)),n("html,body").animate({scrollTop:t.offset().top-30},700),!1}),n(".token-progress ul").length){n(".token-progress ul").find(".item").each(function(t){n(".token-progress ul .item:eq("+[t]+")").css("left",n(".token-progress ul .item:eq("+[t]+")").data("position"))});var i=n(".token-progress ul .progress-active").data("progress");n(".token-progress ul .progress-active").css("width",i)}n(".table-progress").length&&n(".table-latests").find(".table-progress").each(function(t){n(".table-progress:eq("+[t]+") .progress-line").css("width",parseInt(n(".table-progress:eq("+[t]+") .progress-line").data("value"),10)+parseInt(70,10)+"%")});n(".roadmap-modern-wrapper").length&&n(".roadmap-modern-wrapper").owlCarousel({loop:!0,margin:30,nav:!1,responsive:{0:{items:1},600:{items:2},1e3:{items:3}}});n(".roadmap-lux-wrapper").length&&n(".roadmap-lux-wrapper").owlCarousel({loop:!0,margin:30,nav:!1,responsive:{0:{items:1},600:{items:2},1e3:{items:3}}})});n(window).load(function(){n(".loading-wrapper").animate({opacity:"0"},600,function(){setTimeout(function(){n(".loading-wrapper").css("visibility","hidden").fadeOut();n(".parallax").length&&n(".parallax").parallax({imageSrc:"assets/images/parallax.jpg",zIndex:"1"})},300)})});n(window).scroll(function(){alert("ok")});n(window).resize(function(){t()})})(jQuery);
\ No newline at end of file
(function(n){"use strict";function t(){}n(document).ready(function(){if(NProgress.start(),$('[data-toggle="tooltip"]').tooltip(),$(".copy-me").click(function(){$(this).parent().find(".to-copy").select();document.execCommand("copy")}),t(),n(".menu-trigger").length&&n(".menu-trigger").click(function(){n(this).toggleClass("active");n(".header-area .nav").slideToggle(200)}),n("body").click(function(t){var i=t.target;if(!n(i).parents(".flag-list").length&&!n(i).hasClass("flag-list")){if(n(".flag-list").css("display")==="block"){n(".flag-list").css("display","none");return}(n(i).hasClass("selected")||n(i).parents(".selected").length)&&n(".flag-list").css("display","block")}}),n(".countdown").length&&n(".countdown").downCount({date:"09/29/2018 12:00:00",offset:10}),n(".token .token-input").length&&(n(".token .token-input .fa-plus").click(function(){var t=n(this).parent().find("input").val(),r=n(this).parent().find("input").data("step"),i;t==""&&(t=0);i=parseInt(t,10)+parseInt(r,10);n(this).parent().find("input").val(i)}),n(".token .token-input .fa-minus").click(function(){var i=n(this).parent().find("input").val(),r=n(this).parent().find("input").data("step"),t;i==""&&(i=0);t=parseInt(i,10)-parseInt(r,10);t<=0&&(t=r);n(this).parent().find("input").val(t)})),window.sr=new scrollReveal,n("a[href*=#]:not([href=#])").click(function(){var t,i;if(location.pathname.replace(/^\//,"")==this.pathname.replace(/^\//,"")&&location.hostname==this.hostname&&(t=n(this.hash),t=t.length?t:n("[name="+this.hash.slice(1)+"]"),t.length))return i=n(window).width(),i<991&&(n(".menu-trigger").removeClass("active"),n(".header-area .nav").slideUp(200)),n("html,body").animate({scrollTop:t.offset().top-30},700),!1}),n(".token-progress ul").length){n(".token-progress ul").find(".item").each(function(t){n(".token-progress ul .item:eq("+[t]+")").css("left",n(".token-progress ul .item:eq("+[t]+")").data("position"))});var i=n(".token-progress ul .progress-active").data("progress");n(".token-progress ul .progress-active").css("width",i)}n(".table-progress").length&&n(".table-latests").find(".table-progress").each(function(t){n(".table-progress:eq("+[t]+") .progress-line").css("width",parseInt(n(".table-progress:eq("+[t]+") .progress-line").data("value"),10)+parseInt(70,10)+"%")});n(".roadmap-modern-wrapper").length&&n(".roadmap-modern-wrapper").owlCarousel({loop:!0,margin:30,nav:!1,responsive:{0:{items:1},600:{items:2},1e3:{items:3}}});n(".roadmap-lux-wrapper").length&&n(".roadmap-lux-wrapper").owlCarousel({loop:!0,margin:30,nav:!1,responsive:{0:{items:1},600:{items:2},1e3:{items:3}}})});n(window).load(function(){n(".loading-wrapper").animate({opacity:"0"},600,function(){setTimeout(function(){n(".loading-wrapper").css("visibility","hidden").fadeOut();n(".parallax").length&&n(".parallax").parallax({imageSrc:"assets/images/parallax.jpg",zIndex:"1"})},300)})});n(window).scroll(function(){var i=n(window).width(),t;i<9910&&(t=n(window).scrollTop(),t>=30?(n(".header-area").addClass("header-sticky"),n(".header-area .dark-logo").css("display","block"),n(".header-area .light-logo").css("display","none")):(n(".header-area").removeClass("header-sticky"),n(".header-area .dark-logo").css("display","none"),n(".header-area .light-logo").css("display","block")))});n(window).resize(function(){t()})})(jQuery);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment