1
0
mirror of https://github.com/GOSTSec/gostexplr synced 2025-02-06 20:04:37 +00:00
gostexplr/routes/transaction.js
2018-02-03 23:54:25 +05:00

46 lines
925 B
JavaScript

var models = require('../models');
var express = require('express');
var router = express.Router();
/* GET home page. */
router.get('/:txid', async function(req, res, next) {
const txid = encodeURI(req.params.txid);
const transaction = await models.Transaction.findOne({
where: {
txid,
},
include: [{
attributes: ['hash'],
model: models.Block,
},{
model: models.Vout,
include: {
model: models.Address,
}
}, {
model: models.Transaction,
as: 'txtx',
}],
});
if (transaction === null) {
res.status(404).render('404');
return;
}
const vouts = [];
transaction.Vouts.forEach((vout) => {
vout.Addresses.forEach((address) => {
vouts.push({
address: address.address,
value: vout.value,
});
});
});
res.render('transaction', {
transaction,
vouts,
});
});
module.exports = router;