Fixed txs per request to only save block w/ subdocs

This commit is contained in:
tenthirtyone 2017-08-14 17:58:12 -04:00
parent e210e34dbc
commit 9045eacccd
2 changed files with 11 additions and 6 deletions

View File

@ -1,5 +1,5 @@
const config = {
start_node: true,
start_node: false,
logging: 'debug',
bcoin: {
network: 'main',

View File

@ -39,17 +39,22 @@ function getTransactions(params, options, cb) {
module.exports = function transactionAPI(router) {
router.get('/tx/:txid', (req, res) => {
getTransactions(
{ hash: req.params.txid },
getBlock(
{ 'txs.hash': req.params.txid },
{ },
(err, tx) => {
MAX_BLOCKS,
(err, blocks) => {
if (err) {
res.status(501).send();
logger.log('err', err);
}
if (tx[0]) {
const t = tx[0];
if (blocks[0] && blocks[0].txs) {
let t = blocks[0].txs.filter(tx => tx.hash === req.params.txid);
t = t[0];
console.log(t);
console.log(t.inputs);
console.log(t.inputs);
// Map bcoin model to insight-api
res.json({
txid: t.hash,