|
|
@@ -8,360 +8,375 @@ var bitcoin = require("bitcoin"); |
|
|
|
var rpcApi = require("./../app/rpcApi"); |
|
|
|
|
|
|
|
var fs = require('fs'); |
|
|
|
var stream = fs.createWriteStream("proglog.txt"); |
|
|
|
var stream = fs.createWriteStream("proglog.txt"); |
|
|
|
|
|
|
|
|
|
|
|
router.get("/", function(req, res) { |
|
|
|
if (!req.session.host) { |
|
|
|
if (req.cookies['rpc-host']) { |
|
|
|
res.locals.host = req.cookies['rpc-host']; |
|
|
|
} |
|
|
|
|
|
|
|
if (req.cookies['rpc-port']) { |
|
|
|
res.locals.port = req.cookies['rpc-port']; |
|
|
|
} |
|
|
|
|
|
|
|
if (req.cookies['rpc-username']) { |
|
|
|
res.locals.username = req.cookies['rpc-username']; |
|
|
|
} |
|
|
|
|
|
|
|
res.render("connect"); |
|
|
|
res.end(); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var client = global.client; |
|
|
|
|
|
|
|
rpcApi.getInfo().then(function(getinfo) { |
|
|
|
res.locals.getinfo = getinfo; |
|
|
|
|
|
|
|
var blockHeights = []; |
|
|
|
if (getinfo.blocks) { |
|
|
|
for (var i = 0; i < 10; i++) { |
|
|
|
blockHeights.push(getinfo.blocks - i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rpcApi.getBlocksByHeight(blockHeights).then(function(latestBlocks) { |
|
|
|
res.locals.latestBlocks = latestBlocks; |
|
|
|
|
|
|
|
res.render("index"); |
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
console.log(err); |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
res.render("index"); |
|
|
|
}); |
|
|
|
if (!req.session.host) { |
|
|
|
if (req.cookies['rpc-host']) { |
|
|
|
res.locals.host = req.cookies['rpc-host']; |
|
|
|
} |
|
|
|
|
|
|
|
if (req.cookies['rpc-port']) { |
|
|
|
res.locals.port = req.cookies['rpc-port']; |
|
|
|
} |
|
|
|
|
|
|
|
if (req.cookies['rpc-username']) { |
|
|
|
res.locals.username = req.cookies['rpc-username']; |
|
|
|
} |
|
|
|
|
|
|
|
res.render("connect"); |
|
|
|
res.end(); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var client = global.client; |
|
|
|
|
|
|
|
rpcApi.getInfo().then(function(getinfo) { |
|
|
|
res.locals.getinfo = getinfo; |
|
|
|
|
|
|
|
var blockHeights = []; |
|
|
|
if (getinfo.blocks) { |
|
|
|
for (var i = 0; i < 10; i++) { |
|
|
|
blockHeights.push(getinfo.blocks - i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rpcApi.getBlocksByHeight(blockHeights).then(function(latestBlocks) { |
|
|
|
res.locals.latestBlocks = latestBlocks; |
|
|
|
|
|
|
|
res.render("index"); |
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
console.log(err); |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
res.render("index"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
router.get("/node-info", function(req, res) { |
|
|
|
var client = global.client; |
|
|
|
var client = global.client; |
|
|
|
|
|
|
|
stream.write("yyyyyyyyyyyyyyyyyyyyyyy\n"); |
|
|
|
|
|
|
|
rpcApi.getInfo().then(function(getinfo) { |
|
|
|
res.locals.getinfo = getinfo; |
|
|
|
|
|
|
|
stream.write("yyyyyyyyyyyyyyyyyyyyyyy\n"); |
|
|
|
rpcApi.getMiningInfo().then(function(getmininginfo) { |
|
|
|
res.locals.getmininginfo = getmininginfo; |
|
|
|
|
|
|
|
rpcApi.getInfo().then(function(getinfo) { |
|
|
|
res.locals.getinfo = getinfo; |
|
|
|
console.log(getmininginfo); |
|
|
|
stream.write('mininghash:' + getmininginfo.networkhashps + "\n"); |
|
|
|
|
|
|
|
rpcApi.getMiningInfo().then(function(getmininginfo) { |
|
|
|
res.locals.getmininginfo = getmininginfo; |
|
|
|
|
|
|
|
console.log(getmininginfo); |
|
|
|
stream.write('mininghash:'+ getmininginfo.networkhashps +"\n"); |
|
|
|
|
|
|
|
|
|
|
|
res.render("node-info"); |
|
|
|
|
|
|
|
res.render("node-info"); |
|
|
|
|
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
console.log(err); |
|
|
|
res.render("node-info"); |
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
console.log(err); |
|
|
|
res.render("node-info"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
router.get("/mempool", function(req, res) { |
|
|
|
var client = global.client; |
|
|
|
var client = global.client; |
|
|
|
|
|
|
|
rpcApi.getMempoolInfo().then(function(getmempoolinfo) { |
|
|
|
res.locals.getmempoolinfo = getmempoolinfo; |
|
|
|
rpcApi.getMempoolInfo().then(function(getmempoolinfo) { |
|
|
|
res.locals.getmempoolinfo = getmempoolinfo; |
|
|
|
|
|
|
|
rpcApi.getMempoolStats().then(function(mempoolstats) { |
|
|
|
res.locals.mempoolstats = mempoolstats; |
|
|
|
rpcApi.getMempoolStats().then(function(mempoolstats) { |
|
|
|
res.locals.mempoolstats = mempoolstats; |
|
|
|
|
|
|
|
res.render("mempool"); |
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
console.log(err); |
|
|
|
res.render("mempool"); |
|
|
|
}); |
|
|
|
res.render("mempool"); |
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
console.log(err); |
|
|
|
res.render("mempool"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
router.post("/connect", function(req, res) { |
|
|
|
var host = req.body.host; |
|
|
|
var port = req.body.port; |
|
|
|
var username = req.body.username; |
|
|
|
var password = req.body.password; |
|
|
|
var host = req.body.host; |
|
|
|
var port = req.body.port; |
|
|
|
var username = req.body.username; |
|
|
|
var password = req.body.password; |
|
|
|
|
|
|
|
res.cookie('rpc-host', host); |
|
|
|
res.cookie('rpc-port', port); |
|
|
|
res.cookie('rpc-username', username); |
|
|
|
res.cookie('rpc-host', host); |
|
|
|
res.cookie('rpc-port', port); |
|
|
|
res.cookie('rpc-username', username); |
|
|
|
|
|
|
|
req.session.host = host; |
|
|
|
req.session.port = port; |
|
|
|
req.session.username = username; |
|
|
|
req.session.host = host; |
|
|
|
req.session.port = port; |
|
|
|
req.session.username = username; |
|
|
|
|
|
|
|
var client = new bitcoin.Client({ |
|
|
|
host: host, |
|
|
|
port: port, |
|
|
|
user: username, |
|
|
|
pass: password, |
|
|
|
timeout: 30000 |
|
|
|
}); |
|
|
|
var client = new bitcoin.Client({ |
|
|
|
host: host, |
|
|
|
port: port, |
|
|
|
user: username, |
|
|
|
pass: password, |
|
|
|
timeout: 30000 |
|
|
|
}); |
|
|
|
|
|
|
|
console.log("created client: " + client); |
|
|
|
console.log("created client: " + client); |
|
|
|
|
|
|
|
global.client = client; |
|
|
|
global.client = client; |
|
|
|
|
|
|
|
req.session.userMessage = "<strong>Connected via RPC</strong>: " + username + " @ " + host + ":" + port; |
|
|
|
req.session.userMessageType = "success"; |
|
|
|
req.session.userMessage = "<strong>Connected via RPC</strong>: " + username + " @ " + host + ":" + port; |
|
|
|
req.session.userMessageType = "success"; |
|
|
|
|
|
|
|
res.redirect("/"); |
|
|
|
res.redirect("/"); |
|
|
|
}); |
|
|
|
|
|
|
|
router.get("/blocks", function(req, res) { |
|
|
|
var limit = 20; |
|
|
|
var offset = 0; |
|
|
|
var sort = "desc"; |
|
|
|
|
|
|
|
if (req.query.limit) { |
|
|
|
limit = parseInt(req.query.limit); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.query.offset) { |
|
|
|
offset = parseInt(req.query.offset); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.query.sort) { |
|
|
|
sort = req.query.sort; |
|
|
|
} |
|
|
|
|
|
|
|
res.locals.limit = limit; |
|
|
|
res.locals.offset = offset; |
|
|
|
res.locals.sort = sort; |
|
|
|
res.locals.paginationBaseUrl = "/blocks"; |
|
|
|
|
|
|
|
rpcApi.getInfo().then(function(getinfo) { |
|
|
|
res.locals.blockCount = getinfo.blocks; |
|
|
|
res.locals.blockOffset = offset; |
|
|
|
|
|
|
|
var blockHeights = []; |
|
|
|
if (sort == "desc") { |
|
|
|
for (var i = (getinfo.blocks - offset); i > (getinfo.blocks - offset - limit); i--) { |
|
|
|
blockHeights.push(i); |
|
|
|
} |
|
|
|
} else { |
|
|
|
for (var i = offset; i < (offset + limit); i++) { |
|
|
|
blockHeights.push(i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rpcApi.getBlocksByHeight(blockHeights).then(function(blocks) { |
|
|
|
res.locals.blocks = blocks; |
|
|
|
|
|
|
|
res.render("blocks"); |
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
console.log(err); |
|
|
|
res.render("blocks"); |
|
|
|
}); |
|
|
|
var limit = 20; |
|
|
|
var offset = 0; |
|
|
|
var sort = "desc"; |
|
|
|
|
|
|
|
if (req.query.limit) { |
|
|
|
limit = parseInt(req.query.limit); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.query.offset) { |
|
|
|
offset = parseInt(req.query.offset); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.query.sort) { |
|
|
|
sort = req.query.sort; |
|
|
|
} |
|
|
|
|
|
|
|
res.locals.limit = limit; |
|
|
|
res.locals.offset = offset; |
|
|
|
res.locals.sort = sort; |
|
|
|
res.locals.paginationBaseUrl = "/blocks"; |
|
|
|
|
|
|
|
rpcApi.getInfo().then(function(getinfo) { |
|
|
|
res.locals.blockCount = getinfo.blocks; |
|
|
|
res.locals.blockOffset = offset; |
|
|
|
|
|
|
|
var blockHeights = []; |
|
|
|
if (sort == "desc") { |
|
|
|
for (var i = (getinfo.blocks - offset); i > (getinfo.blocks - offset - limit); i--) { |
|
|
|
blockHeights.push(i); |
|
|
|
} |
|
|
|
} else { |
|
|
|
for (var i = offset; i < (offset + limit); i++) { |
|
|
|
blockHeights.push(i); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rpcApi.getBlocksByHeight(blockHeights).then(function(blocks) { |
|
|
|
res.locals.blocks = blocks; |
|
|
|
|
|
|
|
res.render("blocks"); |
|
|
|
}); |
|
|
|
}).catch(function(err) { |
|
|
|
res.locals.userMessage = "Unable to connect to Vivocoin Node at " + req.session.host + ":" + req.session.port; |
|
|
|
console.log(err); |
|
|
|
res.render("blocks"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
router.post("/search", function(req, res) { |
|
|
|
if (!req.body.query) { |
|
|
|
req.session.userMessage = "Enter a block height, block hash, or transaction id."; |
|
|
|
if (!req.body.query) { |
|
|
|
req.session.userMessage = "Enter a block height, block hash, or transaction id."; |
|
|
|
|
|
|
|
res.redirect("/"); |
|
|
|
res.redirect("/"); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
var query = req.body.query.toLowerCase(); |
|
|
|
var query = req.body.query.toLowerCase(); |
|
|
|
|
|
|
|
rpcApi.getRawTransaction(query).then(function(tx) { |
|
|
|
if (tx) { |
|
|
|
res.redirect("/tx/" + query); |
|
|
|
rpcApi.getRawTransaction(query).then(function(tx) { |
|
|
|
if (tx) { |
|
|
|
res.redirect("/tx/" + query); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
}).catch(function(err) { |
|
|
|
rpcApi.getBlockByHash(query).then(function(blockByHash) { |
|
|
|
if (blockByHash) { |
|
|
|
res.redirect("/block/" + query); |
|
|
|
return; |
|
|
|
} |
|
|
|
}).catch(function(err) { |
|
|
|
rpcApi.getBlockByHash(query).then(function(blockByHash) { |
|
|
|
if (blockByHash) { |
|
|
|
res.redirect("/block/" + query); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
}).catch(function(err) { |
|
|
|
if (isNaN(query)) { |
|
|
|
req.session.userMessage = "No results found for query: " + query; |
|
|
|
return; |
|
|
|
} |
|
|
|
}).catch(function(err) { |
|
|
|
if (isNaN(query)) { |
|
|
|
req.session.userMessage = "No results found for query: " + query; |
|
|
|
|
|
|
|
res.redirect("/"); |
|
|
|
res.redirect("/"); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
rpcApi.getBlockByHeight(parseInt(query)).then(function(blockByHeight) { |
|
|
|
if (blockByHeight) { |
|
|
|
res.redirect("/block-height/" + query); |
|
|
|
rpcApi.getBlockByHeight(parseInt(query)).then(function(blockByHeight) { |
|
|
|
if (blockByHeight) { |
|
|
|
res.redirect("/block-height/" + query); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
}).catch(function(err) { |
|
|
|
req.session.userMessage = "No results found for query: " + query; |
|
|
|
return; |
|
|
|
} |
|
|
|
}).catch(function(err) { |
|
|
|
req.session.userMessage = "No results found for query: " + query; |
|
|
|
|
|
|
|
res.redirect("/"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
res.redirect("/"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
router.get("/block-height/:blockHeight", function(req, res) { |
|
|
|
var client = global.client; |
|
|
|
var client = global.client; |
|
|
|
|
|
|
|
var blockHeight = parseInt(req.params.blockHeight); |
|
|
|
var blockHeight = parseInt(req.params.blockHeight); |
|
|
|
|
|
|
|
res.locals.blockHeight = blockHeight; |
|
|
|
res.locals.blockHeight = blockHeight; |
|
|
|
|
|
|
|
res.locals.result = {}; |
|
|
|
res.locals.result = {}; |
|
|
|
|
|
|
|
var limit = 20; |
|
|
|
var offset = 0; |
|
|
|
var limit = 20; |
|
|
|
var offset = 0; |
|
|
|
|
|
|
|
if (req.query.limit) { |
|
|
|
limit = parseInt(req.query.limit); |
|
|
|
} |
|
|
|
if (req.query.limit) { |
|
|
|
limit = parseInt(req.query.limit); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.query.offset) { |
|
|
|
offset = parseInt(req.query.offset); |
|
|
|
} |
|
|
|
if (req.query.offset) { |
|
|
|
offset = parseInt(req.query.offset); |
|
|
|
} |
|
|
|
|
|
|
|
res.locals.limit = limit; |
|
|
|
res.locals.offset = offset; |
|
|
|
res.locals.paginationBaseUrl = "/block-height/" + blockHeight; |
|
|
|
res.locals.limit = limit; |
|
|
|
res.locals.offset = offset; |
|
|
|
res.locals.paginationBaseUrl = "/block-height/" + blockHeight; |
|
|
|
|
|
|
|
client.cmd('getblockhash', blockHeight, function(err, result, resHeaders) { |
|
|
|
if (err) { |
|
|
|
// TODO handle RPC error |
|
|
|
return console.log(err); |
|
|
|
} |
|
|
|
client.cmd('getblockhash', blockHeight, function(err, result, resHeaders) { |
|
|
|
if (err) { |
|
|
|
// TODO handle RPC error |
|
|
|
return console.log(err); |
|
|
|
} |
|
|
|
|
|
|
|
res.locals.result.getblockhash = result; |
|
|
|
res.locals.result.getblockhash = result; |
|
|
|
|
|
|
|
rpcApi.getBlockData(client, result, limit, offset).then(function(result) { |
|
|
|
res.locals.result.getblock = result.getblock; |
|
|
|
res.locals.result.transactions = result.transactions; |
|
|
|
res.locals.result.txInputsByTransaction = result.txInputsByTransaction; |
|
|
|
rpcApi.getBlockData(client, result, limit, offset).then(function(result) { |
|
|
|
res.locals.result.getblock = result.getblock; |
|
|
|
res.locals.result.transactions = result.transactions; |
|
|
|
res.locals.result.txInputsByTransaction = result.txInputsByTransaction; |
|
|
|
|
|
|
|
res.render("block-height"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
res.render("block-height"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
router.get("/block/:blockHash", function(req, res) { |
|
|
|
var blockHash = req.params.blockHash; |
|
|
|
var blockHash = req.params.blockHash; |
|
|
|
|
|
|
|
res.locals.blockHash = blockHash; |
|
|
|
res.locals.blockHash = blockHash; |
|
|
|
|
|
|
|
res.locals.result = {}; |
|
|
|
res.locals.result = {}; |
|
|
|
|
|
|
|
var limit = 20; |
|
|
|
var offset = 0; |
|
|
|
var limit = 20; |
|
|
|
var offset = 0; |
|
|
|
|
|
|
|
if (req.query.limit) { |
|
|
|
limit = parseInt(req.query.limit); |
|
|
|
} |
|
|
|
if (req.query.limit) { |
|
|
|
limit = parseInt(req.query.limit); |
|
|
|
} |
|
|
|
|
|
|
|
if (req.query.offset) { |
|
|
|
offset = parseInt(req.query.offset); |
|
|
|
} |
|
|
|
if (req.query.offset) { |
|
|
|
offset = parseInt(req.query.offset); |
|
|
|
} |
|
|
|
|
|
|
|
res.locals.limit = limit; |
|
|
|
res.locals.offset = offset; |
|
|
|
res.locals.paginationBaseUrl = "/block/" + blockHash; |
|
|
|
res.locals.limit = limit; |
|
|
|
res.locals.offset = offset; |
|
|
|
res.locals.paginationBaseUrl = "/block/" + blockHash; |
|
|
|
|
|
|
|
// TODO handle RPC error |
|
|
|
rpcApi.getBlockData(client, blockHash, limit, offset).then(function(result) { |
|
|
|
res.locals.result.getblock = result.getblock; |
|
|
|
res.locals.result.transactions = result.transactions; |
|
|
|
res.locals.result.txInputsByTransaction = result.txInputsByTransaction; |
|
|
|
// TODO handle RPC error |
|
|
|
rpcApi.getBlockData(client, blockHash, limit, offset).then(function(result) { |
|
|
|
res.locals.result.getblock = result.getblock; |
|
|
|
res.locals.result.transactions = result.transactions; |
|
|
|
res.locals.result.txInputsByTransaction = result.txInputsByTransaction; |
|
|
|
|
|
|
|
res.render("block"); |
|
|
|
}); |
|
|
|
res.render("block"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
router.get("/address/:address", function(req, res) { |
|
|
|
var address = req.params.address; |
|
|
|
|
|
|
|
res.locals.address = address; |
|
|
|
|
|
|
|
res.locals.result = {}; |
|
|
|
|
|
|
|
// TODO handle RPC error |
|
|
|
rpcApi.getBalanceFromAddress(client, address).then(function(result) { |
|
|
|
res.locals.result.address = result.address; |
|
|
|
|
|
|
|
res.render("address"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
router.get("/tx/:transactionId", function(req, res) { |
|
|
|
var txid = req.params.transactionId; |
|
|
|
var txid = req.params.transactionId; |
|
|
|
|
|
|
|
var output = -1; |
|
|
|
if (req.query.output) { |
|
|
|
output = parseInt(req.query.output); |
|
|
|
} |
|
|
|
var output = -1; |
|
|
|
if (req.query.output) { |
|
|
|
output = parseInt(req.query.output); |
|
|
|
} |
|
|
|
|
|
|
|
res.locals.txid = txid; |
|
|
|
res.locals.output = output; |
|
|
|
res.locals.txid = txid; |
|
|
|
res.locals.output = output; |
|
|
|
|
|
|
|
res.locals.result = {}; |
|
|
|
res.locals.result = {}; |
|
|
|
|
|
|
|
// TODO handle RPC error |
|
|
|
rpcApi.getRawTransaction(txid).then(function(rawTxResult) { |
|
|
|
res.locals.result.getrawtransaction = rawTxResult; |
|
|
|
// TODO handle RPC error |
|
|
|
rpcApi.getRawTransaction(txid).then(function(rawTxResult) { |
|
|
|
res.locals.result.getrawtransaction = rawTxResult; |
|
|
|
|
|
|
|
client.cmd('getblock', rawTxResult.blockhash, function(err3, result3, resHeaders3) { |
|
|
|
res.locals.result.getblock = result3; |
|
|
|
client.cmd('getblock', rawTxResult.blockhash, function(err3, result3, resHeaders3) { |
|
|
|
res.locals.result.getblock = result3; |
|
|
|
|
|
|
|
var txids = []; |
|
|
|
for (var i = 0; i < rawTxResult.vin.length; i++) { |
|
|
|
if (!rawTxResult.vin[i].coinbase) { |
|
|
|
txids.push(rawTxResult.vin[i].txid); |
|
|
|
} |
|
|
|
} |
|
|
|
var txids = []; |
|
|
|
for (var i = 0; i < rawTxResult.vin.length; i++) { |
|
|
|
if (!rawTxResult.vin[i].coinbase) { |
|
|
|
txids.push(rawTxResult.vin[i].txid); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
rpcApi.getRawTransactions(txids).then(function(txInputs) { |
|
|
|
res.locals.result.txInputs = txInputs; |
|
|
|
rpcApi.getRawTransactions(txids).then(function(txInputs) { |
|
|
|
res.locals.result.txInputs = txInputs; |
|
|
|
|
|
|
|
res.render("transaction"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
res.render("transaction"); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
router.get("/terminal", function(req, res) { |
|
|
|
if (!env.debug) { |
|
|
|
res.send("Debug mode is off."); |
|
|
|
if (!env.debug) { |
|
|
|
res.send("Debug mode is off."); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
res.render("terminal"); |
|
|
|
res.render("terminal"); |
|
|
|
}); |
|
|
|
|
|
|
|
router.post("/terminal", function(req, res) { |
|
|
|
if (!env.debug) { |
|
|
|
res.send("Debug mode is off."); |
|
|
|
if (!env.debug) { |
|
|
|
res.send("Debug mode is off."); |
|
|
|
|
|
|
|
return; |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
client.cmd(req.body.cmd, function(err, result, resHeaders) { |
|
|
|
console.log(result); |
|
|
|
console.log(err); |
|
|
|
console.log(resHeaders); |
|
|
|
client.cmd(req.body.cmd, function(err, result, resHeaders) { |
|
|
|
console.log(result); |
|
|
|
console.log(err); |
|
|
|
console.log(resHeaders); |
|
|
|
|
|
|
|
res.send(JSON.stringify(result, null, 4)); |
|
|
|
}); |
|
|
|
res.send(JSON.stringify(result, null, 4)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
module.exports = router; |
|
|
|
module.exports = router; |