From e6da43d887ba707d9c127e2362d45bf86e2fa9cf Mon Sep 17 00:00:00 2001 From: coldstar Date: Wed, 26 May 2021 07:04:02 -0700 Subject: [PATCH] 05/26/2021 07:04:02 AM MST --- routes/baseActionsRouter.js | 24 ++++++++++++++++++++++++ views/layout.pug | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/routes/baseActionsRouter.js b/routes/baseActionsRouter.js index 51e28ad..12a3233 100755 --- a/routes/baseActionsRouter.js +++ b/routes/baseActionsRouter.js @@ -190,6 +190,30 @@ router.post("/search", function(req, res) { var query = req.body.query.toLowerCase(); + if (query === null || query === "null" || query.length < 1) { + res.redirect("/"); + return; + } + + query = query.replace(/,/g, ""); + + if (query.stringLength < 9) { + if (typeof query == "number") { + res.redirect("/block-height/" + query); + console.log('This is a block'); + return; + } + } + + if (query.stringLength < 36) { + if (typeof query != "number") { + res.redirect("/address/" + query); + console.log('This is not number'); + return; + } + } + + rpcApi.getRawTransaction(query).then(function(tx) { if (tx) { res.redirect("/tx/" + query); diff --git a/views/layout.pug b/views/layout.pug index b6f4c62..0be2d27 100755 --- a/views/layout.pug +++ b/views/layout.pug @@ -40,7 +40,7 @@ html a(href="/mempool", class="nav-link") Mempool Info form(method="post", action="/search", class="form-inline") div(class="input-group") - input(type="text", class="form-control form-control-sm", name="query", placeholder="block height, block hash, txid", style="width: 250px;") + input(type="text", class="form-control form-control-sm", name="query", placeholder="block height, block hash, txid, address", style="width: 250px;") span(class="input-group-btn") input(type="submit", class="btn btn-primary", value="Search")