insight-api
Advanced tools
Comparing version 0.3.2 to 0.4.0
'use strict'; | ||
var common = require('./common'); | ||
var bitcore = require('bitcore-lib'); | ||
var async = require('async'); | ||
var TxController = require('./transactions'); | ||
var Common = require('./common'); | ||
@@ -11,5 +11,7 @@ function AddressController(node) { | ||
this.txController = new TxController(node); | ||
this.common = new Common({log: this.node.log}); | ||
} | ||
AddressController.prototype.show = function(req, res) { | ||
var self = this; | ||
var options = { | ||
@@ -19,5 +21,10 @@ noTxList: parseInt(req.query.noTxList) | ||
if (req.query.from && req.query.to) { | ||
options.from = parseInt(req.query.from); | ||
options.to = parseInt(req.query.to); | ||
} | ||
this.getAddressSummary(req.addr, options, function(err, data) { | ||
if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -46,5 +53,6 @@ | ||
AddressController.prototype.addressSummarySubQuery = function(req, res, param) { | ||
var self = this; | ||
this.getAddressSummary(req.addr, {}, function(err, data) { | ||
if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -57,3 +65,2 @@ | ||
AddressController.prototype.getAddressSummary = function(address, options, callback) { | ||
var self = this; | ||
@@ -97,7 +104,8 @@ this.node.getAddressSummary(address, options, function(err, summary) { | ||
this.check(req, res, next, req.addrs); | ||
} | ||
}; | ||
AddressController.prototype.check = function(req, res, next, addresses) { | ||
var self = this; | ||
if(!addresses.length || !addresses[0]) { | ||
return common.handleErrors({ | ||
return self.common.handleErrors({ | ||
message: 'Must include address', | ||
@@ -112,3 +120,3 @@ code: 1 | ||
} catch(e) { | ||
return common.handleErrors({ | ||
return self.common.handleErrors({ | ||
message: 'Invalid address: ' + e.message, | ||
@@ -126,9 +134,8 @@ code: 1 | ||
this.node.getUnspentOutputs(req.addr, true, function(err, utxos) { | ||
if(err && err instanceof self.node.errors.NoOutputs) { | ||
this.node.getAddressUnspentOutputs(req.addr, {}, function(err, utxos) { | ||
if(err) { | ||
return self.common.handleErrors(err, res); | ||
} else if (!utxos.length) { | ||
return res.jsonp([]); | ||
} else if(err) { | ||
return common.handleErrors(err, res); | ||
} | ||
res.jsonp(utxos.map(self.transformUtxo.bind(self))); | ||
@@ -140,8 +147,7 @@ }); | ||
var self = this; | ||
this.node.getUnspentOutputs(req.addrs, true, function(err, utxos) { | ||
if(err && err instanceof self.node.errors.NoOutputs) { | ||
this.node.getAddressUnspentOutputs(req.addrs, true, function(err, utxos) { | ||
if(err && err.code === -5) { | ||
return res.jsonp([]); | ||
} else if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -153,12 +159,21 @@ | ||
AddressController.prototype.transformUtxo = function(utxo) { | ||
return { | ||
address: utxo.address, | ||
txid: utxo.txid, | ||
vout: utxo.outputIndex, | ||
ts: utxo.timestamp ? parseInt(utxo.timestamp) : Date.now(), | ||
scriptPubKey: utxo.script, | ||
amount: utxo.satoshis / 1e8, | ||
confirmations: utxo.confirmations | ||
AddressController.prototype.transformUtxo = function(utxoArg) { | ||
var utxo = { | ||
address: utxoArg.address, | ||
txid: utxoArg.txid, | ||
vout: utxoArg.outputIndex, | ||
scriptPubKey: utxoArg.script, | ||
amount: utxoArg.satoshis / 1e8, | ||
satoshis: utxoArg.satoshis | ||
}; | ||
if (utxoArg.height && utxoArg.height > 0) { | ||
utxo.height = utxoArg.height; | ||
utxo.confirmations = this.node.services.bitcoind.height - utxoArg.height + 1; | ||
} else { | ||
utxo.confirmations = 0; | ||
} | ||
if (utxoArg.timestamp) { | ||
utxo.ts = utxoArg.timestamp; | ||
} | ||
return utxo; | ||
}; | ||
@@ -170,10 +185,10 @@ | ||
var options = { | ||
from: req.query.from || req.body.from || 0 | ||
from: parseInt(req.query.from) || parseInt(req.body.from) || 0 | ||
}; | ||
options.to = req.query.to || req.body.to || options.from + 10; | ||
options.to = parseInt(req.query.to) || parseInt(req.body.to) || parseInt(options.from) + 10; | ||
self.node.getAddressHistory(req.addrs, options, function(err, result) { | ||
if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -183,3 +198,3 @@ | ||
if (err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -186,0 +201,0 @@ res.jsonp({ |
'use strict'; | ||
var common = require('./common'); | ||
var async = require('async'); | ||
var bitcore = require('bitcore-lib'); | ||
var _ = bitcore.deps._; | ||
var pools = require('../pools.json'); | ||
var BN = bitcore.crypto.BN; | ||
var LRU = require('lru-cache'); | ||
var Common = require('./common'); | ||
function BlockController(node) { | ||
function BlockController(options) { | ||
var self = this; | ||
this.node = node; | ||
this.node = options.node; | ||
this.blockSummaryCache = LRU(options.blockSummaryCacheSize || BlockController.DEFAULT_BLOCKSUMMARY_CACHE_SIZE); | ||
this.blockCacheConfirmations = 6; | ||
this.blockCache = LRU(options.blockCacheSize || BlockController.DEFAULT_BLOCK_CACHE_SIZE); | ||
this.poolStrings = {}; | ||
@@ -22,2 +28,4 @@ pools.forEach(function(pool) { | ||
}); | ||
this.common = new Common({log: this.node.log}); | ||
} | ||
@@ -27,24 +35,85 @@ | ||
BlockController.DEFAULT_BLOCKSUMMARY_CACHE_SIZE = 1000000; | ||
BlockController.DEFAULT_BLOCK_CACHE_SIZE = 1000; | ||
function isHexadecimal(hash) { | ||
if (!_.isString(hash)) { | ||
return false; | ||
} | ||
return /^[0-9a-fA-F]+$/.test(hash); | ||
} | ||
BlockController.prototype.checkBlockHash = function(req, res, next) { | ||
var self = this; | ||
var hash = req.params.blockHash; | ||
if (hash.length < 64 || !isHexadecimal(hash)) { | ||
return self.common.handleErrors(null, res); | ||
} | ||
next(); | ||
}; | ||
/** | ||
* Find block by hash ... | ||
*/ | ||
BlockController.prototype.block = function(req, res, next, hash) { | ||
BlockController.prototype.block = function(req, res, next) { | ||
var self = this; | ||
var hash = req.params.blockHash; | ||
var blockCached = self.blockCache.get(hash); | ||
this.node.getBlock(hash, function(err, block) { | ||
if(err && err.message === 'Block not found.') { | ||
// TODO libbitcoind should pass an instance of errors.Block.NotFound | ||
return common.handleErrors(null, res); | ||
if (blockCached) { | ||
blockCached.confirmations = self.node.services.bitcoind.height - blockCached.height + 1; | ||
req.block = blockCached; | ||
next(); | ||
} else { | ||
self.node.getBlock(hash, function(err, block) { | ||
if((err && err.code === -5) || (err && err.code === -8)) { | ||
return self.common.handleErrors(null, res); | ||
} else if(err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
self.node.services.bitcoind.getBlockHeader(hash, function(err, info) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
var blockResult = self.transformBlock(block, info); | ||
if (blockResult.confirmations >= self.blockCacheConfirmations) { | ||
self.blockCache.set(hash, blockResult); | ||
} | ||
req.block = blockResult; | ||
next(); | ||
}); | ||
}); | ||
} | ||
}; | ||
/** | ||
* Find rawblock by hash and height... | ||
*/ | ||
BlockController.prototype.rawBlock = function(req, res, next) { | ||
var self = this; | ||
var blockHash = req.params.blockHash; | ||
self.node.getRawBlock(blockHash, function(err, blockBuffer) { | ||
if((err && err.code === -5) || (err && err.code === -8)) { | ||
return self.common.handleErrors(null, res); | ||
} else if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
var info = self.node.services.bitcoind.getBlockIndex(hash); | ||
info.isMainChain = self.node.services.bitcoind.isMainChain(hash); | ||
req.block = self.transformBlock(block, info); | ||
req.rawBlock = { | ||
rawblock: blockBuffer.toString('hex') | ||
}; | ||
next(); | ||
}); | ||
}; | ||
BlockController.prototype._normalizePrevHash = function(hash) { | ||
// TODO fix bitcore to give back null instead of null hash | ||
if (hash !== '0000000000000000000000000000000000000000000000000000000000000000') { | ||
return hash; | ||
} else { | ||
return null; | ||
} | ||
}; | ||
BlockController.prototype.transformBlock = function(block, info) { | ||
@@ -57,3 +126,2 @@ var blockObj = block.toObject(); | ||
hash: block.hash, | ||
confirmations: this.node.services.db.tip.__height - info.height + 1, | ||
size: block.toBuffer().length, | ||
@@ -69,6 +137,7 @@ height: info.height, | ||
chainwork: info.chainWork, | ||
previousblockhash: blockObj.header.prevHash, | ||
nextblockhash: this.node.services.bitcoind.getNextBlockHash(block.hash), | ||
confirmations: info.confirmations, | ||
previousblockhash: this._normalizePrevHash(blockObj.header.prevHash), | ||
nextblockhash: info.nextHash, | ||
reward: this.getBlockReward(info.height) / 1e8, | ||
isMainChain: info.isMainChain, | ||
isMainChain: (info.confirmations !== -1), | ||
poolInfo: this.getPoolInfo(block) | ||
@@ -87,13 +156,81 @@ }; | ||
BlockController.prototype.blockIndex = function(req, res, next, height) { | ||
var info = this.node.services.bitcoind.getBlockIndex(parseInt(height)); | ||
if(!info) { | ||
return common.handleErrors(null, res); | ||
BlockController.prototype.showRaw = function(req, res) { | ||
if (req.rawBlock) { | ||
res.jsonp(req.rawBlock); | ||
} | ||
}; | ||
res.jsonp({ | ||
blockHash: info.hash | ||
BlockController.prototype.blockIndex = function(req, res) { | ||
var self = this; | ||
var height = req.params.height; | ||
this.node.services.bitcoind.getBlockHeader(parseInt(height), function(err, info) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
res.jsonp({ | ||
blockHash: info.hash | ||
}); | ||
}); | ||
}; | ||
BlockController.prototype._getBlockSummary = function(hash, moreTimestamp, next) { | ||
var self = this; | ||
function finish(result) { | ||
if (moreTimestamp > result.time) { | ||
moreTimestamp = result.time; | ||
} | ||
return next(null, result); | ||
} | ||
var summaryCache = self.blockSummaryCache.get(hash); | ||
if (summaryCache) { | ||
finish(summaryCache); | ||
} else { | ||
self.node.services.bitcoind.getRawBlock(hash, function(err, blockBuffer) { | ||
if (err) { | ||
return next(err); | ||
} | ||
var br = new bitcore.encoding.BufferReader(blockBuffer); | ||
// take a shortcut to get number of transactions and the blocksize. | ||
// Also reads the coinbase transaction and only that. | ||
// Old code parsed all transactions in every block _and_ then encoded | ||
// them all back together to get the binary size of the block. | ||
// FIXME: This code might still read the whole block. Fixing that | ||
// would require changes in bitcore-node. | ||
var header = bitcore.BlockHeader.fromBufferReader(br); | ||
var info = {}; | ||
var txlength = br.readVarintNum(); | ||
info.transactions = [bitcore.Transaction().fromBufferReader(br)]; | ||
self.node.services.bitcoind.getBlockHeader(hash, function(err, blockHeader) { | ||
if (err) { | ||
return next(err); | ||
} | ||
var height = blockHeader.height; | ||
var summary = { | ||
height: height, | ||
size: blockBuffer.length, | ||
hash: hash, | ||
time: header.time, | ||
txlength: txlength, | ||
poolInfo: self.getPoolInfo(info) | ||
}; | ||
var confirmations = self.node.services.bitcoind.height - height + 1; | ||
if (confirmations >= self.blockCacheConfirmations) { | ||
self.blockSummaryCache.set(hash, summary); | ||
} | ||
finish(summary); | ||
}); | ||
}); | ||
} | ||
}; | ||
// List blocks by date | ||
@@ -111,3 +248,3 @@ BlockController.prototype.list = function(req, res) { | ||
if(!datePattern.test(dateStr)) { | ||
return common.handleErrors(new Error('Please use yyyy-mm-dd format'), res); | ||
return self.common.handleErrors(new Error('Please use yyyy-mm-dd format'), res); | ||
} | ||
@@ -129,9 +266,11 @@ | ||
var more = false; | ||
var moreTs = lte; | ||
var moreTimestamp = lte; | ||
self.node.services.db.getBlockHashesByTimestamp(lte, gte, function(err, hashes) { | ||
self.node.services.bitcoind.getBlockHashesByTimestamp(lte, gte, function(err, hashes) { | ||
if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
hashes.reverse(); | ||
if(hashes.length > limit) { | ||
@@ -145,37 +284,15 @@ more = true; | ||
function(hash, next) { | ||
self.node.getBlock(hash, function(err, block) { | ||
if(err) { | ||
return next(err); | ||
} | ||
var info = self.node.services.bitcoind.getBlockIndex(hash); | ||
block.__height = info.height; | ||
if(moreTs > block.header.timestamp) { | ||
moreTs = block.header.timestamp; | ||
} | ||
return next(null, block); | ||
}); | ||
self._getBlockSummary(hash, moreTimestamp, next); | ||
}, | ||
function(err, blocks) { | ||
if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
blocks.sort(function(a, b) { | ||
return b.__height - a.__height; | ||
return b.height - a.height; | ||
}); | ||
var data = { | ||
blocks: blocks.map(function(block) { | ||
return { | ||
height: block.__height, | ||
size: block.toBuffer().length, | ||
hash: block.hash, | ||
time: block.header.time, | ||
txlength: block.transactions.length, | ||
poolInfo: self.getPoolInfo(block) | ||
}; | ||
}), | ||
blocks: blocks, | ||
length: blocks.length, | ||
@@ -193,3 +310,3 @@ pagination: { | ||
if(more) { | ||
data.pagination.moreTs = moreTs; | ||
data.pagination.moreTs = moreTimestamp; | ||
} | ||
@@ -196,0 +313,0 @@ |
'use strict'; | ||
exports.notReady = function (err, res, p) { | ||
function Common(options) { | ||
this.log = options.log; | ||
} | ||
Common.prototype.notReady = function (err, res, p) { | ||
res.status(503).send('Server not yet ready. Sync Percentage:' + p); | ||
}; | ||
exports.handleErrors = function (err, res) { | ||
Common.prototype.handleErrors = function (err, res) { | ||
if (err) { | ||
if (err.code) { | ||
res.status(400).send(err.message + '. Code:' + err.code); | ||
} | ||
else { | ||
} else { | ||
this.log.error(err.stack); | ||
res.status(503).send(err.message); | ||
} | ||
} | ||
else { | ||
} else { | ||
res.status(404).send('Not found'); | ||
} | ||
}; | ||
module.exports = Common; |
102
lib/index.js
'use strict'; | ||
var Writable = require('stream').Writable; | ||
var bodyParser = require('body-parser'); | ||
var compression = require('compression'); | ||
var BaseService = require('./service'); | ||
@@ -13,2 +15,4 @@ var inherits = require('util').inherits; | ||
var CurrencyController = require('./currency'); | ||
var RateLimiter = require('./ratelimiter'); | ||
var morgan = require('morgan'); | ||
var bitcore = require('bitcore-lib'); | ||
@@ -46,2 +50,5 @@ var _ = bitcore.deps._; | ||
this.blockSummaryCacheSize = options.blockSummaryCacheSize || BlockController.DEFAULT_BLOCKSUMMARY_CACHE_SIZE; | ||
this.blockCacheSize = options.blockCacheSize || BlockController.DEFAULT_BLOCK_CACHE_SIZE; | ||
if (!_.isUndefined(options.routePrefix)) { | ||
@@ -56,3 +63,3 @@ this.routePrefix = options.routePrefix; | ||
InsightAPI.dependencies = ['address', 'web']; | ||
InsightAPI.dependencies = ['bitcoind', 'web']; | ||
@@ -86,9 +93,51 @@ inherits(InsightAPI, BaseService); | ||
InsightAPI.prototype.start = function(callback) { | ||
this.node.services.bitcoind.on('tx', this.transactionHandler.bind(this)); | ||
this.node.services.bitcoind.on('tx', this.transactionEventHandler.bind(this)); | ||
this.node.services.bitcoind.on('block', this.blockEventHandler.bind(this)); | ||
setImmediate(callback); | ||
}; | ||
InsightAPI.prototype.createLogInfoStream = function() { | ||
var self = this; | ||
function Log(options) { | ||
Writable.call(this, options); | ||
} | ||
inherits(Log, Writable); | ||
Log.prototype._write = function (chunk, enc, callback) { | ||
self.node.log.info(chunk.slice(0, chunk.length - 1)); // remove new line and pass to logger | ||
callback(); | ||
}; | ||
var stream = new Log(); | ||
return stream; | ||
}; | ||
InsightAPI.prototype.getRemoteAddress = function(req) { | ||
if (req.headers['cf-connecting-ip']) { | ||
return req.headers['cf-connecting-ip']; | ||
} | ||
return req.socket.remoteAddress; | ||
}; | ||
InsightAPI.prototype.setupRoutes = function(app) { | ||
var self = this; | ||
//Enable rate limiter | ||
var limiter = new RateLimiter({node: this.node}); | ||
app.use(limiter.middleware()); | ||
//Setup logging | ||
morgan.token('remote-forward-addr', function(req){ | ||
return self.getRemoteAddress(req); | ||
}); | ||
var logFormat = ':remote-forward-addr ":method :url" :status :res[content-length] :response-time ":user-agent" '; | ||
var logStream = this.createLogInfoStream(); | ||
app.use(morgan(logFormat, {stream: logStream})); | ||
//Enable compression | ||
app.use(compression()); | ||
//Enable urlencoded data | ||
app.use(bodyParser.urlencoded({extended: true})); | ||
@@ -104,10 +153,17 @@ | ||
//Block routes | ||
var blocks = new BlockController(this.node); | ||
var blockOptions = { | ||
node: this.node, | ||
blockSummaryCacheSize: this.blockSummaryCacheSize, | ||
blockCacheSize: this.blockCacheSize | ||
}; | ||
var blocks = new BlockController(blockOptions); | ||
app.get('/blocks', this.cacheShort(), blocks.list.bind(blocks)); | ||
app.get('/block/:blockHash', this.cacheLong(), blocks.show.bind(blocks)); | ||
app.get('/block/:blockHash', this.cacheShort(), blocks.checkBlockHash.bind(blocks), blocks.show.bind(blocks)); | ||
app.param('blockHash', blocks.block.bind(blocks)); | ||
app.get('/block-index/:height', this.cacheLong(), blocks.blockIndex.bind(blocks)); | ||
app.get('/rawblock/:blockHash', this.cacheLong(), blocks.checkBlockHash.bind(blocks), blocks.showRaw.bind(blocks)); | ||
app.param('blockHash', blocks.rawBlock.bind(blocks)); | ||
app.get('/block-index/:height', this.cacheShort(), blocks.blockIndex.bind(blocks)); | ||
app.param('height', blocks.blockIndex.bind(blocks)); | ||
@@ -117,3 +173,3 @@ | ||
var transactions = new TxController(this.node); | ||
app.get('/tx/:txid', this.cacheLong(), transactions.show.bind(transactions)); | ||
app.get('/tx/:txid', this.cacheShort(), transactions.show.bind(transactions)); | ||
app.param('txid', transactions.transaction.bind(transactions)); | ||
@@ -165,2 +221,11 @@ app.get('/txs', this.cacheShort(), transactions.list.bind(transactions)); | ||
// Not Found | ||
app.use(function(req, res) { | ||
res.status(404).jsonp({ | ||
status: 404, | ||
url: req.originalUrl, | ||
error: 'Not found' | ||
}); | ||
}); | ||
}; | ||
@@ -180,21 +245,14 @@ | ||
InsightAPI.prototype.blockHandler = function(block, add, callback) { | ||
InsightAPI.prototype.blockEventHandler = function(hashBuffer) { | ||
// Notify inv subscribers | ||
for (var i = 0; i < this.subscriptions.inv.length; i++) { | ||
this.subscriptions.inv[i].emit('block', block.hash); | ||
this.subscriptions.inv[i].emit('block', hashBuffer.toString('hex')); | ||
} | ||
setImmediate(function() { | ||
callback(null, []); | ||
}); | ||
}; | ||
InsightAPI.prototype.transactionEventHandler = function(txBuffer) { | ||
var tx = new Transaction().fromBuffer(txBuffer); | ||
var result = this.txController.transformInvTransaction(tx); | ||
InsightAPI.prototype.transactionHandler = function(txInfo) { | ||
if(txInfo.mempool) { | ||
var tx = Transaction().fromBuffer(txInfo.buffer); | ||
tx = this.txController.transformInvTransaction(tx); | ||
for (var i = 0; i < this.subscriptions.inv.length; i++) { | ||
this.subscriptions.inv[i].emit('tx', tx); | ||
} | ||
for (var i = 0; i < this.subscriptions.inv.length; i++) { | ||
this.subscriptions.inv[i].emit('tx', result); | ||
} | ||
@@ -201,0 +259,0 @@ }; |
@@ -6,9 +6,11 @@ 'use strict'; | ||
var Message = require('bitcore-message'); | ||
var common = require('./common'); | ||
var Common = require('./common'); | ||
function MessagesController(node) { | ||
this.node = node; | ||
this.common = new Common({log: this.node.log}); | ||
} | ||
MessagesController.prototype.verify = function(req, res) { | ||
var self = this; | ||
var address = req.body.address || req.query.address; | ||
@@ -18,3 +20,3 @@ var signature = req.body.signature || req.query.signature; | ||
if(_.isUndefined(address) || _.isUndefined(signature) || _.isUndefined(message)) { | ||
return common.handleErrors({ | ||
return self.common.handleErrors({ | ||
message: 'Missing parameters (expected "address", "signature" and "message")', | ||
@@ -28,3 +30,3 @@ code: 1 | ||
} catch(err) { | ||
return common.handleErrors({ | ||
return self.common.handleErrors({ | ||
message: 'Unexpected error: ' + err.message, | ||
@@ -31,0 +33,0 @@ code: 1 |
'use strict'; | ||
var Common = require('./common'); | ||
function StatusController(node) { | ||
this.node = node; | ||
this.common = new Common({log: this.node.log}); | ||
} | ||
StatusController.prototype.show = function(req, res) { | ||
var self = this; | ||
var option = req.query.q; | ||
switch(option) { | ||
case 'getDifficulty': | ||
res.jsonp(this.getDifficulty()); | ||
break; | ||
case 'getLastBlockHash': | ||
res.jsonp(this.getLastBlockHash()); | ||
break; | ||
case 'getBestBlockHash': | ||
res.jsonp(this.getBestBlockHash()); | ||
break; | ||
case 'getInfo': | ||
default: | ||
res.jsonp(this.getInfo()); | ||
case 'getDifficulty': | ||
this.getDifficulty(function(err, result) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
res.jsonp(result); | ||
}); | ||
break; | ||
case 'getLastBlockHash': | ||
res.jsonp(this.getLastBlockHash()); | ||
break; | ||
case 'getBestBlockHash': | ||
this.getBestBlockHash(function(err, result) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
res.jsonp(result); | ||
}); | ||
break; | ||
case 'getInfo': | ||
default: | ||
this.getInfo(function(err, result) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
res.jsonp({ | ||
info: result | ||
}); | ||
}); | ||
} | ||
}; | ||
StatusController.prototype.getInfo = function() { | ||
var info = this.node.services.bitcoind.getInfo(); | ||
return { | ||
info: info | ||
}; | ||
StatusController.prototype.getInfo = function(callback) { | ||
this.node.services.bitcoind.getInfo(function(err, result) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
var info = { | ||
version: result.version, | ||
protocolversion: result.protocolVersion, | ||
blocks: result.blocks, | ||
timeoffset: result.timeOffset, | ||
connections: result.connections, | ||
proxy: result.proxy, | ||
difficulty: result.difficulty, | ||
testnet: result.testnet, | ||
relayfee: result.relayFee, | ||
errors: result.errors, | ||
network: result.network | ||
}; | ||
callback(null, info); | ||
}); | ||
}; | ||
StatusController.prototype.getLastBlockHash = function() { | ||
var hash = this.node.services.db.tip.hash; | ||
var hash = this.node.services.bitcoind.tiphash; | ||
return { | ||
@@ -42,36 +77,55 @@ syncTipHash: hash, | ||
StatusController.prototype.getBestBlockHash = function() { | ||
var hash = this.node.services.bitcoind.getBestBlockHash(); | ||
return { | ||
bestblockhash: hash | ||
}; | ||
StatusController.prototype.getBestBlockHash = function(callback) { | ||
this.node.services.bitcoind.getBestBlockHash(function(err, hash) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
callback(null, { | ||
bestblockhash: hash | ||
}); | ||
}); | ||
}; | ||
StatusController.prototype.getDifficulty = function() { | ||
var info = this.node.services.bitcoind.getInfo(); | ||
return { | ||
difficulty: info.difficulty | ||
}; | ||
StatusController.prototype.getDifficulty = function(callback) { | ||
this.node.services.bitcoind.getInfo(function(err, info) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
callback(null, { | ||
difficulty: info.difficulty | ||
}); | ||
}); | ||
}; | ||
StatusController.prototype.sync = function(req, res) { | ||
var self = this; | ||
var status = 'syncing'; | ||
if(this.node.services.bitcoind.isSynced() && this.node.services.db.tip.__height === this.node.services.bitcoind.height) { | ||
status = 'finished'; | ||
} | ||
// Not exactly the total blockchain height, | ||
// but we will reach 100% when our db and bitcoind are both fully synced | ||
var totalHeight = this.node.services.bitcoind.height / (this.node.services.bitcoind.syncPercentage() / 100); | ||
this.node.services.bitcoind.isSynced(function(err, synced) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
if (synced) { | ||
status = 'finished'; | ||
} | ||
var info = { | ||
status: status, | ||
blockChainHeight: this.node.services.bitcoind.height, | ||
syncPercentage: Math.round(this.node.services.db.tip.__height / totalHeight * 100), | ||
height: this.node.services.db.tip.__height, | ||
error: null, | ||
type: 'bitcore node' | ||
}; | ||
self.node.services.bitcoind.syncPercentage(function(err, percentage) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
var info = { | ||
status: status, | ||
blockChainHeight: self.node.services.bitcoind.height, | ||
syncPercentage: Math.round(percentage), | ||
height: self.node.services.bitcoind.height, | ||
error: null, | ||
type: 'bitcore node' | ||
}; | ||
res.jsonp(info); | ||
res.jsonp(info); | ||
}); | ||
}); | ||
}; | ||
@@ -78,0 +132,0 @@ |
@@ -6,3 +6,3 @@ 'use strict'; | ||
var $ = bitcore.util.preconditions; | ||
var common = require('./common'); | ||
var Common = require('./common'); | ||
var async = require('async'); | ||
@@ -14,2 +14,3 @@ | ||
this.node = node; | ||
this.common = new Common({log: this.node.log}); | ||
} | ||
@@ -26,28 +27,21 @@ | ||
*/ | ||
TxController.prototype.transaction = function(req, res, next, txid) { | ||
TxController.prototype.transaction = function(req, res, next) { | ||
var self = this; | ||
var txid = req.params.txid; | ||
this.node.getTransactionWithBlockInfo(txid, true, function(err, transaction) { | ||
if (err && err instanceof self.node.errors.Transaction.NotFound) { | ||
return common.handleErrors(null, res); | ||
this.node.getDetailedTransaction(txid, function(err, transaction) { | ||
if (err && err.code === -5) { | ||
return self.common.handleErrors(null, res); | ||
} else if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
transaction.populateInputs(self.node.services.db, [], function(err) { | ||
if(err) { | ||
return res.send({ | ||
error: err.toString() | ||
}); | ||
self.transformTransaction(transaction, function(err, transformedTransaction) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
req.transaction = transformedTransaction; | ||
next(); | ||
}); | ||
self.transformTransaction(transaction, function(err, transformedTransaction) { | ||
if (err) { | ||
return common.handleErrors(err, res); | ||
} | ||
req.transaction = transformedTransaction; | ||
next(); | ||
}); | ||
}); | ||
}); | ||
@@ -58,22 +52,19 @@ }; | ||
$.checkArgument(_.isFunction(callback)); | ||
var self = this; | ||
var txid = transaction.id; | ||
var txObj = transaction.toObject(); | ||
var confirmations = 0; | ||
if(transaction.__height >= 0) { | ||
confirmations = this.node.services.db.tip.__height - transaction.__height + 1; | ||
if(transaction.height >= 0) { | ||
confirmations = this.node.services.bitcoind.height - transaction.height + 1; | ||
} | ||
var transformed = { | ||
txid: txObj.hash, | ||
version: txObj.version, | ||
locktime: txObj.nLockTime | ||
txid: transaction.hash, | ||
version: transaction.version, | ||
locktime: transaction.locktime | ||
}; | ||
if(transaction.isCoinbase()) { | ||
if(transaction.coinbase) { | ||
transformed.vin = [ | ||
{ | ||
coinbase: txObj.inputs[0].script, | ||
sequence: txObj.inputs[0].sequenceNumber, | ||
coinbase: transaction.inputs[0].script, | ||
sequence: transaction.inputs[0].sequence, | ||
n: 0 | ||
@@ -83,44 +74,29 @@ } | ||
} else { | ||
transformed.vin = txObj.inputs.map(this.transformInput.bind(this)); | ||
transformed.vin = transaction.inputs.map(this.transformInput.bind(this)); | ||
} | ||
async.map( | ||
Object.keys(txObj.outputs), | ||
function(outputIndex, next) { | ||
outputIndex = parseInt(outputIndex); | ||
var output = txObj.outputs[outputIndex]; | ||
self.transformOutput(txid, output, outputIndex, next); | ||
}, | ||
function(err, vout) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
transformed.vout = transaction.outputs.map(this.transformOutput.bind(this)); | ||
transformed.vout = vout; | ||
transformed.blockhash = transaction.blockHash; | ||
transformed.blockheight = transaction.height; | ||
transformed.confirmations = confirmations; | ||
// TODO consider mempool txs with receivedTime? | ||
var time = transaction.blockTimestamp ? transaction.blockTimestamp : Math.round(Date.now() / 1000); | ||
transformed.time = time; | ||
if (transformed.confirmations) { | ||
transformed.blocktime = transformed.time; | ||
} | ||
transformed.blockhash = transaction.__blockHash; | ||
transformed.blockheight = transaction.__height; | ||
transformed.confirmations = confirmations; | ||
var time = transaction.__timestamp ? transaction.__timestamp : Math.round(Date.now() / 1000); | ||
transformed.time = time; | ||
if (transformed.confirmations) { | ||
transformed.blocktime = transformed.time; | ||
} | ||
if(transaction.coinbase) { | ||
transformed.isCoinBase = true; | ||
} | ||
if(transaction.isCoinbase()) { | ||
transformed.isCoinBase = true; | ||
} | ||
transformed.valueOut = transaction.outputSatoshis / 1e8; | ||
transformed.size = transaction.hex.length / 2; // in bytes | ||
if (!transaction.coinbase) { | ||
transformed.valueIn = transaction.inputSatoshis / 1e8; | ||
transformed.fees = transaction.feeSatoshis / 1e8; | ||
} | ||
transformed.valueOut = transaction.outputAmount / 1e8; | ||
transformed.size = transaction.toBuffer().length; | ||
if(transaction.hasAllUtxoInfo()) { | ||
transformed.valueIn = transaction.inputAmount / 1e8; | ||
transformed.fees = transaction.getFee() / 1e8; | ||
} | ||
callback(null, transformed); | ||
} | ||
); | ||
callback(null, transformed); | ||
}; | ||
@@ -130,3 +106,2 @@ | ||
// Input scripts are validated and can be assumed to be valid | ||
var script = new bitcore.Script(input.script); | ||
var transformed = { | ||
@@ -136,18 +111,16 @@ txid: input.prevTxId, | ||
scriptSig: { | ||
asm: script.toASM(), | ||
asm: input.scriptAsm, | ||
hex: input.script | ||
}, | ||
sequence: input.sequenceNumber, | ||
sequence: input.sequence, | ||
n: index | ||
}; | ||
if(input.output) { | ||
transformed.addr = bitcore.Script(input.output.script).toAddress(this.node.network).toString(); | ||
transformed.valueSat = input.output.satoshis; | ||
transformed.value = input.output.satoshis / 1e8; | ||
transformed.doubleSpentTxID = null; // TODO | ||
//transformed.isConfirmed = null; // TODO | ||
//transformed.confirmations = null; // TODO | ||
//transformed.unconfirmedInput = null; // TODO | ||
} | ||
transformed.addr = input.address; | ||
transformed.valueSat = input.satoshis; | ||
transformed.value = input.satoshis / 1e8; | ||
transformed.doubleSpentTxID = null; // TODO | ||
//transformed.isConfirmed = null; // TODO | ||
//transformed.confirmations = null; // TODO | ||
//transformed.unconfirmedInput = null; // TODO | ||
@@ -157,4 +130,3 @@ return transformed; | ||
TxController.prototype.transformOutput = function(txid, output, index, callback) { | ||
var self = this; | ||
TxController.prototype.transformOutput = function(output, index) { | ||
var transformed = { | ||
@@ -165,42 +137,17 @@ value: (output.satoshis / 1e8).toFixed(8), | ||
hex: output.script, | ||
asm: output.scriptAsm | ||
//reqSigs: null, // TODO | ||
} | ||
}, | ||
spentTxId: output.spentTxId || null, | ||
spentIndex: _.isUndefined(output.spentIndex) ? null : output.spentIndex, | ||
spentHeight: output.spentHeight || null | ||
//spentTs: undefined // TODO | ||
}; | ||
var script; | ||
try { | ||
// Output scripts can be invalid, so we need to try/catch | ||
script = new bitcore.Script(output.script); | ||
} catch (err) { | ||
script = false; | ||
if (output.address) { | ||
transformed.scriptPubKey.addresses = [output.address]; | ||
var address = bitcore.Address(output.address); //TODO return type from bitcore-node | ||
transformed.scriptPubKey.type = address.type; | ||
} | ||
if (script) { | ||
transformed.scriptPubKey.asm = script.toASM(); | ||
var address = script.toAddress(this.node.network); | ||
if (address) { | ||
transformed.scriptPubKey.addresses = [address.toString()]; | ||
transformed.scriptPubKey.type = address.type; | ||
} | ||
} | ||
var options = { | ||
queryMempool: true | ||
}; | ||
self.node.services.address.getInputForOutput( | ||
txid, | ||
index, | ||
options, | ||
function(err, inputResult) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (inputResult) { | ||
transformed.spentTxId = inputResult.inputTxId; | ||
transformed.spentIndex = inputResult.inputIndex; | ||
} | ||
callback(null, transformed); | ||
} | ||
); | ||
return transformed; | ||
}; | ||
@@ -240,10 +187,11 @@ | ||
TxController.prototype.rawTransaction = function(req, res, next, txid) { | ||
TxController.prototype.rawTransaction = function(req, res, next) { | ||
var self = this; | ||
var txid = req.params.txid; | ||
this.node.getTransaction(txid, true, function(err, transaction) { | ||
if (err && err instanceof self.node.errors.Transaction.NotFound) { | ||
return common.handleErrors(null, res); | ||
this.node.getTransaction(txid, function(err, transaction) { | ||
if (err && err.code === -5) { | ||
return self.common.handleErrors(null, res); | ||
} else if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -275,32 +223,30 @@ | ||
if(blockHash) { | ||
self.node.getBlock(blockHash, function(err, block) { | ||
if(err && err.message === 'Block not found.') { | ||
return common.handleErrors(null, res); | ||
self.node.getBlockOverview(blockHash, function(err, block) { | ||
if(err && err.code === -5) { | ||
return self.common.handleErrors(null, res); | ||
} else if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
var blockInfo = self.node.services.bitcoind.getBlockIndex(block.hash); | ||
var txs = block.transactions; | ||
var totalTxs = txs.length; | ||
var totalTxs = block.txids.length; | ||
var txids; | ||
if(!_.isUndefined(page)) { | ||
txs = txs.splice(page * pageLength, pageLength); | ||
var start = page * pageLength; | ||
txids = block.txids.slice(start, start + pageLength); | ||
pagesTotal = Math.ceil(totalTxs / pageLength); | ||
} else { | ||
txids = block.txids; | ||
} | ||
async.mapSeries(txs, function(tx, next) { | ||
tx.__blockHash = block.hash; | ||
tx.__height = blockInfo.height; | ||
tx.__timestamp = block.header.time; | ||
tx.populateInputs(self.node.services.db, [], function(err) { | ||
if(err) { | ||
async.mapSeries(txids, function(txid, next) { | ||
self.node.getDetailedTransaction(txid, function(err, transaction) { | ||
if (err) { | ||
return next(err); | ||
} | ||
self.transformTransaction(tx, next); | ||
self.transformTransaction(transaction, next); | ||
}); | ||
}, function(err, transformed) { | ||
if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -313,2 +259,3 @@ | ||
}); | ||
}); | ||
@@ -323,3 +270,3 @@ } else if(address) { | ||
if(err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -340,3 +287,3 @@ | ||
if (err) { | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -351,3 +298,3 @@ res.jsonp({ | ||
} else { | ||
return common.handleErrors(new Error('Block hash or address expected'), res); | ||
return self.common.handleErrors(new Error('Block hash or address expected'), res); | ||
} | ||
@@ -357,6 +304,7 @@ }; | ||
TxController.prototype.send = function(req, res) { | ||
var self = this; | ||
this.node.sendTransaction(req.body.rawtx, function(err, txid) { | ||
if(err) { | ||
// TODO handle specific errors | ||
return common.handleErrors(err, res); | ||
return self.common.handleErrors(err, res); | ||
} | ||
@@ -363,0 +311,0 @@ |
'use strict'; | ||
var _ = require('lodash'); | ||
var async = require('async'); | ||
var Common = require('./common'); | ||
function UtilsController(node) { | ||
this.node = node; | ||
this.common = new Common({log: this.node.log}); | ||
} | ||
@@ -13,12 +17,20 @@ | ||
var result = nbBlocks.map(function(n) { | ||
async.map(nbBlocks, function(n, next) { | ||
var num = parseInt(n); | ||
// Insight and Bitcoin JSON-RPC return bitcoin for this value (instead of satoshis). | ||
var fee = self.node.services.bitcoind.estimateFee(num) / 1e8; | ||
return [num, fee]; | ||
self.node.services.bitcoind.estimateFee(num, function(err, fee) { | ||
if (err) { | ||
return next(err); | ||
} | ||
next(null, [num, fee]); | ||
}); | ||
}, function(err, result) { | ||
if (err) { | ||
return self.common.handleErrors(err, res); | ||
} | ||
res.jsonp(_.zipObject(result)); | ||
}); | ||
res.jsonp(_.zipObject(result)); | ||
}; | ||
module.exports = UtilsController; |
{ | ||
"name": "insight-api", | ||
"description": "A Bitcoin blockchain REST and web socket API service for Bitcore Node.", | ||
"version": "0.3.2", | ||
"version": "0.4.0", | ||
"repository": "git://github.com/bitpay/insight-api.git", | ||
@@ -67,12 +67,15 @@ "contributors": [ | ||
"body-parser": "^1.13.3", | ||
"compression": "^1.6.1", | ||
"lodash": "^2.4.1", | ||
"lru-cache": "^4.0.1", | ||
"morgan": "^1.7.0", | ||
"request": "^2.64.0" | ||
}, | ||
"devDependencies": { | ||
"chai": "*", | ||
"mocha": "~1.16.2", | ||
"chai": "^3.5.0", | ||
"mocha": "^2.4.5", | ||
"proxyquire": "^1.7.2", | ||
"should": "^2.1.1", | ||
"should": "^8.3.1", | ||
"sinon": "^1.10.3" | ||
} | ||
} |
@@ -200,6 +200,6 @@ [ | ||
{ | ||
"poolName": "Slush", | ||
"url": "https://mining.bitcoin.cz/", | ||
"poolName": "SlushPool", | ||
"url": "https://slushpool.com/", | ||
"searchStrings": [ | ||
"slush" | ||
"/slush/" | ||
] | ||
@@ -206,0 +206,0 @@ }, |
168
README.md
@@ -5,3 +5,3 @@ # Insight API | ||
This is a backend-only service. If you're looking for the web frontend application, take a look at https://github.com/bitpay/insight. | ||
This is a backend-only service. If you're looking for the web frontend application, take a look at https://github.com/bitpay/insight-ui. | ||
@@ -22,6 +22,58 @@ ## Getting Started | ||
- [Bitcore Node 0.2.x](https://github.com/bitpay/bitcore-node) | ||
- [Bitcore Node 3.x](https://github.com/bitpay/bitcore-node) | ||
**Note:** You can use an existing Bitcoin data directory, however `txindex` needs to be set to true in `bitcoin.conf`. | ||
**Note:** You can use an existing Bitcoin data directory, however `txindex`, `addressindex`, `timestampindex` and `spentindex` needs to be set to true in `bitcoin.conf`, as well as a few other additional fields. | ||
## Notes on Upgrading from v0.3 | ||
The unspent outputs format now has `satoshis` and `height`: | ||
``` | ||
[ | ||
{ | ||
"address":"mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", | ||
"txid":"d5f8a96faccf79d4c087fa217627bb1120e83f8ea1a7d84b1de4277ead9bbac1", | ||
"vout":0, | ||
"scriptPubKey":"76a91453c0307d6851aa0ce7825ba883c6bd9ad242b48688ac", | ||
"amount":0.000006, | ||
"satoshis":600, | ||
"confirmations":0, | ||
"ts":1461349425 | ||
}, | ||
{ | ||
"address": "mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", | ||
"txid": "bc9df3b92120feaee4edc80963d8ed59d6a78ea0defef3ec3cb374f2015bfc6e", | ||
"vout": 1, | ||
"scriptPubKey": "76a91453c0307d6851aa0ce7825ba883c6bd9ad242b48688ac", | ||
"amount": 0.12345678, | ||
"satoshis: 12345678, | ||
"confirmations": 1, | ||
"height": 300001 | ||
} | ||
] | ||
``` | ||
The `timestamp` property will only be set for unconfirmed transactions and `height` can be used for determining block order. The `confirmationsFromCache` is nolonger set or necessary, confirmation count is only cached for the time between blocks. | ||
There is a new `GET` endpoint or raw blocks at `/rawblock/<blockHash>`: | ||
Response format: | ||
``` | ||
{ | ||
"rawblock": "blockhexstring..." | ||
} | ||
``` | ||
There are a few changes to the `GET` endpoint for `/addr/[:address]`: | ||
- The list of txids in an address summary does not include orphaned transactions | ||
- The txids will be sorted in block order | ||
- The list of txids will be limited at 1000 txids | ||
- There are two new query options "from" and "to" for pagination of the txids (e.g. `/addr/[:address]?from=1000&to=2000`) | ||
Some additional general notes: | ||
- The transaction history for an address will be sorted in block order | ||
- The response for the `/sync` endpoint does not include `startTs` and `endTs` as the sync is no longer relevant as indexes are built in bitcoind. | ||
- The endpoint for `/peer` is no longer relevant connection to bitcoind is via ZMQ. | ||
- `/tx` endpoint results will now include block height, and spentTx related fields will be set to `null` if unspent. | ||
- `/block` endpoint results does not include `confirmations` and will include `poolInfo`. | ||
## Notes on Upgrading from v0.2 | ||
@@ -66,6 +118,58 @@ | ||
``` | ||
{"blockHash":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"} | ||
{ | ||
"blockHash":"000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f" | ||
} | ||
``` | ||
which is the hash of the Genesis block (0 height) | ||
### Raw Block | ||
``` | ||
/insight-api/rawblock/[:blockHash] | ||
/insight-api/rawblock/[:blockHeight] | ||
``` | ||
This would return: | ||
``` | ||
{ | ||
"rawblock":"blockhexstring..." | ||
} | ||
``` | ||
### Block Summaries | ||
Get block summaries by date: | ||
``` | ||
/insight-api/blocks?limit=3&blockDate=2016-04-22 | ||
``` | ||
Example response: | ||
``` | ||
{ | ||
"blocks": [ | ||
{ | ||
"height": 408495, | ||
"size": 989237, | ||
"hash": "00000000000000000108a1f4d4db839702d72f16561b1154600a26c453ecb378", | ||
"time": 1461360083, | ||
"txlength": 1695, | ||
"poolInfo": { | ||
"poolName": "BTCC Pool", | ||
"url": "https://pool.btcc.com/" | ||
} | ||
} | ||
], | ||
"length": 1, | ||
"pagination": { | ||
"next": "2016-04-23", | ||
"prev": "2016-04-21", | ||
"currentTs": 1461369599, | ||
"current": "2016-04-22", | ||
"isToday": true, | ||
"more": true, | ||
"moreTs": 1461369600 | ||
} | ||
} | ||
``` | ||
### Transaction | ||
@@ -81,4 +185,5 @@ ``` | ||
``` | ||
/insight-api/addr/[:addr][?noTxList=1&noCache=1] | ||
/insight-api/addr/[:addr][?noTxList=1][&from=&to=] | ||
/insight-api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5?noTxList=1 | ||
/insight-api/addr/mmvP3mTe53qxHdPqXEvdu8WdC7GfQ2vmx5?from=1000&to=2000 | ||
``` | ||
@@ -97,26 +202,27 @@ | ||
``` | ||
/insight-api/addr/[:addr]/utxo[?noCache=1] | ||
/insight-api/addr/[:addr]/utxo | ||
``` | ||
Sample return: | ||
``` json | ||
``` | ||
[ | ||
{ | ||
"address": "n2PuaAguxZqLddRbTnAoAuwKYgN2w2hZk7", | ||
"txid": "dbfdc2a0d22a8282c4e7be0452d595695f3a39173bed4f48e590877382b112fc", | ||
"vout": 0, | ||
"ts": 1401276201, | ||
"scriptPubKey": "76a914e50575162795cd77366fb80d728e3216bd52deac88ac", | ||
"amount": 0.001, | ||
"confirmations": 3 | ||
}, | ||
{ | ||
"address": "n2PuaAguxZqLddRbTnAoAuwKYgN2w2hZk7", | ||
"txid": "e2b82af55d64f12fd0dd075d0922ee7d6a300f58fe60a23cbb5831b31d1d58b4", | ||
"vout": 0, | ||
"ts": 1401226410, | ||
"scriptPubKey": "76a914e50575162795cd77366fb80d728e3216bd52deac88ac", | ||
"amount": 0.001, | ||
"confirmation": 6, | ||
"confirmationsFromCache": true | ||
} | ||
{ | ||
"address":"mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", | ||
"txid":"d5f8a96faccf79d4c087fa217627bb1120e83f8ea1a7d84b1de4277ead9bbac1", | ||
"vout":0, | ||
"scriptPubKey":"76a91453c0307d6851aa0ce7825ba883c6bd9ad242b48688ac", | ||
"amount":0.000006, | ||
"satoshis":600, | ||
"confirmations":0, | ||
"ts":1461349425 | ||
}, | ||
{ | ||
"address": "mo9ncXisMeAoXwqcV5EWuyncbmCcQN4rVs", | ||
"txid": "bc9df3b92120feaee4edc80963d8ed59d6a78ea0defef3ec3cb374f2015bfc6e", | ||
"vout": 1, | ||
"scriptPubKey": "76a91453c0307d6851aa0ce7825ba883c6bd9ad242b48688ac", | ||
"amount": 0.12345678, | ||
"satoshis: 12345678, | ||
"confirmations": 1, | ||
"height": 300001 | ||
} | ||
] | ||
@@ -234,3 +340,3 @@ ``` | ||
### Live Network P2P Data Sync Status (Bitcoind runs in the same process) | ||
### Live Network P2P Data Sync Status | ||
``` | ||
@@ -264,3 +370,3 @@ /insight-api/peer | ||
'tx': new transaction received from network. This event is published in the 'inv' room. Data will be a app/models/Transaction object. | ||
`tx`: new transaction received from network. This event is published in the 'inv' room. Data will be a app/models/Transaction object. | ||
Sample output: | ||
@@ -276,3 +382,3 @@ ``` | ||
'block': new block received from network. This event is published in the 'inv' room. Data will be a app/models/Block object. | ||
`block`: new block received from network. This event is published in the `inv` room. Data will be a app/models/Block object. | ||
Sample output: | ||
@@ -287,5 +393,5 @@ ``` | ||
'<bitcoinAddress>': new transaction concerning <bitcoinAddress> received from network. This event is published in the '<bitcoinAddress>' room. | ||
`<bitcoinAddress>`: new transaction concerning <bitcoinAddress> received from network. This event is published in the `<bitcoinAddress>` room. | ||
'status': every 1% increment on the sync task, this event will be triggered. This event is published in the 'sync' room. | ||
`status`: every 1% increment on the sync task, this event will be triggered. This event is published in the `sync` room. | ||
@@ -292,0 +398,0 @@ Sample output: |
@@ -12,79 +12,79 @@ 'use strict'; | ||
{ | ||
"address": "mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er", | ||
"satoshis": 2782729129, | ||
"height": 534105, | ||
"confirmations": 123, | ||
"timestamp": 1441068774, | ||
"fees": 35436, | ||
"outputIndexes": [ | ||
'address': 'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er', | ||
'satoshis': 2782729129, | ||
'height': 534105, | ||
'confirmations': 123, | ||
'timestamp': 1441068774, | ||
'fees': 35436, | ||
'outputIndexes': [ | ||
0 | ||
], | ||
"inputIndexes": [], | ||
"tx": { | ||
"hash": "bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7", | ||
"version": 1, | ||
"inputs": [ | ||
'inputIndexes': [], | ||
'tx': { | ||
'hash': 'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7', | ||
'version': 1, | ||
'inputs': [ | ||
{ | ||
"prevTxId": "ea5e5bafbf29cdf6f6097ab344128477e67889d4d6203cb43594836daa6cc425", | ||
"outputIndex": 1, | ||
"sequenceNumber": 4294967294, | ||
"script": "483045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a6012103acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6", | ||
"scriptString": "72 0x3045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a601 33 0x03acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6", | ||
"output": { | ||
"satoshis": 2796764565, | ||
"script": "76a91488b1fe8aec5ae4358a11447a2f22b2781faedb9b88ac" | ||
'prevTxId': 'ea5e5bafbf29cdf6f6097ab344128477e67889d4d6203cb43594836daa6cc425', | ||
'outputIndex': 1, | ||
'sequenceNumber': 4294967294, | ||
'script': '483045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a6012103acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6', | ||
'scriptString': '72 0x3045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a601 33 0x03acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6', | ||
'output': { | ||
'satoshis': 2796764565, | ||
'script': '76a91488b1fe8aec5ae4358a11447a2f22b2781faedb9b88ac' | ||
} | ||
} | ||
], | ||
"outputs": [ | ||
'outputs': [ | ||
{ | ||
"satoshis": 2782729129, | ||
"script": "76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac" | ||
'satoshis': 2782729129, | ||
'script': '76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac' | ||
}, | ||
{ | ||
"satoshis": 14000000, | ||
"script": "76a9149713201957f42379e574d7c70d506ee49c2c8ad688ac" | ||
'satoshis': 14000000, | ||
'script': '76a9149713201957f42379e574d7c70d506ee49c2c8ad688ac' | ||
} | ||
], | ||
"nLockTime": 534089 | ||
'nLockTime': 534089 | ||
} | ||
}, | ||
{ | ||
"address": "mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er", | ||
"satoshis": -2782729129, | ||
"height": 534110, | ||
"confirmations": 118, | ||
"timestamp": 1441072817, | ||
"fees": 35437, | ||
"outputIndexes": [], | ||
"inputIndexes": [ | ||
"0" | ||
'address': 'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er', | ||
'satoshis': -2782729129, | ||
'height': 534110, | ||
'confirmations': 118, | ||
'timestamp': 1441072817, | ||
'fees': 35437, | ||
'outputIndexes': [], | ||
'inputIndexes': [ | ||
'0' | ||
], | ||
"tx": { | ||
"hash": "01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3", | ||
"version": 1, | ||
"inputs": [ | ||
'tx': { | ||
'hash': '01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3', | ||
'version': 1, | ||
'inputs': [ | ||
{ | ||
"prevTxId": "bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7", | ||
"outputIndex": 0, | ||
"sequenceNumber": 4294967294, | ||
"script": "47304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d5640121034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24", | ||
"scriptString": "71 0x304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d56401 33 0x034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24", | ||
"output": { | ||
"satoshis": 2782729129, | ||
"script": "76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac" | ||
'prevTxId': 'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7', | ||
'outputIndex': 0, | ||
'sequenceNumber': 4294967294, | ||
'script': '47304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d5640121034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24', | ||
'scriptString': '71 0x304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d56401 33 0x034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24', | ||
'output': { | ||
'satoshis': 2782729129, | ||
'script': '76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac' | ||
} | ||
} | ||
], | ||
"outputs": [ | ||
'outputs': [ | ||
{ | ||
"satoshis": 2764693692, | ||
"script": "76a91456e446bc3489543d8324c6d0271524c0bd0506dd88ac" | ||
'satoshis': 2764693692, | ||
'script': '76a91456e446bc3489543d8324c6d0271524c0bd0506dd88ac' | ||
}, | ||
{ | ||
"satoshis": 18000000, | ||
"script": "76a914011d2963b619186a318f768dddfd98cd553912a088ac" | ||
'satoshis': 18000000, | ||
'script': '76a914011d2963b619186a318f768dddfd98cd553912a088ac' | ||
} | ||
], | ||
"nLockTime": 534099 | ||
'nLockTime': 534099 | ||
} | ||
@@ -95,49 +95,52 @@ } | ||
var tx = bitcore.Transaction().fromObject({ | ||
"hash": "63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73", | ||
"version": 1, | ||
"inputs": [ | ||
var tx = { | ||
height: 534181, | ||
blockTimestamp: 1441116143, | ||
blockHash: '0000000000000041ddc94ecf4f86a456a83b2e320c36c6f0c13ff92c7e75f013', | ||
hex: '0100000002f379708395d0a0357514205a3758a0317926428356e54a09089852fc6f7297ea010000008a473044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e40141040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964dffffffffb758ffd4c31693d9620f326385404530a079d5e60a90b94e46d3c2dbc29c0a98020000008a473044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b014104d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2ffffffff03605b0300000000001976a914b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d88ac40992d03000000001976a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac256c0400000000001976a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac00000000', | ||
hash: '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73', | ||
version: 1, | ||
inputSatoshis: 53839829, | ||
outputSatoshis: 53829829, | ||
feeSatoshis: 10000, | ||
inputs: [ | ||
{ | ||
"prevTxId": "ea97726ffc529808094ae5568342267931a058375a20147535a0d095837079f3", | ||
"outputIndex": 1, | ||
"sequenceNumber": 4294967295, | ||
"script": "473044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e40141040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d", | ||
"scriptString": "71 0x3044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e401 65 0x040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d", | ||
"output": { | ||
"satoshis": 53540000, | ||
"script": "76a91454dcfbff9e109bf369e457f6b0f869f4e647076488ac" | ||
} | ||
address: 'moFfnRwt77pApKnnU6m5uocFaa43aAYpt5', | ||
prevTxId: 'ea97726ffc529808094ae5568342267931a058375a20147535a0d095837079f3', | ||
outputIndex: 1, | ||
sequence: 4294967295, | ||
script: '473044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e40141040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d', | ||
scriptAsm: '71 0x3044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e401 65 0x040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d', | ||
satoshis: 53540000, | ||
}, | ||
{ | ||
"prevTxId": "980a9cc2dbc2d3464eb9900ae6d579a03045408563320f62d99316c3d4ff58b7", | ||
"outputIndex": 2, | ||
"sequenceNumber": 4294967295, | ||
"script": "473044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b014104d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2", | ||
"scriptString": "71 0x3044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b01 65 0x04d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2", | ||
"output": { | ||
"satoshis": 299829, | ||
"script": "76a914db731c9ebf3874d75ee26b9c19b692d278c283f788ac" | ||
} | ||
address: 'n1XJBAyU4hNR4xRtY3UxnmAteoJX83p5qv', | ||
prevTxId: '980a9cc2dbc2d3464eb9900ae6d579a03045408563320f62d99316c3d4ff58b7', | ||
outputIndex: 2, | ||
sequence: 4294967295, | ||
script: '473044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b014104d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2', | ||
scriptAsm: '71 0x3044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b01 65 0x04d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2', | ||
satoshis: 299829, | ||
} | ||
], | ||
"outputs": [ | ||
outputs: [ | ||
{ | ||
"satoshis": 220000, | ||
"script": "76a914b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d88ac" | ||
satoshis: 220000, | ||
script: '76a914b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d88ac', | ||
address: 'mxT2KzTUQvsaYYothDtjcdvyAdaHA9ofMp' | ||
}, | ||
{ | ||
"satoshis": 53320000, | ||
"script": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac" | ||
satoshis: 53320000, | ||
address: 'mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK', | ||
script: '76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac' | ||
}, | ||
{ | ||
"satoshis": 289829, | ||
"script": "76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac" | ||
address: 'moZY18rGNmh4YCPeugtGW46AkkWMQttBUD', | ||
satoshis: 289829, | ||
script: '76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac' | ||
} | ||
], | ||
"nLockTime": 0 | ||
}); | ||
locktime: 0 | ||
}; | ||
tx.__height = 534181; | ||
tx.__timestamp = 1441116143; | ||
tx.__blockHash = '0000000000000041ddc94ecf4f86a456a83b2e320c36c6f0c13ff92c7e75f013'; | ||
var txinfos2 = { | ||
@@ -154,20 +157,20 @@ totalCount: 1, | ||
{ | ||
"address": "mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK", | ||
"txid": "63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73", | ||
"outputIndex": 1, | ||
"timestamp": 1441116143, | ||
"satoshis": 53320000, | ||
"script": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac", | ||
"blockHeight": 534181, | ||
"confirmations": 50 | ||
'address': 'mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK', | ||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73', | ||
'outputIndex': 1, | ||
'timestamp': 1441116143, | ||
'satoshis': 53320000, | ||
'script': '76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac', | ||
'height': 534181, | ||
'confirmations': 50 | ||
}, | ||
{ | ||
"address": "moZY18rGNmh4YCPeugtGW46AkkWMQttBUD", | ||
"txid": "63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73", | ||
"outputIndex": 2, | ||
"timestamp": 1441116143, | ||
"satoshis": 289829, | ||
"script": "76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac", | ||
"blockHeight": 534181, | ||
"confirmations": 50 | ||
'address': 'moZY18rGNmh4YCPeugtGW46AkkWMQttBUD', | ||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73', | ||
'outputIndex': 2, | ||
'timestamp': 1441116143, | ||
'satoshis': 289829, | ||
'script': '76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac', | ||
'height': 534181, | ||
'confirmations': 50 | ||
} | ||
@@ -202,17 +205,17 @@ ]; | ||
var insight = { | ||
"addrStr": "mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er", | ||
"balance": 0, | ||
"balanceSat": 0, | ||
"totalReceived": 27.82729129, | ||
"totalReceivedSat": 2782729129, | ||
"totalSent": 27.82729129, | ||
"totalSentSat": 2782729129, | ||
"unconfirmedBalance": 0, | ||
"unconfirmedBalanceSat": 0, | ||
"unconfirmedTxApperances": 0, | ||
"txApperances": 2, | ||
"transactions": [ | ||
"bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7", | ||
"01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3" | ||
] | ||
'addrStr': 'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er', | ||
'balance': 0, | ||
'balanceSat': 0, | ||
'totalReceived': 27.82729129, | ||
'totalReceivedSat': 2782729129, | ||
'totalSent': 27.82729129, | ||
'totalSentSat': 2782729129, | ||
'unconfirmedBalance': 0, | ||
'unconfirmedBalanceSat': 0, | ||
'unconfirmedTxApperances': 0, | ||
'txApperances': 2, | ||
'transactions': [ | ||
'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7', | ||
'01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3' | ||
] | ||
}; | ||
@@ -229,2 +232,26 @@ | ||
it('handle error', function() { | ||
var testnode = {}; | ||
testnode.log = {}; | ||
testnode.log.error = sinon.stub(); | ||
var controller = new AddressController(testnode); | ||
controller.getAddressSummary = sinon.stub().callsArgWith(2, new Error('test')); | ||
var req = { | ||
query: { | ||
noTxList: 1 | ||
}, | ||
addr: 'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er' | ||
}; | ||
var send = sinon.stub(); | ||
var status = sinon.stub().returns({send: send}); | ||
var res = { | ||
status: status | ||
}; | ||
controller.show(req, res); | ||
send.callCount.should.equal(1); | ||
status.callCount.should.equal(1); | ||
status.args[0][0].should.equal(503); | ||
send.args[0][0].should.equal('test'); | ||
}); | ||
it('/balance', function(done) { | ||
@@ -285,12 +312,14 @@ var insight = 0; | ||
var insight = [ | ||
{ | ||
"address": "mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK", | ||
"txid": "63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73", | ||
"vout": 1, | ||
"ts": 1441116143, | ||
"scriptPubKey": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac", | ||
"amount": 0.5332, | ||
"confirmations": 50, | ||
"confirmationsFromCache": true | ||
} | ||
{ | ||
'address': 'mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK', | ||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73', | ||
'vout': 1, | ||
'ts': 1441116143, | ||
'scriptPubKey': '76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac', | ||
'amount': 0.5332, | ||
'confirmations': 50, | ||
'height': 534181, | ||
'satoshis': 53320000, | ||
'confirmationsFromCache': true | ||
} | ||
]; | ||
@@ -305,3 +334,8 @@ | ||
var node = { | ||
getUnspentOutputs: sinon.stub().callsArgWith(2, null, utxos.slice(0, 1)) | ||
services: { | ||
bitcoind: { | ||
height: 534230 | ||
} | ||
}, | ||
getAddressUnspentOutputs: sinon.stub().callsArgWith(2, null, utxos.slice(0, 1)) | ||
}; | ||
@@ -330,22 +364,26 @@ | ||
var insight = [ | ||
{ | ||
"address": "mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK", | ||
"txid": "63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73", | ||
"vout": 1, | ||
"ts": 1441116143, | ||
"scriptPubKey": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac", | ||
"amount": 0.5332, | ||
"confirmations": 50, | ||
"confirmationsFromCache": true | ||
}, | ||
{ | ||
"address": "moZY18rGNmh4YCPeugtGW46AkkWMQttBUD", | ||
"txid": "63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73", | ||
"vout": 2, | ||
"ts": 1441116143, | ||
"scriptPubKey": "76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac", | ||
"amount": 0.00289829, | ||
"confirmations": 50, | ||
"confirmationsFromCache": true | ||
} | ||
{ | ||
'address': 'mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK', | ||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73', | ||
'vout': 1, | ||
'ts': 1441116143, | ||
'scriptPubKey': '76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac', | ||
'amount': 0.5332, | ||
'height': 534181, | ||
'satoshis': 53320000, | ||
'confirmations': 50, | ||
'confirmationsFromCache': true | ||
}, | ||
{ | ||
'address': 'moZY18rGNmh4YCPeugtGW46AkkWMQttBUD', | ||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73', | ||
'vout': 2, | ||
'ts': 1441116143, | ||
'scriptPubKey': '76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac', | ||
'amount': 0.00289829, | ||
'height': 534181, | ||
'satoshis': 289829, | ||
'confirmations': 50, | ||
'confirmationsFromCache': true | ||
} | ||
]; | ||
@@ -362,3 +400,8 @@ | ||
var node = { | ||
getUnspentOutputs: sinon.stub().callsArgWith(2, null, utxos) | ||
services: { | ||
bitcoind: { | ||
height: 534230 | ||
} | ||
}, | ||
getAddressUnspentOutputs: sinon.stub().callsArgWith(2, null, utxos) | ||
}; | ||
@@ -387,137 +430,146 @@ | ||
var insight = { | ||
"totalItems": 1, | ||
"from": 0, | ||
"to": 1, | ||
"items": [ | ||
'totalItems': 1, | ||
'from': 0, | ||
'to': 1, | ||
'items': [ | ||
{ | ||
'txid': '63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73', | ||
'version': 1, | ||
'locktime': 0, | ||
'vin': [ | ||
{ | ||
"txid": "63b68becb0e514b32317f4b29a5cf0627d4087e54ac17f686fcb1d9a27680f73", | ||
"version": 1, | ||
"locktime": 0, | ||
"vin": [ | ||
{ | ||
"txid": "ea97726ffc529808094ae5568342267931a058375a20147535a0d095837079f3", | ||
"vout": 1, | ||
"scriptSig": { | ||
"asm": "3044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e401 040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d", | ||
"hex": "473044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e40141040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d" | ||
}, | ||
"sequence": 4294967295, | ||
"n": 0, | ||
"addr": "moFfnRwt77pApKnnU6m5uocFaa43aAYpt5", | ||
"valueSat": 53540000, | ||
"value": 0.5354, | ||
"doubleSpentTxID": null | ||
}, | ||
{ | ||
"txid": "980a9cc2dbc2d3464eb9900ae6d579a03045408563320f62d99316c3d4ff58b7", | ||
"vout": 2, | ||
"scriptSig": { | ||
"asm": "3044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b01 04d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2", | ||
"hex": "473044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b014104d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2" | ||
}, | ||
"sequence": 4294967295, | ||
"n": 1, | ||
"addr": "n1XJBAyU4hNR4xRtY3UxnmAteoJX83p5qv", | ||
"valueSat": 299829, | ||
"value": 0.00299829, | ||
"doubleSpentTxID": null | ||
} | ||
'txid': 'ea97726ffc529808094ae5568342267931a058375a20147535a0d095837079f3', | ||
'vout': 1, | ||
'scriptSig': { | ||
'asm': '3044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e401 040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d', | ||
'hex': '473044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e40141040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d' | ||
}, | ||
'sequence': 4294967295, | ||
'n': 0, | ||
'addr': 'moFfnRwt77pApKnnU6m5uocFaa43aAYpt5', | ||
'valueSat': 53540000, | ||
'value': 0.5354, | ||
'doubleSpentTxID': null | ||
}, | ||
{ | ||
'txid': '980a9cc2dbc2d3464eb9900ae6d579a03045408563320f62d99316c3d4ff58b7', | ||
'vout': 2, | ||
'scriptSig': { | ||
'asm': '3044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b01 04d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2', | ||
'hex': '473044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b014104d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2' | ||
}, | ||
'sequence': 4294967295, | ||
'n': 1, | ||
'addr': 'n1XJBAyU4hNR4xRtY3UxnmAteoJX83p5qv', | ||
'valueSat': 299829, | ||
'value': 0.00299829, | ||
'doubleSpentTxID': null | ||
} | ||
], | ||
'vout': [ | ||
{ | ||
'value': '0.00220000', | ||
'n': 0, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a914b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d88ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mxT2KzTUQvsaYYothDtjcdvyAdaHA9ofMp' | ||
] | ||
}, | ||
'spentHeight': null, | ||
'spentIndex': null, | ||
'spentTxId': null | ||
}, | ||
{ | ||
'value': '0.53320000', | ||
'n': 1, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 d2ec20bb8e5f25a52f730384b803d95683250e0b OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK' | ||
], | ||
"vout": [ | ||
{ | ||
"value": "0.00220000", | ||
"n": 0, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a914b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d88ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mxT2KzTUQvsaYYothDtjcdvyAdaHA9ofMp" | ||
] | ||
} | ||
}, | ||
{ | ||
"value": "0.53320000", | ||
"n": 1, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 d2ec20bb8e5f25a52f730384b803d95683250e0b OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a914d2ec20bb8e5f25a52f730384b803d95683250e0b88ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mzkD4nmQ8ixqxySdBgsXTpgvAMK5iRZpNK" | ||
] | ||
} | ||
}, | ||
{ | ||
"value": "0.00289829", | ||
"n": 2, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 583df9fa56ad961051e00ca93e68dfaf1eab9ec5 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"moZY18rGNmh4YCPeugtGW46AkkWMQttBUD" | ||
] | ||
} | ||
} | ||
], | ||
"blockhash": "0000000000000041ddc94ecf4f86a456a83b2e320c36c6f0c13ff92c7e75f013", | ||
"blockheight": 534181, | ||
"confirmations": 52, | ||
"time": 1441116143, | ||
"blocktime": 1441116143, | ||
"valueOut": 0.53829829, | ||
"size": 470, | ||
"valueIn": 0.53839829, | ||
"fees": 0.0001, | ||
"firstSeenTs": 1441108193 | ||
}, | ||
'spentHeight': null, | ||
'spentIndex': null, | ||
'spentTxId': null | ||
}, | ||
{ | ||
'value': '0.00289829', | ||
'n': 2, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 583df9fa56ad961051e00ca93e68dfaf1eab9ec5 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a914583df9fa56ad961051e00ca93e68dfaf1eab9ec588ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'moZY18rGNmh4YCPeugtGW46AkkWMQttBUD' | ||
] | ||
}, | ||
'spentHeight': null, | ||
'spentIndex': null, | ||
'spentTxId': null | ||
} | ||
] | ||
], | ||
'blockhash': '0000000000000041ddc94ecf4f86a456a83b2e320c36c6f0c13ff92c7e75f013', | ||
'blockheight': 534181, | ||
'confirmations': 52, | ||
'time': 1441116143, | ||
'blocktime': 1441116143, | ||
'valueOut': 0.53829829, | ||
'size': 470, | ||
'valueIn': 0.53839829, | ||
'fees': 0.0001, | ||
'firstSeenTs': 1441108193 | ||
} | ||
] | ||
}; | ||
var todos = { | ||
"items": [ | ||
'items': [ | ||
{ | ||
"vin": [ | ||
'vin': [ | ||
{ | ||
"scriptSig": { | ||
"asm": "3044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e401 040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d" | ||
'scriptSig': { | ||
'asm': '3044022054233934268b30be779fad874ef42e8db928ba27a1b612d5f111b3ee95eb271c022024272bbaf2dcc4050bd3b9dfa3c93884f6ba6ad7d257598b8245abb65b5ab1e401 040682fdb281a8533e21e13dfd1fcfa424912a85b6cdc4136b5842c85de05ac1f0e4a013f20702adeb53329de13b2ef388e5ed6244676f4f1ee4ee685ab607964d' | ||
} | ||
}, | ||
{ | ||
"scriptSig": { | ||
"asm": "3044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b01 04d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2" | ||
'scriptSig': { | ||
'asm': '3044022044938ac3f8fcb8da29011df6397ed28cc7e894cdc35d596d4f3623bd8c7e465f022014829c6e0bd7ee97a1bcfef6b85c5fd232653f289394fc6ce6ebb41c73403f1b01 04d9ccf88efc6e5be3151fae5e848efd94c91d75e7bf621f9f724a8caff51415338525d3239fae6b93826edf759dd562f77693e55dfa852ffd96a92d683db590f2' | ||
} | ||
} | ||
], | ||
"vout": [ | ||
'vout': [ | ||
{ | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d OP_EQUALVERIFY OP_CHECKSIG", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [] | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 b9bbd76588d9e4e09f0369a9aa0b2749a11c4e8d OP_EQUALVERIFY OP_CHECKSIG', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [] | ||
} | ||
}, | ||
{ | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 d2ec20bb8e5f25a52f730384b803d95683250e0b OP_EQUALVERIFY OP_CHECKSIG", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [] | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 d2ec20bb8e5f25a52f730384b803d95683250e0b OP_EQUALVERIFY OP_CHECKSIG', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [] | ||
} | ||
}, | ||
{ | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 583df9fa56ad961051e00ca93e68dfaf1eab9ec5 OP_EQUALVERIFY OP_CHECKSIG", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [] | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 583df9fa56ad961051e00ca93e68dfaf1eab9ec5 OP_EQUALVERIFY OP_CHECKSIG', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [] | ||
} | ||
} | ||
], | ||
"firstSeenTs": 1441108193 | ||
'firstSeenTs': 1441108193 | ||
} | ||
@@ -530,9 +582,4 @@ ] | ||
services: { | ||
db: { | ||
tip: { | ||
__height: 534232 | ||
} | ||
}, | ||
address: { | ||
getInputForOutput: sinon.stub().callsArgWith(3, null, false), | ||
bitcoind: { | ||
height: 534232 | ||
} | ||
@@ -539,0 +586,0 @@ }, |
@@ -16,2 +16,4 @@ 'use strict'; | ||
prevHash: '00000000000001a55f3214e9172eb34b20e0bc5bd6b8007f3f149fca2c8991a4', | ||
nextHash: '000000000001e866a8057cde0c650796cb8a59e0e6038dc31c69d7ca6649627d', | ||
confirmations: 119, | ||
height: 533974 | ||
@@ -23,2 +25,3 @@ }, | ||
prevHash: '00000000000006bd8fe9e53780323c0e85719eca771022e1eb6d10c62195c441', | ||
confirmations: 119, | ||
height: 533951 | ||
@@ -55,5 +58,5 @@ }, | ||
'tx': [ | ||
'25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd', | ||
'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0', | ||
'2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1' | ||
'25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd', | ||
'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0', | ||
'2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1' | ||
], | ||
@@ -75,13 +78,9 @@ 'time': 1440987503, | ||
var node = { | ||
log: sinon.stub(), | ||
getBlock: sinon.stub().callsArgWith(1, null, bitcoreBlock), | ||
services: { | ||
bitcoind: { | ||
getNextBlockHash: sinon.stub().returns('000000000001e866a8057cde0c650796cb8a59e0e6038dc31c69d7ca6649627d'), | ||
getBlockIndex: sinon.stub().returns(blockIndexes['0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7']), | ||
isMainChain: sinon.stub().returns(true) | ||
}, | ||
db: { | ||
tip: { | ||
__height: 534092 | ||
} | ||
getBlockHeader: sinon.stub().callsArgWith(1, null, blockIndexes['0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7']), | ||
isMainChain: sinon.stub().returns(true), | ||
height: 534092 | ||
} | ||
@@ -92,4 +91,9 @@ } | ||
it('block data should be correct', function(done) { | ||
var controller = new BlockController(node); | ||
var req = {}; | ||
var controller = new BlockController({node: node}); | ||
var hash = '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7'; | ||
var req = { | ||
params: { | ||
blockHash: hash | ||
} | ||
}; | ||
var res = {}; | ||
@@ -102,6 +106,3 @@ var next = function() { | ||
}; | ||
var hash = '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7'; | ||
controller.block(req, res, next, hash); | ||
controller.block(req, res, next); | ||
}); | ||
@@ -112,18 +113,18 @@ | ||
var node = { | ||
log: sinon.stub(), | ||
getBlock: sinon.stub().callsArgWith(1, null, block), | ||
services: { | ||
bitcoind: { | ||
getNextBlockHash: sinon.stub().returns('000000000001e866a8057cde0c650796cb8a59e0e6038dc31c69d7ca6649627d'), | ||
getBlockIndex: sinon.stub().returns(blockIndexes['000000000000000004a118407a4e3556ae2d5e882017e7ce526659d8073f13a4']), | ||
isMainChain: sinon.stub().returns(true) | ||
}, | ||
db: { | ||
tip: { | ||
__height: 534092 | ||
} | ||
getBlockHeader: sinon.stub().callsArgWith(1, null, blockIndexes['000000000000000004a118407a4e3556ae2d5e882017e7ce526659d8073f13a4']), | ||
isMainChain: sinon.stub().returns(true), | ||
height: 534092 | ||
} | ||
} | ||
}; | ||
var controller = new BlockController(node); | ||
var req = {}; | ||
var controller = new BlockController({node: node}); | ||
var req = { | ||
params: { | ||
blockHash: hash | ||
} | ||
}; | ||
var res = {}; | ||
@@ -140,3 +141,3 @@ var next = function() { | ||
controller.block(req, res, next, hash); | ||
controller.block(req, res, next); | ||
}); | ||
@@ -149,34 +150,34 @@ | ||
var insight = { | ||
"blocks": [ | ||
'blocks': [ | ||
{ | ||
"height": 533951, | ||
"size": 206, | ||
"hash": "000000000008fbb2e358e382a6f6948b2da24563bba183af447e6e2542e8efc7", | ||
"time": 1440978683, | ||
"txlength": 1, | ||
"poolInfo": { | ||
"poolName": "AntMiner", | ||
"url": "https://bitmaintech.com/" | ||
'height': 533951, | ||
'size': 206, | ||
'hash': '000000000008fbb2e358e382a6f6948b2da24563bba183af447e6e2542e8efc7', | ||
'time': 1440978683, | ||
'txlength': 1, | ||
'poolInfo': { | ||
'poolName': 'AntMiner', | ||
'url': 'https://bitmaintech.com/' | ||
} | ||
}, | ||
{ | ||
"height": 533950, | ||
"size": 206, | ||
"hash": "00000000000006bd8fe9e53780323c0e85719eca771022e1eb6d10c62195c441", | ||
"time": 1440977479, | ||
"txlength": 1, | ||
"poolInfo": { | ||
"poolName": "AntMiner", | ||
"url": "https://bitmaintech.com/" | ||
'height': 533950, | ||
'size': 206, | ||
'hash': '00000000000006bd8fe9e53780323c0e85719eca771022e1eb6d10c62195c441', | ||
'time': 1440977479, | ||
'txlength': 1, | ||
'poolInfo': { | ||
'poolName': 'AntMiner', | ||
'url': 'https://bitmaintech.com/' | ||
} | ||
} | ||
], | ||
"length": 2, | ||
"pagination": { | ||
"current": "2015-08-30", | ||
"currentTs": 1440979199, | ||
"isToday": false, | ||
"more": false, | ||
"next": "2015-08-31", | ||
"prev": "2015-08-29" | ||
'length': 2, | ||
'pagination': { | ||
'current': '2015-08-30', | ||
'currentTs': 1440979199, | ||
'isToday': false, | ||
'more': false, | ||
'next': '2015-08-31', | ||
'prev': '2015-08-29' | ||
} | ||
@@ -186,18 +187,17 @@ }; | ||
var stub = sinon.stub(); | ||
stub.onFirstCall().callsArgWith(1, null, bitcore.Block.fromBuffer(blocks['000000000008fbb2e358e382a6f6948b2da24563bba183af447e6e2542e8efc7'], 'hex')); | ||
stub.onSecondCall().callsArgWith(1, null, bitcore.Block.fromBuffer(blocks['00000000000006bd8fe9e53780323c0e85719eca771022e1eb6d10c62195c441'], 'hex')) | ||
stub.onFirstCall().callsArgWith(1, null, new Buffer(blocks['000000000008fbb2e358e382a6f6948b2da24563bba183af447e6e2542e8efc7'], 'hex')); | ||
stub.onSecondCall().callsArgWith(1, null, new Buffer(blocks['00000000000006bd8fe9e53780323c0e85719eca771022e1eb6d10c62195c441'], 'hex')); | ||
var hashes = [ | ||
'000000000008fbb2e358e382a6f6948b2da24563bba183af447e6e2542e8efc7', | ||
'00000000000006bd8fe9e53780323c0e85719eca771022e1eb6d10c62195c441' | ||
'00000000000006bd8fe9e53780323c0e85719eca771022e1eb6d10c62195c441', | ||
'000000000008fbb2e358e382a6f6948b2da24563bba183af447e6e2542e8efc7' | ||
]; | ||
var node = { | ||
getBlock: stub, | ||
log: sinon.stub(), | ||
services: { | ||
bitcoind: { | ||
getBlockIndex: function(hash) { | ||
return blockIndexes[hash]; | ||
} | ||
}, | ||
db: { | ||
getRawBlock: stub, | ||
getBlockHeader: function(hash, callback) { | ||
callback(null, blockIndexes[hash]); | ||
}, | ||
getBlockHashesByTimestamp: sinon.stub().callsArgWith(2, null, hashes) | ||
@@ -209,3 +209,3 @@ } | ||
it('should have correct data', function(done) { | ||
var blocks = new BlockController(node); | ||
var blocks = new BlockController({node: node}); | ||
@@ -232,6 +232,7 @@ var req = { | ||
var node = { | ||
log: sinon.stub(), | ||
services: { | ||
bitcoind: { | ||
getBlockIndex: function(height) { | ||
return blockIndexes[height]; | ||
getBlockHeader: function(height, callback) { | ||
callback(null, blockIndexes[height]); | ||
} | ||
@@ -243,9 +244,15 @@ } | ||
it('should have correct data', function(done) { | ||
var blocks = new BlockController(node); | ||
var blocks = new BlockController({node: node}); | ||
var insight = { | ||
"blockHash": "0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7" | ||
'blockHash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7' | ||
}; | ||
var req = {}; | ||
var height = 533974; | ||
var req = { | ||
params: { | ||
height: height | ||
} | ||
}; | ||
var res = { | ||
@@ -257,6 +264,4 @@ jsonp: function(data) { | ||
}; | ||
var next = function() {}; | ||
var height = 533974; | ||
blocks.blockIndex(req, res, next, height); | ||
blocks.blockIndex(req, res); | ||
}); | ||
@@ -266,3 +271,6 @@ }); | ||
describe('#getBlockReward', function() { | ||
var blocks = new BlockController({}); | ||
var node = { | ||
log: sinon.stub() | ||
}; | ||
var blocks = new BlockController({node: node}); | ||
@@ -269,0 +277,0 @@ it('should give a block reward of 50 * 1e8 for block before first halvening', function() { |
@@ -10,4 +10,8 @@ 'use strict'; | ||
it('will set cache control header', function(done) { | ||
var node = { | ||
log: sinon.stub() | ||
}; | ||
var index = new InsightAPI({ | ||
enableCache: true | ||
enableCache: true, | ||
node: node | ||
}); | ||
@@ -27,4 +31,8 @@ var req = {}; | ||
it('will NOT set cache control header', function(done) { | ||
var node = { | ||
log: sinon.stub() | ||
}; | ||
var index = new InsightAPI({ | ||
enableCache: false | ||
enableCache: false, | ||
node: node | ||
}); | ||
@@ -44,5 +52,9 @@ var req = {}; | ||
it('will set SHORT cache control header', function(done) { | ||
var node = { | ||
log: sinon.stub() | ||
}; | ||
var index = new InsightAPI({ | ||
enableCache: true, | ||
cacheShortSeconds: 35 | ||
cacheShortSeconds: 35, | ||
node: node | ||
}); | ||
@@ -62,4 +74,8 @@ var req = {}; | ||
it('will set SHORT DEFAULT cache control header', function(done) { | ||
var node = { | ||
log: sinon.stub() | ||
}; | ||
var index = new InsightAPI({ | ||
enableCache: true | ||
enableCache: true, | ||
node: node | ||
}); | ||
@@ -81,5 +97,9 @@ var req = {}; | ||
it('will set LONG cache control header', function(done) { | ||
var node = { | ||
log: sinon.stub() | ||
}; | ||
var index = new InsightAPI({ | ||
enableCache: true, | ||
cacheLongSeconds: 86400000 | ||
cacheLongSeconds: 86400000, | ||
node: node | ||
}); | ||
@@ -99,4 +119,8 @@ var req = {}; | ||
it('will set LONG DEFAULT cache control header', function(done) { | ||
var node = { | ||
log: sinon.stub() | ||
}; | ||
var index = new InsightAPI({ | ||
enableCache: true | ||
enableCache: true, | ||
node: node | ||
}); | ||
@@ -103,0 +127,0 @@ var req = {}; |
@@ -11,9 +11,9 @@ 'use strict'; | ||
version: 110000, | ||
protocolversion: 70002, | ||
protocolVersion: 70002, | ||
blocks: 548645, | ||
timeoffset: 0, | ||
timeOffset: 0, | ||
connections: 8, | ||
difficulty: 21546.906405522557, | ||
testnet: true, | ||
relayfee: 1000, | ||
relayFee: 1000, | ||
errors: '' | ||
@@ -35,9 +35,5 @@ }; | ||
bitcoind: { | ||
getInfo: sinon.stub().returns(info), | ||
getBestBlockHash: sinon.stub().returns(outSetInfo.bestblock) | ||
}, | ||
db: { | ||
tip: { | ||
hash: outSetInfo.bestblock | ||
} | ||
getInfo: sinon.stub().callsArgWith(0, null, info), | ||
getBestBlockHash: sinon.stub().callsArgWith(0, null, outSetInfo.bestblock), | ||
tiphash: outSetInfo.bestblock | ||
} | ||
@@ -123,11 +119,6 @@ } | ||
services: { | ||
db: { | ||
tip: { | ||
__height: 500000 | ||
} | ||
}, | ||
bitcoind: { | ||
height: 500000, | ||
isSynced: sinon.stub().returns(true), | ||
syncPercentage: sinon.stub().returns(99.99) | ||
isSynced: sinon.stub().callsArgWith(0, null, true), | ||
syncPercentage: sinon.stub().callsArgWith(0, null, 99.99) | ||
} | ||
@@ -134,0 +125,0 @@ } |
@@ -12,121 +12,137 @@ 'use strict'; | ||
var insight = { | ||
"txid": "b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0", | ||
"version": 1, | ||
"locktime": 0, | ||
"vin": [ | ||
{ | ||
"txid": "87c9b0f27571fff14b8c2d69e55614eacedd0f59fcc490b721320f9dae145aad", | ||
"vout": 0, | ||
"scriptSig": { | ||
"asm": "30450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c01 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"hex": "4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307" | ||
}, | ||
"sequence": 4294967295, | ||
"n": 0, | ||
"addr": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f", | ||
"valueSat": 18535505, | ||
"value": 0.18535505, | ||
"doubleSpentTxID": null, | ||
"isConfirmed": true, | ||
"confirmations": 242, | ||
"unconfirmedInput": false | ||
'txid': 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0', | ||
'version': 1, | ||
'locktime': 0, | ||
'vin': [ | ||
{ | ||
'txid': '87c9b0f27571fff14b8c2d69e55614eacedd0f59fcc490b721320f9dae145aad', | ||
'vout': 0, | ||
'scriptSig': { | ||
'asm': '30450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c01 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
'hex': '4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307' | ||
}, | ||
{ | ||
"txid": "d8a10aaedf3dd33b5ddf8979273f3dbf61e4638d1aa6a93c59ea22bc65ac2196", | ||
"vout": 0, | ||
"scriptSig": { | ||
"asm": "30440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb3101 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"hex": "4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307" | ||
}, | ||
"sequence": 4294967295, | ||
"n": 1, | ||
"addr": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f", | ||
"valueSat": 16419885, | ||
"value": 0.16419885, | ||
"doubleSpentTxID": null, | ||
"isConfirmed": true, | ||
"confirmations": 242, | ||
"unconfirmedInput": false | ||
} | ||
'sequence': 4294967295, | ||
'n': 0, | ||
'addr': 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
'valueSat': 18535505, | ||
'value': 0.18535505, | ||
'doubleSpentTxID': null, | ||
'isConfirmed': true, | ||
'confirmations': 242, | ||
'unconfirmedInput': false | ||
}, | ||
{ | ||
'txid': 'd8a10aaedf3dd33b5ddf8979273f3dbf61e4638d1aa6a93c59ea22bc65ac2196', | ||
'vout': 0, | ||
'scriptSig': { | ||
'asm': '30440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb3101 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
'hex': '4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307' | ||
}, | ||
'sequence': 4294967295, | ||
'n': 1, | ||
'addr': 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
'valueSat': 16419885, | ||
'value': 0.16419885, | ||
'doubleSpentTxID': null, | ||
'isConfirmed': true, | ||
'confirmations': 242, | ||
'unconfirmedInput': false | ||
} | ||
], | ||
"vout": [ | ||
{ | ||
"value": "0.21247964", | ||
"n": 0, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 4b7b335f978f130269fe661423258ae9642df8a1 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a9144b7b335f978f130269fe661423258ae9642df8a188ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mnQ4ZaGessNgdxmWPxbTHcfx4b8R6eUr1X" | ||
] | ||
} | ||
'vout': [ | ||
{ | ||
'value': '0.21247964', | ||
'n': 0, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 4b7b335f978f130269fe661423258ae9642df8a1 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a9144b7b335f978f130269fe661423258ae9642df8a188ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mnQ4ZaGessNgdxmWPxbTHcfx4b8R6eUr1X' | ||
] | ||
}, | ||
{ | ||
"value": "0.13677426", | ||
"n": 1, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 6efcf883b4b6f9997be9a0600f6c095fe2bd2d92 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f" | ||
] | ||
}, | ||
"spentTxId": "614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec", | ||
"spentIndex": 1, | ||
"spentTs": 1440997099 | ||
} | ||
'spentTxId': null, | ||
'spentIndex': null, | ||
'spentHeight': null | ||
}, | ||
{ | ||
'value': '0.13677426', | ||
'n': 1, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 6efcf883b4b6f9997be9a0600f6c095fe2bd2d92 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f' | ||
] | ||
}, | ||
'spentTxId': '614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec', | ||
'spentIndex': 1, | ||
'spentHeight': 10, | ||
'spentTs': 1440997099 | ||
} | ||
], | ||
"blockhash": "0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7", | ||
"blockheight": 533974, | ||
"confirmations": 230, | ||
"time": 1440987503, | ||
"blocktime": 1440987503, | ||
"valueOut": 0.3492539, | ||
"size": 437, | ||
"valueIn": 0.3495539, | ||
"fees": 0.0003 | ||
'blockhash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
'blockheight': 533974, | ||
'confirmations': 230, | ||
'time': 1440987503, | ||
'blocktime': 1440987503, | ||
'valueOut': 0.3492539, | ||
'size': 437, | ||
'valueIn': 0.3495539, | ||
'fees': 0.0003 | ||
}; | ||
var bitcoreTxObj = { | ||
"hash": "b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0", | ||
"version": 1, | ||
"inputs": [ | ||
var spentTxId = '614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec'; | ||
var spentIndex = 1; | ||
var detailedTransaction = { | ||
hex: '7b5485d3628922f004f470f497f6a83f6df4df347e1bce15831a964623f8072b565f7c7bc5dcbc717c6e2a2301a2f6b4a19e65042ad88c9f5d037628de38603c4f137f625e135691e2bd0169cab74e1368abe858f3c3d116e9d13c4c85ead129d9edf0245a3fb1b35561bd230607dca0dcaf3cffc735a3982d8384a1ecc5d622a7bb4db8b5d47d061701978b1f45e2e39946d66c3394f8a20b8ac8c931a6786f761da2d0f3fa2c7c93edee9f2a94de7c47510498767c3d87afe68815bd6058710bf5d8c850a5d20fc217943d9c00da58a4908d92a0912578247746f2086e54cb7b81b6a9e3cc1741457e956d41bdeaae06c441db96ec39a2d17147dd8f468eeaeaaa78dc2e53d66188a791c46b2a4965639ad72a2b90ee52786e36db1a8cf924346b105a40b41a3027dae657782ef7e8b56d6da86062184cb5366d4886cd2ce27471d9d62d1df447f2e5a9641e1f8d1f2b628054d3bd915bf7932bcec6f2dd4965e2406b1dba445b5493ee475757de332618220318dd806b880a7364370c5c0c3b736a653f97b2901fdb5cf4b5b2230b09b2d7bd324a392633d51c598765f9bd286421239a1f25db34a9a61f645eb601e59f10fc1b', | ||
hash: 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0', | ||
version: 1, | ||
blockHash: '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
height: 533974, | ||
blockTimestamp: 1440987503, | ||
inputSatoshis: 34955390, | ||
outputSatoshis: 34925390, | ||
feeSatoshis: 30000, | ||
inputs: [ | ||
{ | ||
"prevTxId": "87c9b0f27571fff14b8c2d69e55614eacedd0f59fcc490b721320f9dae145aad", | ||
"outputIndex": 0, | ||
"sequenceNumber": 4294967295, | ||
"script": "4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"scriptString": "72 0x30450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c01 65 0x04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"output": { | ||
"satoshis": 18535505, | ||
"script": "76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac" | ||
} | ||
address: 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
prevTxId: '87c9b0f27571fff14b8c2d69e55614eacedd0f59fcc490b721320f9dae145aad', | ||
outputIndex: 0, | ||
sequence: 4294967295, | ||
script: '4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
scriptAsm: '30450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c01 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
satoshis: 18535505, | ||
}, | ||
{ | ||
"prevTxId": "d8a10aaedf3dd33b5ddf8979273f3dbf61e4638d1aa6a93c59ea22bc65ac2196", | ||
"outputIndex": 0, | ||
"sequenceNumber": 4294967295, | ||
"script": "4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"scriptString": "71 0x30440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb3101 65 0x04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"output": { | ||
"satoshis": 16419885, | ||
"script": "76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac" | ||
} | ||
address: 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
prevTxId: 'd8a10aaedf3dd33b5ddf8979273f3dbf61e4638d1aa6a93c59ea22bc65ac2196', | ||
outputIndex: 0, | ||
sequence: 4294967295, | ||
script: '4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
scriptAsm: '30440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb3101 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
satoshis: 16419885, | ||
} | ||
], | ||
"outputs": [ | ||
outputs: [ | ||
{ | ||
"satoshis": 21247964, | ||
"script": "76a9144b7b335f978f130269fe661423258ae9642df8a188ac" | ||
satoshis: 21247964, | ||
script: '76a9144b7b335f978f130269fe661423258ae9642df8a188ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 4b7b335f978f130269fe661423258ae9642df8a1 OP_EQUALVERIFY OP_CHECKSIG', | ||
address: 'mnQ4ZaGessNgdxmWPxbTHcfx4b8R6eUr1X' | ||
}, | ||
{ | ||
"satoshis": 13677426, | ||
"script": "76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac" | ||
address: 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
satoshis: 13677426, | ||
scriptAsm: 'OP_DUP OP_HASH160 6efcf883b4b6f9997be9a0600f6c095fe2bd2d92 OP_EQUALVERIFY OP_CHECKSIG', | ||
script: '76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac', | ||
spentTxId: spentTxId, | ||
spentIndex: spentIndex, | ||
spentHeight: 10 | ||
} | ||
], | ||
"nLockTime": 0 | ||
locktime: 0 | ||
}; | ||
@@ -162,35 +178,8 @@ | ||
var spentTxId = '614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec'; | ||
var spentIndex = 1; | ||
var bitcoreTx = bitcore.Transaction(bitcoreTxObj); | ||
bitcoreTx.__blockHash = '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7'; | ||
bitcoreTx.__height = 533974; | ||
bitcoreTx.__timestamp = 1440987503; | ||
bitcoreTx.populateInputs = sinon.stub().callsArg(2); | ||
bitcoreTx.toObject = sinon.stub().returns(bitcoreTxObj); | ||
var node = { | ||
getTransactionWithBlockInfo: sinon.stub().callsArgWith(2, null, bitcoreTx), | ||
getDetailedTransaction: sinon.stub().callsArgWith(1, null, detailedTransaction), | ||
services: { | ||
db: { | ||
tip: { | ||
__height: 534203 | ||
} | ||
bitcoind: { | ||
height: 534203 | ||
}, | ||
address: { | ||
getInputForOutput: function(txid, outputIndex, options, callback) { | ||
var data = false; | ||
if (txid === 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0' && | ||
outputIndex === 1) { | ||
data = { | ||
inputTxId: spentTxId, | ||
inputIndex: spentIndex | ||
} | ||
} | ||
setImmediate(function() { | ||
callback(null, data); | ||
}); | ||
} | ||
} | ||
}, | ||
@@ -201,3 +190,8 @@ network: 'testnet' | ||
var transactions = new TxController(node); | ||
var req = {}; | ||
var txid = 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0'; | ||
var req = { | ||
params: { | ||
txid: txid | ||
} | ||
}; | ||
var res = {}; | ||
@@ -209,5 +203,4 @@ var next = function() { | ||
}; | ||
var txid = 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0'; | ||
transactions.transaction(req, res, next, txid); | ||
transactions.transaction(req, res, next); | ||
}); | ||
@@ -217,27 +210,158 @@ }); | ||
describe('/txs', function() { | ||
var sandbox = sinon.sandbox.create(); | ||
afterEach(function() { | ||
sandbox.restore(); | ||
}); | ||
it('by block hash', function(done) { | ||
var blockHex = '07000020a491892cca9f143f7f00b8d65bbce0204bb32e17e914325fa5010000000000003e28f0519ecf01f7f01ea8da61084b2e4741a18ce1f3738117b84458353764b06fb9e35567f20c1a78eb626f0301000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2303d6250800feb0aae355fe263600000963676d696e6572343208ae5800000000000000ffffffff01c018824a000000001976a91468bedce8982d25c3b6b03f6238cbad00378b8ead88ac000000000100000002ad5a14ae9d0f3221b790c4fc590fddceea1456e5692d8c4bf1ff7175f2b0c987000000008b4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307ffffffff9621ac65bc22ea593ca9a61a8d63e461bf3d3f277989df5d3bd33ddfae0aa1d8000000008a4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307ffffffff02dc374401000000001976a9144b7b335f978f130269fe661423258ae9642df8a188ac72b3d000000000001976a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac000000000100000002060d3cb6dfb7ffe85e2908010fea63190c9707e96fc7448128eb895b5e222771030000006b483045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901210346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909dfeffffff7b2d8a8263cffbdb722e2a5c74166e6f2258634e277c0b08f51b578b667e2fba000000006a473044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c012103371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eeefeffffff02209a1d00000000001976a9148e451eec7ca0a1764b4ab119274efdd2727b3c8588ac40420f00000000001976a914d0fce8f064cd1059a6a11501dd66fe42368572b088accb250800'; | ||
var blockIndex = { | ||
"hash": "0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7", | ||
"blockheight": 533974, | ||
"chainWork": "0000000000000000000000000000000000000000000000054626b1839ade284a", | ||
"prevHash": "00000000000001a55f3214e9172eb34b20e0bc5bd6b8007f3f149fca2c8991a4", | ||
"height": 533974 | ||
var blockOverview = { | ||
hash: '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
height: 533974, | ||
chainWork: '0000000000000000000000000000000000000000000000054626b1839ade284a', | ||
prevHash: '00000000000001a55f3214e9172eb34b20e0bc5bd6b8007f3f149fca2c8991a4', | ||
txids: [ | ||
'25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd', | ||
'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0', | ||
'2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1' | ||
] | ||
}; | ||
var block = bitcore.Block.fromBuffer(new Buffer(blockHex, 'hex')); | ||
var transactionDetails = { | ||
'25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd': { | ||
hex: '01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff2303d6250800feb0aae355fe263600000963676d696e6572343208ae5800000000000000ffffffff01c018824a000000001976a91468bedce8982d25c3b6b03f6238cbad00378b8ead88ac00000000', | ||
coinbase: true, | ||
version: 1, | ||
blockTimestamp: 1440987503, | ||
blockHash: '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
height: 533974, | ||
inputSatoshis: 0, | ||
outputSatoshis: 1250040000, | ||
feeSatoshis: 0, | ||
locktime: 0, | ||
hash: '25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd', | ||
inputs: [ | ||
{ | ||
script: '03d6250800feb0aae355fe263600000963676d696e6572343208ae5800000000000000', | ||
sequence: 4294967295 | ||
} | ||
], | ||
outputs: [ | ||
{ | ||
address: 'mq4oDPjmNWnBxbzx7qouzhpCSTMePUtYDF', | ||
script: '76a91468bedce8982d25c3b6b03f6238cbad00378b8ead88ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 68bedce8982d25c3b6b03f6238cbad00378b8ead OP_EQUALVERIFY OP_CHECKSIG', | ||
satoshis: 1250040000 | ||
} | ||
] | ||
}, | ||
'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0': { | ||
hex: '0100000002ad5a14ae9d0f3221b790c4fc590fddceea1456e5692d8c4bf1ff7175f2b0c987000000008b4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307ffffffff9621ac65bc22ea593ca9a61a8d63e461bf3d3f277989df5d3bd33ddfae0aa1d8000000008a4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307ffffffff02dc374401000000001976a9144b7b335f978f130269fe661423258ae9642df8a188ac72b3d000000000001976a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac00000000', | ||
inputSatoshis: 34955390, | ||
outputSatoshis: 34925390, | ||
feeSatoshis: 30000, | ||
version: 1, | ||
hash: 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0', | ||
blockTimestamp: 1440987503, | ||
height: 533974, | ||
blockHash: '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
locktime: 0, | ||
inputs: [ | ||
{ | ||
satoshis: 18535505, | ||
address: 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
script: '4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
scriptAsm: '30450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c01 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
prevTxId: '87c9b0f27571fff14b8c2d69e55614eacedd0f59fcc490b721320f9dae145aad', | ||
outputIndex: 0, | ||
sequence: 4294967295 | ||
}, | ||
{ | ||
address: 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
script: '4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
scriptAsm: '30440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb3101 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
satoshis: 16419885, | ||
sequence: 4294967295, | ||
prevTxId: 'd8a10aaedf3dd33b5ddf8979273f3dbf61e4638d1aa6a93c59ea22bc65ac2196', | ||
outputIndex: 0 | ||
} | ||
], | ||
outputs: [ | ||
{ | ||
address: 'mnQ4ZaGessNgdxmWPxbTHcfx4b8R6eUr1X', | ||
script: '76a9144b7b335f978f130269fe661423258ae9642df8a188ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 4b7b335f978f130269fe661423258ae9642df8a1 OP_EQUALVERIFY OP_CHECKSIG', | ||
satoshis: 21247964 | ||
}, | ||
{ | ||
script: '76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 6efcf883b4b6f9997be9a0600f6c095fe2bd2d92 OP_EQUALVERIFY OP_CHECKSIG', | ||
address: 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
satoshis: 13677426, | ||
spentTxId: '614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec', | ||
spentIndex: 1, | ||
spentHeight: 200 | ||
} | ||
] | ||
}, | ||
'2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1': { | ||
hex: '0100000002060d3cb6dfb7ffe85e2908010fea63190c9707e96fc7448128eb895b5e222771030000006b483045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901210346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909dfeffffff7b2d8a8263cffbdb722e2a5c74166e6f2258634e277c0b08f51b578b667e2fba000000006a473044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c012103371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eeefeffffff02209a1d00000000001976a9148e451eec7ca0a1764b4ab119274efdd2727b3c8588ac40420f00000000001976a914d0fce8f064cd1059a6a11501dd66fe42368572b088accb250800', | ||
blockHash: '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
blockTimestamp: 1440987503, | ||
height: 533974, | ||
locktime: 533963, | ||
inputSatoshis: 2950000, | ||
outputSatoshis: 2940000, | ||
feeSatoshis: 10000, | ||
version: 1, | ||
hash: '2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1', | ||
inputs: [ | ||
{ | ||
address: 'mgZK8zpudWoAaAwpLQSgc9t9PJJyEBpBdJ', | ||
satoshis: 990000, | ||
script: '483045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901210346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909d', | ||
scriptAsm: '3045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901 0346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909d', | ||
sequence: 4294967294, | ||
outputIndex: 3, | ||
prevTxId: '7127225e5b89eb288144c76fe907970c1963ea0f0108295ee8ffb7dfb63c0d06' | ||
}, | ||
{ | ||
address: 'n4oM7bPuC4ZPdCEDvtw9xGYQC7jmi5S6F4', | ||
satoshis: 1960000, | ||
script: '473044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c012103371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eee', | ||
scriptAsm: '3044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c01 03371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eee', | ||
prevTxId: 'ba2f7e668b571bf5080b7c274e6358226f6e16745c2a2e72dbfbcf63828a2d7b', | ||
sequence: 4294967294, | ||
outputIndex : 0 | ||
} | ||
], | ||
outputs: [ | ||
{ | ||
spentTxId: '9a213b879da9073a9a30606f9046f35f36f268cbf03f6242993a97c4c07c00b9', | ||
spentIndex: 1, | ||
spentHeight: 200, | ||
satoshis: 1940000, | ||
script: '76a9148e451eec7ca0a1764b4ab119274efdd2727b3c8588ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 8e451eec7ca0a1764b4ab119274efdd2727b3c85 OP_EQUALVERIFY OP_CHECKSIG', | ||
address: 'mtVD3tdifBNujYzZ5N7PgXfKk4Bc85tDKA' | ||
}, | ||
{ | ||
spentTxId: '418d3eb60275957b3456b96902e908abf962e71be4c4f09486564254664951bc', | ||
spentIndex: 34, | ||
spentHeight: 200, | ||
script: '76a914d0fce8f064cd1059a6a11501dd66fe42368572b088ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 d0fce8f064cd1059a6a11501dd66fe42368572b0 OP_EQUALVERIFY OP_CHECKSIG', | ||
address: 'mzZypShcs1B35udnkqeYeJy8rUdgHDDvKG', | ||
satoshis: 1000000 | ||
} | ||
] | ||
} | ||
}; | ||
var node = { | ||
getBlock: sinon.stub().callsArgWith(1, null, block), | ||
getBlockOverview: sinon.stub().callsArgWith(1, null, blockOverview), | ||
getDetailedTransaction: function(txid, callback) { | ||
callback(null, transactionDetails[txid]); | ||
}, | ||
services: { | ||
bitcoind: { | ||
getBlockIndex: sinon.stub().returns(blockIndex) | ||
}, | ||
db: { | ||
tip: { | ||
__height: 534209 | ||
} | ||
}, | ||
address: { | ||
getInputForOutput: sinon.stub().callsArgWith(3, null, false), | ||
height: 534209 | ||
} | ||
@@ -248,221 +372,205 @@ }, | ||
bitcore.Transaction.prototype.populateInputs = function(db, pool, callback) { | ||
if(this.hash === 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0') { | ||
this.inputs[0].output = new bitcore.Transaction.Output({ | ||
satoshis: 18535505, | ||
script: '76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac' | ||
}); | ||
this.inputs[1].output = new bitcore.Transaction.Output({ | ||
satoshis: 16419885, | ||
script: '76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac' | ||
}); | ||
} else if(this.hash === '2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1') { | ||
this.inputs[0].output = new bitcore.Transaction.Output({ | ||
satoshis: 990000, | ||
script: '76a9140b6a5b76fab66d809e0f9e9336c79011880ba96188ac' | ||
}); | ||
this.inputs[1].output = new bitcore.Transaction.Output({ | ||
satoshis: 1960000, | ||
script: '76a914ff6498e8c2498cbad016e1bf3a28cfb178995dbd88ac' | ||
}); | ||
} | ||
callback(); | ||
}; | ||
var transactions = new TxController(node); | ||
var insight = { | ||
"pagesTotal": 1, | ||
"txs": [ | ||
'pagesTotal': 1, | ||
'txs': [ | ||
{ | ||
'txid': '25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd', | ||
'version': 1, | ||
'locktime': 0, | ||
'vin': [ | ||
{ | ||
"txid": "25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd", | ||
"version": 1, | ||
"locktime": 0, | ||
"vin": [ | ||
{ | ||
"coinbase": "03d6250800feb0aae355fe263600000963676d696e6572343208ae5800000000000000", | ||
"sequence": 4294967295, | ||
"n": 0 | ||
} | ||
], | ||
"vout": [ | ||
{ | ||
"value": "12.50040000", | ||
"n": 0, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 68bedce8982d25c3b6b03f6238cbad00378b8ead OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a91468bedce8982d25c3b6b03f6238cbad00378b8ead88ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mq4oDPjmNWnBxbzx7qouzhpCSTMePUtYDF" | ||
] | ||
} | ||
} | ||
], | ||
"blockhash": "0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7", | ||
"blockheight": 533974, | ||
"confirmations": 236, | ||
"time": 1440987503, | ||
"blocktime": 1440987503, | ||
"isCoinBase": true, | ||
"valueOut": 12.5004, | ||
"size": 120 | ||
'coinbase': '03d6250800feb0aae355fe263600000963676d696e6572343208ae5800000000000000', | ||
'sequence': 4294967295, | ||
'n': 0 | ||
} | ||
], | ||
'vout': [ | ||
{ | ||
'value': '12.50040000', | ||
'n': 0, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 68bedce8982d25c3b6b03f6238cbad00378b8ead OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a91468bedce8982d25c3b6b03f6238cbad00378b8ead88ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mq4oDPjmNWnBxbzx7qouzhpCSTMePUtYDF' | ||
] | ||
}, | ||
'spentTxId': null, | ||
'spentIndex': null, | ||
'spentHeight': null | ||
} | ||
], | ||
'blockhash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
'blockheight': 533974, | ||
'confirmations': 236, | ||
'time': 1440987503, | ||
'blocktime': 1440987503, | ||
'isCoinBase': true, | ||
'valueOut': 12.5004, | ||
'size': 120 | ||
}, | ||
{ | ||
'txid': 'b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0', | ||
'version': 1, | ||
'locktime': 0, | ||
'vin': [ | ||
{ | ||
'txid': '87c9b0f27571fff14b8c2d69e55614eacedd0f59fcc490b721320f9dae145aad', | ||
'vout': 0, | ||
'scriptSig': { | ||
'asm': '30450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c01 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
'hex': '4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307' | ||
}, | ||
'sequence': 4294967295, | ||
'n': 0, | ||
'addr': 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
'valueSat': 18535505, | ||
'value': 0.18535505, | ||
'doubleSpentTxID': null | ||
}, | ||
{ | ||
"txid": "b85334bf2df35c6dd5b294efe92ffc793a78edff75a2ca666fc296ffb04bbba0", | ||
"version": 1, | ||
"locktime": 0, | ||
"vin": [ | ||
{ | ||
"txid": "87c9b0f27571fff14b8c2d69e55614eacedd0f59fcc490b721320f9dae145aad", | ||
"vout": 0, | ||
"scriptSig": { | ||
"asm": "30450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c01 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"hex": "4830450221008e5df62719cd92d7b137d00bbd27f153f2909bcad3a300960bc1020ec6d5e961022039df51600ff4fb5da5a794d1648c6b47c1f7d277fd5877fb5e52a730a3595f8c014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307" | ||
}, | ||
"sequence": 4294967295, | ||
"n": 0, | ||
"addr": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f", | ||
"valueSat": 18535505, | ||
"value": 0.18535505, | ||
"doubleSpentTxID": null | ||
}, | ||
{ | ||
"txid": "d8a10aaedf3dd33b5ddf8979273f3dbf61e4638d1aa6a93c59ea22bc65ac2196", | ||
"vout": 0, | ||
"scriptSig": { | ||
"asm": "30440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb3101 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307", | ||
"hex": "4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307" | ||
}, | ||
"sequence": 4294967295, | ||
"n": 1, | ||
"addr": "mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f", | ||
"valueSat": 16419885, | ||
"value": 0.16419885, | ||
"doubleSpentTxID": null | ||
} | ||
], | ||
"vout": [ | ||
{ | ||
"value": "0.21247964", | ||
"n": 0, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 4b7b335f978f130269fe661423258ae9642df8a1 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a9144b7b335f978f130269fe661423258ae9642df8a188ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mnQ4ZaGessNgdxmWPxbTHcfx4b8R6eUr1X" | ||
] | ||
} | ||
}, | ||
{ | ||
"value": "0.13677426", | ||
"n": 1, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 6efcf883b4b6f9997be9a0600f6c095fe2bd2d92 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f" | ||
] | ||
}, | ||
"spentTxId": "614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec", | ||
"spentIndex": 1, | ||
"spentTs": 1440997099 | ||
} | ||
], | ||
"blockhash": "0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7", | ||
"blockheight": 533974, | ||
"confirmations": 236, | ||
"time": 1440987503, | ||
"blocktime": 1440987503, | ||
"valueOut": 0.3492539, | ||
"size": 437, | ||
"valueIn": 0.3495539, | ||
"fees": 0.0003 | ||
'txid': 'd8a10aaedf3dd33b5ddf8979273f3dbf61e4638d1aa6a93c59ea22bc65ac2196', | ||
'vout': 0, | ||
'scriptSig': { | ||
'asm': '30440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb3101 04eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307', | ||
'hex': '4730440220761464d7bab9515d92260762a97af82a9b25d202d8f7197b1aaec81b6fed541f022059f99606de6b06e17b2cd102dceb3807ebdd9e777a5b77c9a0b3672f5eabcb31014104eb1e0ccd9afcac42229348dd776e991c69551ae3474340fada12e787e51758397e1d3afdba360d6374261125ea3b6ea079a5f202c150dfd729e1062d9176a307' | ||
}, | ||
'sequence': 4294967295, | ||
'n': 1, | ||
'addr': 'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f', | ||
'valueSat': 16419885, | ||
'value': 0.16419885, | ||
'doubleSpentTxID': null | ||
} | ||
], | ||
'vout': [ | ||
{ | ||
'value': '0.21247964', | ||
'n': 0, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 4b7b335f978f130269fe661423258ae9642df8a1 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a9144b7b335f978f130269fe661423258ae9642df8a188ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mnQ4ZaGessNgdxmWPxbTHcfx4b8R6eUr1X' | ||
] | ||
}, | ||
'spentTxId': null, | ||
'spentIndex': null, | ||
'spentHeight': null | ||
}, | ||
{ | ||
"txid": "2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1", | ||
"version": 1, | ||
"locktime": 533963, | ||
"vin": [ | ||
{ | ||
"txid": "7127225e5b89eb288144c76fe907970c1963ea0f0108295ee8ffb7dfb63c0d06", | ||
"vout": 3, | ||
"scriptSig": { | ||
"asm": "3045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901 0346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909d", | ||
"hex": "483045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901210346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909d" | ||
}, | ||
"sequence": 4294967294, | ||
"n": 0, | ||
"addr": "mgZK8zpudWoAaAwpLQSgc9t9PJJyEBpBdJ", | ||
"valueSat": 990000, | ||
"value": 0.0099, | ||
"doubleSpentTxID": null | ||
}, | ||
{ | ||
"txid": "ba2f7e668b571bf5080b7c274e6358226f6e16745c2a2e72dbfbcf63828a2d7b", | ||
"vout": 0, | ||
"scriptSig": { | ||
"asm": "3044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c01 03371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eee", | ||
"hex": "473044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c012103371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eee" | ||
}, | ||
"sequence": 4294967294, | ||
"n": 1, | ||
"addr": "n4oM7bPuC4ZPdCEDvtw9xGYQC7jmi5S6F4", | ||
"valueSat": 1960000, | ||
"value": 0.0196, | ||
"doubleSpentTxID": null | ||
} | ||
], | ||
"vout": [ | ||
{ | ||
"value": "0.01940000", | ||
"n": 0, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 8e451eec7ca0a1764b4ab119274efdd2727b3c85 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a9148e451eec7ca0a1764b4ab119274efdd2727b3c8588ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mtVD3tdifBNujYzZ5N7PgXfKk4Bc85tDKA" | ||
] | ||
}, | ||
"spentTxId": "9a213b879da9073a9a30606f9046f35f36f268cbf03f6242993a97c4c07c00b9", | ||
"spentIndex": 1, | ||
"spentTs": 1440992946 | ||
}, | ||
{ | ||
"value": "0.01000000", | ||
"n": 1, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 d0fce8f064cd1059a6a11501dd66fe42368572b0 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a914d0fce8f064cd1059a6a11501dd66fe42368572b088ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mzZypShcs1B35udnkqeYeJy8rUdgHDDvKG" | ||
] | ||
}, | ||
"spentTxId": "418d3eb60275957b3456b96902e908abf962e71be4c4f09486564254664951bc", | ||
"spentIndex": 34, | ||
"spentTs": 1440999118 | ||
} | ||
], | ||
"blockhash": "0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7", | ||
"blockheight": 533974, | ||
"confirmations": 236, | ||
"time": 1440987503, | ||
"blocktime": 1440987503, | ||
"valueOut": 0.0294, | ||
"size": 373, | ||
"valueIn": 0.0295, | ||
"fees": 0.0001 | ||
'value': '0.13677426', | ||
'n': 1, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 6efcf883b4b6f9997be9a0600f6c095fe2bd2d92 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a9146efcf883b4b6f9997be9a0600f6c095fe2bd2d9288ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mqdofsXHpePPGBFXuwwypAqCcXi48Xhb2f' | ||
] | ||
}, | ||
'spentTxId': '614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec', | ||
'spentIndex': 1, | ||
'spentHeight': 200, | ||
'spentTs': 1440997099 | ||
} | ||
] | ||
], | ||
'blockhash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
'blockheight': 533974, | ||
'confirmations': 236, | ||
'time': 1440987503, | ||
'blocktime': 1440987503, | ||
'valueOut': 0.3492539, | ||
'size': 437, | ||
'valueIn': 0.3495539, | ||
'fees': 0.0003 | ||
}, | ||
{ | ||
'txid': '2e01c7a4a0e335112236b711c4aaddd02e8dc59ba2cda416e8f80ff06dddd7e1', | ||
'version': 1, | ||
'locktime': 533963, | ||
'vin': [ | ||
{ | ||
'txid': '7127225e5b89eb288144c76fe907970c1963ea0f0108295ee8ffb7dfb63c0d06', | ||
'vout': 3, | ||
'scriptSig': { | ||
'asm': '3045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901 0346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909d', | ||
'hex': '483045022100f67cffc0ae23adb236ff3edb4a9736e277605db30cc7708dfab8cf1e1483bbce022052396aa5d664ec1cb65992c423fd9a17e94dc7af328d2d559e90746dd195ca5901210346134da14907581d8190d3980caaf46d95e4eb9c1ca8e70f1fc6007fefb1909d' | ||
}, | ||
'sequence': 4294967294, | ||
'n': 0, | ||
'addr': 'mgZK8zpudWoAaAwpLQSgc9t9PJJyEBpBdJ', | ||
'valueSat': 990000, | ||
'value': 0.0099, | ||
'doubleSpentTxID': null | ||
}, | ||
{ | ||
'txid': 'ba2f7e668b571bf5080b7c274e6358226f6e16745c2a2e72dbfbcf63828a2d7b', | ||
'vout': 0, | ||
'scriptSig': { | ||
'asm': '3044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c01 03371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eee', | ||
'hex': '473044022077222a91cda23af69179377c62d84a176fb12caff6c5cbf6ae9e5957ff3b1afe0220768edead76819228dcba18cca3c9a5a5d4c32919720f21df21a297ba375bbe5c012103371ea5a4dfe356b3ea4042a537d7ab7ee0faabd43e21b6cc076fda2240629eee' | ||
}, | ||
'sequence': 4294967294, | ||
'n': 1, | ||
'addr': 'n4oM7bPuC4ZPdCEDvtw9xGYQC7jmi5S6F4', | ||
'valueSat': 1960000, | ||
'value': 0.0196, | ||
'doubleSpentTxID': null | ||
} | ||
], | ||
'vout': [ | ||
{ | ||
'value': '0.01940000', | ||
'n': 0, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 8e451eec7ca0a1764b4ab119274efdd2727b3c85 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a9148e451eec7ca0a1764b4ab119274efdd2727b3c8588ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mtVD3tdifBNujYzZ5N7PgXfKk4Bc85tDKA' | ||
] | ||
}, | ||
'spentTxId': '9a213b879da9073a9a30606f9046f35f36f268cbf03f6242993a97c4c07c00b9', | ||
'spentIndex': 1, | ||
'spentHeight': 200, | ||
'spentTs': 1440992946 | ||
}, | ||
{ | ||
'value': '0.01000000', | ||
'n': 1, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 d0fce8f064cd1059a6a11501dd66fe42368572b0 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a914d0fce8f064cd1059a6a11501dd66fe42368572b088ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mzZypShcs1B35udnkqeYeJy8rUdgHDDvKG' | ||
] | ||
}, | ||
'spentTxId': '418d3eb60275957b3456b96902e908abf962e71be4c4f09486564254664951bc', | ||
'spentIndex': 34, | ||
'spentHeight': 200, | ||
'spentTs': 1440999118 | ||
} | ||
], | ||
'blockhash': '0000000000000afa0c3c0afd450c793a1e300ec84cbe9555166e06132f19a8f7', | ||
'blockheight': 533974, | ||
'confirmations': 236, | ||
'time': 1440987503, | ||
'blocktime': 1440987503, | ||
'valueOut': 0.0294, | ||
'size': 373, | ||
'valueIn': 0.0295, | ||
'fees': 0.0001 | ||
} | ||
] | ||
}; | ||
@@ -494,5 +602,3 @@ | ||
}, | ||
spentIndex: 1, | ||
spentTs: 1440997099, | ||
spentTxId: '614fe1708825f9c21732394e4784cc6808ac1d8b939736bfdead970567561eec' | ||
spentTs: 1440997099 | ||
} | ||
@@ -509,5 +615,3 @@ ] | ||
}, | ||
spentIndex: 1, | ||
spentTs: 1440992946, | ||
spentTxId: '9a213b879da9073a9a30606f9046f35f36f268cbf03f6242993a97c4c07c00b9' | ||
spentTs: 1440992946 | ||
}, | ||
@@ -518,5 +622,3 @@ { | ||
}, | ||
spentIndex: 34, | ||
spentTs: 1440999118, | ||
spentTxId: '418d3eb60275957b3456b96902e908abf962e71be4c4f09486564254664951bc' | ||
spentTs: 1440999118 | ||
} | ||
@@ -526,3 +628,3 @@ ] | ||
] | ||
} | ||
}; | ||
@@ -537,3 +639,3 @@ var req = { | ||
jsonp: function(data) { | ||
var merged = _.merge(data, todos); | ||
_.merge(data, todos); | ||
should(data).eql(insight); | ||
@@ -550,60 +652,73 @@ done(); | ||
{ | ||
tx: bitcore.Transaction().fromObject({ | ||
"hash": "bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7", | ||
"version": 1, | ||
"inputs": [ | ||
tx: { | ||
hex: '010000000125c46caa6d839435b43c20d6d48978e677841244b37a09f6f6cd29bfaf5b5eea010000006b483045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a6012103acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6feffffff02a913dda5000000001976a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac809fd500000000001976a9149713201957f42379e574d7c70d506ee49c2c8ad688ac49260800', | ||
hash: 'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7', | ||
version: 1, | ||
inputs: [ | ||
{ | ||
"prevTxId": "ea5e5bafbf29cdf6f6097ab344128477e67889d4d6203cb43594836daa6cc425", | ||
"outputIndex": 1, | ||
"sequenceNumber": 4294967294, | ||
"script": "483045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a6012103acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6", | ||
"scriptString": "72 0x3045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a601 33 0x03acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6", | ||
"output": { | ||
"satoshis": 2796764565, | ||
"script": "76a91488b1fe8aec5ae4358a11447a2f22b2781faedb9b88ac" | ||
} | ||
prevTxId: 'ea5e5bafbf29cdf6f6097ab344128477e67889d4d6203cb43594836daa6cc425', | ||
outputIndex: 1, | ||
sequence: 4294967294, | ||
script: '483045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a6012103acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6', | ||
scriptAsm: '3045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a601 03acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6', | ||
satoshis: 2796764565, | ||
address: 'msyjRQQ88MabQmyafpKCjBHUwuJ49tVjcb' | ||
} | ||
], | ||
"outputs": [ | ||
outputs: [ | ||
{ | ||
"satoshis": 2782729129, | ||
"script": "76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac" | ||
satoshis: 2782729129, | ||
address: 'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er', | ||
script: '76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 3583efb5e64a4668c6c54bb5fcc30af4417b4f2d OP_EQUALVERIFY OP_CHECKSIG' | ||
}, | ||
{ | ||
"satoshis": 14000000, | ||
"script": "76a9149713201957f42379e574d7c70d506ee49c2c8ad688ac" | ||
satoshis: 14000000, | ||
address: 'muHmEsjhjmATf9i3T9gHyeQoce9LXe2dWz', | ||
script: '76a9149713201957f42379e574d7c70d506ee49c2c8ad688ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 9713201957f42379e574d7c70d506ee49c2c8ad6 OP_EQUALVERIFY OP_CHECKSIG' | ||
} | ||
], | ||
"nLockTime": 534089 | ||
}) | ||
inputSatoshis: 2796764565, | ||
outputSatoshis: 2796729129, | ||
feeSatoshis: 35436, | ||
locktime: 534089 | ||
} | ||
}, | ||
{ | ||
tx: bitcore.Transaction().fromObject({ | ||
"hash": "01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3", | ||
"version": 1, | ||
"inputs": [ | ||
tx: { | ||
hex: '0100000001c7f1230d689647ccbff2aae4ddeeccf26aa8836fea709552c9fa0962b9c30ebb000000006a47304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d5640121034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24feffffff02bce0c9a4000000001976a91456e446bc3489543d8324c6d0271524c0bd0506dd88ac80a81201000000001976a914011d2963b619186a318f768dddfd98cd553912a088ac53260800', | ||
hash: '01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3', | ||
version: 1, | ||
inputs: [ | ||
{ | ||
"prevTxId": "bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7", | ||
"outputIndex": 0, | ||
"sequenceNumber": 4294967294, | ||
"script": "47304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d5640121034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24", | ||
"scriptString": "71 0x304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d56401 33 0x034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24", | ||
"output": { | ||
"satoshis": 2782729129, | ||
"script": "76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac" | ||
} | ||
prevTxId: 'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7', | ||
outputIndex: 0, | ||
sequence: 4294967294, | ||
script: '47304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d5640121034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24', | ||
scriptAsm: '304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d56401 034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24', | ||
satoshis: 2782729129, | ||
address: 'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er' | ||
} | ||
], | ||
"outputs": [ | ||
outputs: [ | ||
{ | ||
"satoshis": 2764693692, | ||
"script": "76a91456e446bc3489543d8324c6d0271524c0bd0506dd88ac" | ||
satoshis: 2764693692, | ||
address: 'moSPsU4p2C2gssiniJ1JNH4fB9xs633tLv', | ||
script: '76a91456e446bc3489543d8324c6d0271524c0bd0506dd88ac', | ||
scriptAsm: 'OP_DUP OP_HASH160 56e446bc3489543d8324c6d0271524c0bd0506dd OP_EQUALVERIFY OP_CHECKSIG' | ||
}, | ||
{ | ||
"satoshis": 18000000, | ||
"script": "76a914011d2963b619186a318f768dddfd98cd553912a088ac" | ||
satoshis: 18000000, | ||
scriptAsm: 'OP_DUP OP_HASH160 011d2963b619186a318f768dddfd98cd553912a0 OP_EQUALVERIFY OP_CHECKSIG', | ||
script: '76a914011d2963b619186a318f768dddfd98cd553912a088ac', | ||
address: 'mfcquSAitCkUKXaYRZTRZQDfUegnL3kDew', | ||
spentTxId: '71a9e60c0341c9c258367f1a6d4253276f16e207bf84f41ff7412d8958a81bed' | ||
} | ||
], | ||
"nLockTime": 534099 | ||
}) | ||
inputSatoshis: 2782729129, | ||
outputSatoshis: 2782693692, | ||
feeSatoshis: 35437, | ||
locktime: 534099 | ||
} | ||
} | ||
@@ -617,45 +732,27 @@ ]; | ||
txinfos[0].tx.__blockHash = '00000000000001001aba15de213648f370607fb048288dd27b96f7e833a73520'; | ||
txinfos[0].tx.__timestamp = 1441068774; | ||
txinfos[0].tx.__height = 534105; | ||
txinfos[0].tx.blockHash = '00000000000001001aba15de213648f370607fb048288dd27b96f7e833a73520'; | ||
txinfos[0].tx.blockTimestamp = 1441068774; | ||
txinfos[0].tx.height = 534105; | ||
txinfos[1].tx.__blockHash = '0000000000000a3acc1f7fe72917eb48bb319ed96c125a6dfcc0ba6acab3c4d0'; | ||
txinfos[1].tx.__timestamp = 1441072817; | ||
txinfos[1].tx.__height = 534110; | ||
txinfos[1].tx.blockHash = '0000000000000a3acc1f7fe72917eb48bb319ed96c125a6dfcc0ba6acab3c4d0'; | ||
txinfos[1].tx.blockTimestamp = 1441072817; | ||
txinfos[1].tx.height = 534110; | ||
txinfos[0].tx.outputs[0].spentTxId = '01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3'; | ||
txinfos[0].tx.outputs[0].spentIndex = 0; | ||
txinfos[0].tx.outputs[0].spentHeight = 199; | ||
txinfos[1].tx.outputs[0].spentTxId = '661194e5533a395ce9076f292b7e0fb28fe94cd8832a81b4aa0517ff58c1ddd2'; | ||
txinfos[1].tx.outputs[0].spentIndex = 0; | ||
txinfos[1].tx.outputs[0].spentHeight = 134; | ||
txinfos[1].tx.outputs[1].spentTxId = '71a9e60c0341c9c258367f1a6d4253276f16e207bf84f41ff7412d8958a81bed'; | ||
txinfos[1].tx.outputs[1].spentIndex = 0; | ||
txinfos[1].tx.outputs[1].spentHeight = 112; | ||
var node = { | ||
getAddressHistory: sinon.stub().callsArgWith(2, null, historyResult), | ||
services: { | ||
db: { | ||
tip: { | ||
__height: 534223 | ||
} | ||
}, | ||
address: { | ||
getInputForOutput: function(txid, outputIndex, options, callback) { | ||
var data = false; | ||
if (txid === 'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7') { | ||
if (outputIndex === 0) { | ||
data = { | ||
inputTxId: '01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3', | ||
inputIndex: 0 | ||
}; | ||
} | ||
} else if (txid === '01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3') { | ||
if (outputIndex === 0) { | ||
data = { | ||
inputTxId: '661194e5533a395ce9076f292b7e0fb28fe94cd8832a81b4aa0517ff58c1ddd2', | ||
inputIndex: 0 | ||
} | ||
} else if (outputIndex === 1) { | ||
data = { | ||
inputTxId: '71a9e60c0341c9c258367f1a6d4253276f16e207bf84f41ff7412d8958a81bed', | ||
inputIndex: 0 | ||
} | ||
} | ||
} | ||
setImmediate(function() { | ||
callback(null, data); | ||
}); | ||
} | ||
bitcoind: { | ||
height: 534223 | ||
} | ||
@@ -667,147 +764,153 @@ }, | ||
var insight = { | ||
"pagesTotal": 1, | ||
"txs": [ | ||
'pagesTotal': 1, | ||
'txs': [ | ||
{ | ||
'txid': 'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7', | ||
'version': 1, | ||
'locktime': 534089, | ||
'vin': [ | ||
{ | ||
"txid": "bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7", | ||
"version": 1, | ||
"locktime": 534089, | ||
"vin": [ | ||
{ | ||
"txid": "ea5e5bafbf29cdf6f6097ab344128477e67889d4d6203cb43594836daa6cc425", | ||
"vout": 1, | ||
"scriptSig": { | ||
"asm": "3045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a601 03acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6", | ||
"hex": "483045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a6012103acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6" | ||
}, | ||
"sequence": 4294967294, | ||
"n": 0, | ||
"addr": "msyjRQQ88MabQmyafpKCjBHUwuJ49tVjcb", | ||
"valueSat": 2796764565, | ||
"value": 27.96764565, | ||
"doubleSpentTxID": null | ||
} | ||
], | ||
"vout": [ | ||
{ | ||
"value": "27.82729129", | ||
"n": 0, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 3583efb5e64a4668c6c54bb5fcc30af4417b4f2d OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er" | ||
] | ||
}, | ||
"spentTxId": "01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3", | ||
"spentIndex": 0, | ||
"spentTs": 1441072817 | ||
}, | ||
{ | ||
"value": "0.14000000", | ||
"n": 1, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 9713201957f42379e574d7c70d506ee49c2c8ad6 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a9149713201957f42379e574d7c70d506ee49c2c8ad688ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"muHmEsjhjmATf9i3T9gHyeQoce9LXe2dWz" | ||
] | ||
} | ||
} | ||
], | ||
"blockhash": "00000000000001001aba15de213648f370607fb048288dd27b96f7e833a73520", | ||
"blockheight": 534105, | ||
"confirmations": 119, | ||
"time": 1441068774, | ||
"blocktime": 1441068774, | ||
"valueOut": 27.96729129, | ||
"size": 226, | ||
"valueIn": 27.96764565, | ||
"fees": 0.00035436 | ||
'txid': 'ea5e5bafbf29cdf6f6097ab344128477e67889d4d6203cb43594836daa6cc425', | ||
'vout': 1, | ||
'scriptSig': { | ||
'asm': '3045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a601 03acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6', | ||
'hex': '483045022100f4d169783bef70e3943d2a617cce55d9fe4e33fc6f9880b8277265e2f619a97002201238648abcdf52960500664e969046d41755f7fc371971ebc78002fc418465a6012103acdcd31d51272403ce0829447e59e2ac9e08ed0bf92011cbf7420addf24534e6' | ||
}, | ||
'sequence': 4294967294, | ||
'n': 0, | ||
'addr': 'msyjRQQ88MabQmyafpKCjBHUwuJ49tVjcb', | ||
'valueSat': 2796764565, | ||
'value': 27.96764565, | ||
'doubleSpentTxID': null | ||
} | ||
], | ||
'vout': [ | ||
{ | ||
'value': '27.82729129', | ||
'n': 0, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 3583efb5e64a4668c6c54bb5fcc30af4417b4f2d OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a9143583efb5e64a4668c6c54bb5fcc30af4417b4f2d88ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er' | ||
] | ||
}, | ||
'spentTxId': '01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3', | ||
'spentIndex': 0, | ||
'spentHeight': 199, | ||
'spentTs': 1441072817 | ||
}, | ||
{ | ||
"txid": "01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3", | ||
"version": 1, | ||
"locktime": 534099, | ||
"vin": [ | ||
{ | ||
"txid": "bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7", | ||
"vout": 0, | ||
"scriptSig": { | ||
"asm": "304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d56401 034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24", | ||
"hex": "47304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d5640121034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24" | ||
}, | ||
"sequence": 4294967294, | ||
"n": 0, | ||
"addr": "mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er", | ||
"valueSat": 2782729129, | ||
"value": 27.82729129, | ||
"doubleSpentTxID": null | ||
} | ||
], | ||
"vout": [ | ||
{ | ||
"value": "27.64693692", | ||
"n": 0, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 56e446bc3489543d8324c6d0271524c0bd0506dd OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a91456e446bc3489543d8324c6d0271524c0bd0506dd88ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"moSPsU4p2C2gssiniJ1JNH4fB9xs633tLv" | ||
] | ||
}, | ||
"spentTxId": "661194e5533a395ce9076f292b7e0fb28fe94cd8832a81b4aa0517ff58c1ddd2", | ||
"spentIndex": 0, | ||
"spentTs": 1441077236 | ||
}, | ||
{ | ||
"value": "0.18000000", | ||
"n": 1, | ||
"scriptPubKey": { | ||
"asm": "OP_DUP OP_HASH160 011d2963b619186a318f768dddfd98cd553912a0 OP_EQUALVERIFY OP_CHECKSIG", | ||
"hex": "76a914011d2963b619186a318f768dddfd98cd553912a088ac", | ||
"reqSigs": 1, | ||
"type": "pubkeyhash", | ||
"addresses": [ | ||
"mfcquSAitCkUKXaYRZTRZQDfUegnL3kDew" | ||
] | ||
}, | ||
"spentTxId": "71a9e60c0341c9c258367f1a6d4253276f16e207bf84f41ff7412d8958a81bed", | ||
"spentIndex": 0, | ||
"spentTs": 1441069523 | ||
} | ||
], | ||
"blockhash": "0000000000000a3acc1f7fe72917eb48bb319ed96c125a6dfcc0ba6acab3c4d0", | ||
"blockheight": 534110, | ||
"confirmations": 114, | ||
"time": 1441072817, | ||
"blocktime": 1441072817, | ||
"valueOut": 27.82693692, | ||
"size": 225, | ||
"valueIn": 27.82729129, | ||
"fees": 0.00035437 | ||
'value': '0.14000000', | ||
'n': 1, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 9713201957f42379e574d7c70d506ee49c2c8ad6 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a9149713201957f42379e574d7c70d506ee49c2c8ad688ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'muHmEsjhjmATf9i3T9gHyeQoce9LXe2dWz' | ||
] | ||
}, | ||
'spentTxId': null, | ||
'spentIndex': null, | ||
'spentHeight': null | ||
} | ||
] | ||
], | ||
'blockhash': '00000000000001001aba15de213648f370607fb048288dd27b96f7e833a73520', | ||
'blockheight': 534105, | ||
'confirmations': 119, | ||
'time': 1441068774, | ||
'blocktime': 1441068774, | ||
'valueOut': 27.96729129, | ||
'size': 226, | ||
'valueIn': 27.96764565, | ||
'fees': 0.00035436 | ||
}, | ||
{ | ||
'txid': '01f700df84c466f2a389440e5eeacdc47d04f380c39e5d19dce2ce91a11ecba3', | ||
'version': 1, | ||
'locktime': 534099, | ||
'vin': [ | ||
{ | ||
'txid': 'bb0ec3b96209fac9529570ea6f83a86af2cceedde4aaf2bfcc4796680d23f1c7', | ||
'vout': 0, | ||
'scriptSig': { | ||
'asm': '304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d56401 034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24', | ||
'hex': '47304402201ee69281db6b95bb1aa3074059b67581635b719e8f64e4c2694db6ec56ad9447022011e91528996ea459b1fb2c0b59363fecbefe4bc2ca90f7b2382bdaa358f2d5640121034cc057b12a68ee79df998004b9a1341bbb18b17ea4939bebaa3bac001e940f24' | ||
}, | ||
'sequence': 4294967294, | ||
'n': 0, | ||
'addr': 'mkPvAKZ2rar6qeG3KjBtJHHMSP1wFZH7Er', | ||
'valueSat': 2782729129, | ||
'value': 27.82729129, | ||
'doubleSpentTxID': null | ||
} | ||
], | ||
'vout': [ | ||
{ | ||
'value': '27.64693692', | ||
'n': 0, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 56e446bc3489543d8324c6d0271524c0bd0506dd OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a91456e446bc3489543d8324c6d0271524c0bd0506dd88ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'moSPsU4p2C2gssiniJ1JNH4fB9xs633tLv' | ||
] | ||
}, | ||
'spentTxId': '661194e5533a395ce9076f292b7e0fb28fe94cd8832a81b4aa0517ff58c1ddd2', | ||
'spentIndex': 0, | ||
'spentHeight': 134, | ||
'spentTs': 1441077236 | ||
}, | ||
{ | ||
'value': '0.18000000', | ||
'n': 1, | ||
'scriptPubKey': { | ||
'asm': 'OP_DUP OP_HASH160 011d2963b619186a318f768dddfd98cd553912a0 OP_EQUALVERIFY OP_CHECKSIG', | ||
'hex': '76a914011d2963b619186a318f768dddfd98cd553912a088ac', | ||
'reqSigs': 1, | ||
'type': 'pubkeyhash', | ||
'addresses': [ | ||
'mfcquSAitCkUKXaYRZTRZQDfUegnL3kDew' | ||
] | ||
}, | ||
'spentTxId': '71a9e60c0341c9c258367f1a6d4253276f16e207bf84f41ff7412d8958a81bed', | ||
'spentIndex': 0, | ||
'spentHeight': 112, | ||
'spentTs': 1441069523 | ||
} | ||
], | ||
'blockhash': '0000000000000a3acc1f7fe72917eb48bb319ed96c125a6dfcc0ba6acab3c4d0', | ||
'blockheight': 534110, | ||
'confirmations': 114, | ||
'time': 1441072817, | ||
'blocktime': 1441072817, | ||
'valueOut': 27.82693692, | ||
'size': 225, | ||
'valueIn': 27.82729129, | ||
'fees': 0.00035437 | ||
} | ||
] | ||
}; | ||
var todos = { | ||
"txs": [ | ||
'txs': [ | ||
{ | ||
"vin": [ | ||
'vin': [ | ||
], | ||
"vout": [ | ||
'vout': [ | ||
{ | ||
"scriptPubKey": { | ||
"reqSigs": 1 | ||
'scriptPubKey': { | ||
'reqSigs': 1 | ||
}, | ||
"spentTs": 1441072817 | ||
'spentTs': 1441072817 | ||
}, | ||
{ | ||
"scriptPubKey": { | ||
"reqSigs": 1 | ||
'scriptPubKey': { | ||
'reqSigs': 1 | ||
} | ||
@@ -818,16 +921,16 @@ } | ||
{ | ||
"vin": [ | ||
'vin': [ | ||
], | ||
"vout": [ | ||
'vout': [ | ||
{ | ||
"scriptPubKey": { | ||
"reqSigs": 1 | ||
'scriptPubKey': { | ||
'reqSigs': 1 | ||
}, | ||
"spentTs": 1441077236 | ||
'spentTs': 1441077236 | ||
}, | ||
{ | ||
"scriptPubKey": { | ||
"reqSigs": 1 | ||
'scriptPubKey': { | ||
'reqSigs': 1 | ||
}, | ||
"spentTs": 1441069523 | ||
'spentTs': 1441069523 | ||
} | ||
@@ -863,3 +966,3 @@ ] | ||
var node = { | ||
getTransaction: sinon.stub().callsArgWith(2, null, bitcore.Transaction().fromBuffer(new Buffer(hex, 'hex'))) | ||
getTransaction: sinon.stub().callsArgWith(1, null, bitcore.Transaction().fromBuffer(new Buffer(hex, 'hex'))) | ||
}; | ||
@@ -870,3 +973,7 @@ | ||
var res = {}; | ||
var req = {}; | ||
var req = { | ||
params: { | ||
txid: txid | ||
} | ||
}; | ||
var next = function() { | ||
@@ -877,3 +984,3 @@ should(req.rawTransaction.rawtx).eql(hex); | ||
var txid = '25a988e54b02e0e5df146a0f8fa7b9db56210533a9f04bdfda5f4ceb6f77aadd'; | ||
transactions.rawTransaction(req, res, next, txid); | ||
transactions.rawTransaction(req, res, next); | ||
}); | ||
@@ -885,13 +992,13 @@ }); | ||
var insight = { | ||
"txid": "a15a7c257af596704390d345ff3ea2eed4cd02ce8bfb8afb700bff82257e49fb", | ||
"valueOut": 0.02038504, | ||
"vout": [ | ||
'txid': 'a15a7c257af596704390d345ff3ea2eed4cd02ce8bfb8afb700bff82257e49fb', | ||
'valueOut': 0.02038504, | ||
'vout': [ | ||
{ | ||
"3DQYCLG6rZdtV2Xw8y4YtozZjNHYoKsLuo": 45000 | ||
'3DQYCLG6rZdtV2Xw8y4YtozZjNHYoKsLuo': 45000 | ||
}, | ||
{ | ||
"12WvZmssxT85f81dD6wcmWznxbnFkEpNMS": 1993504 | ||
'12WvZmssxT85f81dD6wcmWznxbnFkEpNMS': 1993504 | ||
} | ||
], | ||
"isRBF": false, | ||
'isRBF': false | ||
}; | ||
@@ -913,10 +1020,10 @@ | ||
var insight = { | ||
"txid": "716d54157c31e52c820494c6c2b8af1b64352049f4dcc80632aa15742a7f82c4", | ||
"valueOut": 12.5002, | ||
"vout": [ | ||
'txid': '716d54157c31e52c820494c6c2b8af1b64352049f4dcc80632aa15742a7f82c4', | ||
'valueOut': 12.5002, | ||
'vout': [ | ||
{ | ||
"n4eY3qiP9pi32MWC6FcJFHciSsfNiYFYgR": 12.5002 * 1e8 | ||
'n4eY3qiP9pi32MWC6FcJFHciSsfNiYFYgR': 12.5002 * 1e8 | ||
} | ||
], | ||
"isRBF": false, | ||
'isRBF': false | ||
}; | ||
@@ -937,9 +1044,11 @@ | ||
it('should detect RBF txs', function() { | ||
var testCases = [{ | ||
rawTx: '01000000017fa897c3556271c34cb28c03c196c2d912093264c9d293cb4980a2635474467d010000000f5355540b6f93598893578893588851ffffffff01501e0000000000001976a914aa2482ce71d219018ef334f6cc551ee88abd920888ac00000000', | ||
expected: false, | ||
}, { | ||
rawTx: '01000000017fa897c3556271c34cb28c03c196c2d912093264c9d293cb4980a2635474467d010000000f5355540b6f935988935788935888510000000001501e0000000000001976a914aa2482ce71d219018ef334f6cc551ee88abd920888ac00000000', | ||
expected: true, | ||
}, ]; | ||
var testCases = [ | ||
{ | ||
rawTx: '01000000017fa897c3556271c34cb28c03c196c2d912093264c9d293cb4980a2635474467d010000000f5355540b6f93598893578893588851ffffffff01501e0000000000001976a914aa2482ce71d219018ef334f6cc551ee88abd920888ac00000000', | ||
expected: false, | ||
}, { | ||
rawTx: '01000000017fa897c3556271c34cb28c03c196c2d912093264c9d293cb4980a2635474467d010000000f5355540b6f935988935788935888510000000001501e0000000000001976a914aa2482ce71d219018ef334f6cc551ee88abd920888ac00000000', | ||
expected: true, | ||
}, | ||
]; | ||
@@ -946,0 +1055,0 @@ var node = { |
@@ -13,8 +13,8 @@ 'use strict'; | ||
bitcoind: { | ||
estimateFee: function(blocks) { | ||
estimateFee: function(blocks, callback) { | ||
switch(blocks) { | ||
case 1: | ||
return 1000; | ||
case 3: | ||
return 3000; | ||
case 1: | ||
return callback(null, 1000 / 1e8); | ||
case 3: | ||
return callback(null, 3000 / 1e8); | ||
} | ||
@@ -21,0 +21,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
666012
27
6144
450
1
9
+ Addedcompression@^1.6.1
+ Addedlru-cache@^4.0.1
+ Addedmorgan@^1.7.0
+ Addedaccepts@1.3.8(transitive)
+ Addedbasic-auth@2.0.1(transitive)
+ Addedbytes@3.0.0(transitive)
+ Addedcompressible@2.0.18(transitive)
+ Addedcompression@1.7.4(transitive)
+ Addedlru-cache@4.1.5(transitive)
+ Addedmime-db@1.53.0(transitive)
+ Addedmorgan@1.10.0(transitive)
+ Addednegotiator@0.6.3(transitive)
+ Addedon-finished@2.3.0(transitive)
+ Addedon-headers@1.0.2(transitive)
+ Addedpseudomap@1.0.2(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedvary@1.1.2(transitive)
+ Addedyallist@2.1.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)