Merge branch 'next-merge' of https://github.com/tenthirtyone/insight into next
This commit is contained in:
commit
b9de71862d
@ -1,7 +1,7 @@
|
||||
const Bcoin = require('./lib/node');
|
||||
const config = require('./config');
|
||||
const logger = require('./lib/logger');
|
||||
const Api = require('./lib/api');
|
||||
const Api = require('./lib/api').server;
|
||||
const db = require('./lib/db');
|
||||
|
||||
logger.log('debug',
|
||||
|
||||
@ -14,6 +14,8 @@ app.use(bodyParser.json());
|
||||
|
||||
// Serve insight ui front end from root dir public folder
|
||||
app.use(express.static('../app/www', { maxage: '1w' }));
|
||||
// Legacy UI - useful for 1:1 compares
|
||||
// app.use(express.static('./public', { maxage: '1w' }));
|
||||
|
||||
app.set('json spaces', config.api.json_spaces);
|
||||
|
||||
@ -37,4 +39,7 @@ app.use((req, res) => res.status(404).send({
|
||||
// Socket server
|
||||
const server = require('http').Server(app);
|
||||
|
||||
module.exports = server;
|
||||
module.exports = {
|
||||
server,
|
||||
api,
|
||||
};
|
||||
|
||||
@ -59,7 +59,6 @@ module.exports = function transactionAPI(router) {
|
||||
// /txs is overloaded. Next ver separate concerns
|
||||
// query by block
|
||||
// query by address
|
||||
// last n txs - haha jk YOU 404
|
||||
router.get('/txs', (req, res) => {
|
||||
const pageNum = parseInt(req.query.pageNum, 10) || 0;
|
||||
const rangeStart = pageNum * MAX_TXS;
|
||||
@ -174,30 +173,29 @@ module.exports = function transactionAPI(router) {
|
||||
`/txs getTopTransactions ${err}`);
|
||||
return res.status(404).send(err);
|
||||
}
|
||||
return res.json({
|
||||
txs: txs.map(tx => ({
|
||||
txid: tx.hash,
|
||||
fees: tx.fee / 1e8,
|
||||
size: tx.size,
|
||||
confirmations: (height - tx.height) + 1,
|
||||
valueOut: tx.outputs.reduce((sum, output) => sum + output.value, 0) / 1e8,
|
||||
vin: tx.inputs.map(input => ({
|
||||
scriptSig: {
|
||||
asm: input.script,
|
||||
},
|
||||
addr: input.address,
|
||||
value: input.value / 1e8,
|
||||
})),
|
||||
vout: tx.outputs.map(output => ({
|
||||
scriptPubKey: {
|
||||
asm: output.script,
|
||||
addresses: [output.address],
|
||||
},
|
||||
value: output.value / 1e8,
|
||||
})),
|
||||
isCoinBase: tx.inputs[0].prevout.hash === '0000000000000000000000000000000000000000000000000000000000000000',
|
||||
return res.send(txs.map(tx => ({
|
||||
txid: tx.hash,
|
||||
fees: tx.fee / 1e8,
|
||||
size: tx.size,
|
||||
confirmations: (height - tx.height) + 1,
|
||||
valueOut: tx.outputs.reduce((sum, output) => sum + output.value, 0) / 1e8,
|
||||
vin: tx.inputs.map(input => ({
|
||||
scriptSig: {
|
||||
asm: input.script,
|
||||
},
|
||||
addr: input.address,
|
||||
value: input.value / 1e8,
|
||||
})),
|
||||
});
|
||||
vout: tx.outputs.map(output => ({
|
||||
scriptPubKey: {
|
||||
asm: output.script,
|
||||
addresses: [output.address],
|
||||
},
|
||||
value: output.value / 1e8,
|
||||
})),
|
||||
isCoinBase: tx.inputs[0].prevout.hash === '0000000000000000000000000000000000000000000000000000000000000000',
|
||||
})),
|
||||
);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user