add scriptsigs to txs for circle-plus info on tx lists

This commit is contained in:
tenthirtyone 2017-08-17 14:37:08 -04:00
parent 3e7f263e18
commit 4b6482e0ad
2 changed files with 15 additions and 2 deletions

View File

@ -4,7 +4,7 @@ const config = {
bcoin_http: 'localhost', bcoin_http: 'localhost',
bcoin: { bcoin: {
network: 'main', network: 'main',
db: 'mem', db: 'leveldb',
prefix: '.', prefix: '.',
checkpoints: true, checkpoints: true,
workers: false, workers: false,

View File

@ -35,6 +35,8 @@ module.exports = function transactionAPI(router) {
return res.status(404).send(); return res.status(404).send();
} }
console.log(tx);
// Return UI JSON // Return UI JSON
return res.send({ return res.send({
txid: tx.hash, txid: tx.hash,
@ -49,9 +51,13 @@ module.exports = function transactionAPI(router) {
vin: tx.inputs.map(input => ({ vin: tx.inputs.map(input => ({
addr: input.coin ? input.coin.address : '', addr: input.coin ? input.coin.address : '',
value: input.coin ? input.coin.value / 1e8 : 0, value: input.coin ? input.coin.value / 1e8 : 0,
scriptSig: {
asm: input.script,
},
})), })),
vout: tx.outputs.map(output => ({ vout: tx.outputs.map(output => ({
scriptPubKey: { scriptPubKey: {
asm: output.script,
addresses: [output.address], addresses: [output.address],
}, },
value: output.value / 1e8, value: output.value / 1e8,
@ -71,7 +77,6 @@ module.exports = function transactionAPI(router) {
const rangeEnd = rangeStart + MAX_TXS; const rangeEnd = rangeStart + MAX_TXS;
// get txs for blockhash, start with best height to calc confirmations // get txs for blockhash, start with best height to calc confirmations
if (req.query.block) { if (req.query.block) {
const height = db.blocks.bestHeight(); const height = db.blocks.bestHeight();
// Get Bcoin data // Get Bcoin data
return request(`${API_URL}/block/${req.query.block}`, return request(`${API_URL}/block/${req.query.block}`,
@ -110,9 +115,13 @@ module.exports = function transactionAPI(router) {
vin: tx.inputs.map(input => ({ vin: tx.inputs.map(input => ({
addr: input.coin ? input.coin.address : '', addr: input.coin ? input.coin.address : '',
value: input.coin ? input.coin.value / 1e8 : 0, value: input.coin ? input.coin.value / 1e8 : 0,
scriptSig: {
asm: input.script,
},
})), })),
vout: tx.outputs.map(output => ({ vout: tx.outputs.map(output => ({
scriptPubKey: { scriptPubKey: {
asm: output.script,
addresses: [output.address], addresses: [output.address],
}, },
value: output.value / 1e8, value: output.value / 1e8,
@ -162,9 +171,13 @@ module.exports = function transactionAPI(router) {
vin: tx.inputs.map(input => ({ vin: tx.inputs.map(input => ({
addr: input.coin ? input.coin.address : '', addr: input.coin ? input.coin.address : '',
value: input.coin ? input.coin.value / 1e8 : 0, value: input.coin ? input.coin.value / 1e8 : 0,
scriptSig: {
asm: input.script,
},
})), })),
vout: tx.outputs.map(output => ({ vout: tx.outputs.map(output => ({
scriptPubKey: { scriptPubKey: {
asm: output.script,
addresses: [output.address], addresses: [output.address],
}, },
value: output.value / 1e8, value: output.value / 1e8,