Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Request = require("request");
- var express = require('express');
- var bodyParser = require('body-parser');
- var app = express();
- var urlencodedParser = bodyParser.urlencoded({ extended: true });
- var server = app.listen(8084, function () {
- var port = server.address().port;
- require('dns').lookup(require('os').hostname(), function (err, add, fam) {
- console.log('HTTP running on http://%s:8082', add);
- })
- });
- app.get('/', function (req, res) {
- var html='';
- html +="<!DOCTYPE html>";
- html +=" <html>";
- html +=" <head>";
- html +=" <link rel='stylesheet' type='text/css' href='./public/style.css'>";
- html +=" </head>";
- html +=" <body>";
- html += "<form action='/report' method='post' name='form1'>";
- html += "<center>Address:<br>";
- html += "<input type= 'text' name='aid' style='background-color: #3CBC8D; color: white; size: 150px;'> <br>";
- html += "<input type='submit' value='submit' style='background-color: #3CBC8D; color: white;'></center>";
- html += "</form>";
- html += "</body>";
- res.send(html);
- });
- app.post('/report', urlencodedParser, function (req, res) {
- Request.get(`https://chainz.cryptoid.info/pnd/api.dws?q=multiaddr&key=1a9c92c7492b&active=${req.body.aid}`, (error, response, body) => {
- if(error) {
- return console.dir(error);
- }
- obj = JSON.parse(body);
- var html='';
- html +="<!DOCTYPE html>";
- html +=" <html>";
- html +=" <head>";
- html +=" </head>";
- html +=" <body>";
- html += "Looking up Address: " + JSON.stringify(obj.addresses[0].address);
- html += "<br><br><br>";
- for (var i = 0; i < obj.txs.length; i++) {
- html += 'TX HASH: <a href="https://chainz.cryptoid.info/pnd/tx.dws?'+ obj.txs[i].hash +'"> '+ JSON.stringify(obj.txs[i].hash);
- Request.get(`https://chainz.cryptoid.info/pnd/api.dws?q=txinfo&t=${obj.txs[i].hash}`, (error, response, body) => {
- if(error) {
- return console.log(error);
- }
- obj = JSON.parse(body);
- var html='';
- html += JSON.stringify(obj);
- console.log(obj)
- })
- html += "</a><br>";
- html += "Confirmations: " + JSON.stringify(obj.txs[i].confirmations);
- html += "<br>";
- html += "Change: " + JSON.stringify(obj.txs[i].change);
- html += "<br>";
- html += "Time: " + JSON.stringify(obj.txs[i].time_utc);
- html += "<br>";
- html += "N: " + JSON.stringify(obj.txs[i].n);
- html += "<br><br>";
- }
- html += "</body>";
- html += "</html>";
- res.send(html);
- console.dir(JSON.parse(body));
- }) });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement