Merge pull request #106 from matiu/bug/fix-double-spent
fix double spent reports
This commit is contained in:
commit
4dabb9f15e
|
@ -100,7 +100,6 @@ exports.list = function(req, res) {
|
|||
var dateStr;
|
||||
var todayStr = formatTimestamp(new Date());
|
||||
|
||||
console.log('[blocks.js.102]'); //TODO
|
||||
if (req.query.blockDate) {
|
||||
// TODO: Validate format yyyy-mm-dd
|
||||
dateStr = req.query.blockDate;
|
||||
|
@ -110,18 +109,14 @@ console.log('[blocks.js.102]'); //TODO
|
|||
isToday = true;
|
||||
}
|
||||
var gte = Math.round((new Date(dateStr)).getTime() / 1000);
|
||||
console.log('[blocks.js.112:gte:]',gte); //TODO
|
||||
|
||||
//pagination
|
||||
var lte = parseInt(req.query.startTimestamp) || gte + 86400;
|
||||
console.log('[blocks.js.115:lte:]',lte); //TODO
|
||||
var prev = formatTimestamp(new Date((gte - 86400) * 1000));
|
||||
var next = lte ? formatTimestamp(new Date(lte * 1000)) :null;
|
||||
console.log('[blocks.js.116:next:]',next, lte); //TODO
|
||||
var limit = parseInt(req.query.limit || DFLT_LIMIT) + 1;
|
||||
var more;
|
||||
|
||||
console.log('[blocks.js.119]'); //TODO
|
||||
bdb.getBlocksByDate(gte, lte, limit, function(err, blockList) {
|
||||
|
||||
if (err) {
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var util = require('util'),
|
||||
config = require('../config/config');
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
var TransactionDb = require('../lib/TransactionDb.js').default();
|
||||
var hash = process.argv[2] || '4286d6fc82a314348af4e9d3ce649f78ce4569937e9ad6613563755f0d14e3d1';
|
||||
|
||||
var t= TransactionDb.fromIdWithInfo(hash,function(err,tx) {
|
||||
console.log('Err:');
|
||||
console.log(err);
|
||||
|
||||
console.log('Ret:');
|
||||
console.log(util.inspect(tx,{depth:null}));
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
'use strict';
|
||||
|
||||
var util = require('util');
|
||||
var T = require('../lib/TransactionDb');
|
||||
|
||||
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
|
||||
|
||||
|
||||
// var hash = process.argv[2] || '0000000000b6288775bbd326bedf324ca8717a15191da58391535408205aada4';
|
||||
var hash = process.argv[2] || 'e2253359458db3e732c82a43fc62f56979ff59928f25a2df34dfa443e9a41160';
|
||||
|
||||
|
||||
|
||||
var t = new T();
|
||||
t.fromIdWithInfo(hash, function(err, ret) {
|
||||
|
||||
console.log('Err:');
|
||||
console.log(err);
|
||||
|
||||
|
||||
console.log('Ret:');
|
||||
console.log(util.inspect(ret,{depth:null}));
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -301,7 +301,6 @@ BlockDb.prototype.getBlocksByDate = function(start_ts, end_ts, limit, cb) {
|
|||
limit: limit,
|
||||
reverse: 1,
|
||||
};
|
||||
console.log('[BlockDb.js.298:opts:]',opts); //TODO
|
||||
|
||||
db.createReadStream(opts)
|
||||
.on('data', function (data) {
|
||||
|
|
|
@ -40,7 +40,7 @@ var bitcore = require('bitcore'),
|
|||
buffertools = require('buffertools');
|
||||
|
||||
var logger = require('./logger').logger;
|
||||
var info = logger.info;
|
||||
var inf = logger.inf;
|
||||
|
||||
var db = imports.db || levelup(config.leveldb + '/txs',{maxOpenFiles: MAX_OPEN_FILES} );
|
||||
var PoolMatch = imports.poolMatch || require('soop').load('./PoolMatch',config);
|
||||
|
@ -188,7 +188,7 @@ TransactionDb.prototype._fillOutpoints = function(txInfo, cb) {
|
|||
async.eachLimit(txInfo.vin, CONCURRENCY, function(i, c_in) {
|
||||
self.fromTxIdN(i.txid, i.vout, function(err, ret) {
|
||||
if (!ret || !ret.addr || !ret.valueSat) {
|
||||
info('Could not get TXouts in %s,%d from %s ', i.txid, i.vout, txInfo.txid);
|
||||
inf('Could not get TXouts in %s,%d from %s ', i.txid, i.vout, txInfo.txid);
|
||||
if (ret) i.unconfirmedInput = ret.unconfirmedInput;
|
||||
incompleteInputs = 1;
|
||||
return c_in(); // error not scalated
|
||||
|
@ -201,12 +201,15 @@ TransactionDb.prototype._fillOutpoints = function(txInfo, cb) {
|
|||
i.value = ret.valueSat / util.COIN;
|
||||
valueIn += i.valueSat;
|
||||
|
||||
console.log('[TransactionDb.js.204:ret:]',ret); //TODO
|
||||
if (ret.multipleSpentAttempt || !ret.spentTxId ||
|
||||
(ret.spentTxId && ret.spentTxId !== info.txid)
|
||||
(ret.spentTxId && ret.spentTxId !== txInfo.txid)
|
||||
) {
|
||||
if (ret.multipleSpentAttempts) {
|
||||
ret.multipleSpentAttempts.forEach(function(mul) {
|
||||
if (mul.spentTxId !== info.txid) {
|
||||
if (mul.spentTxId !== txInfo.txid) {
|
||||
|
||||
console.log('[TransactionDb.js.210]'); //TODO
|
||||
i.doubleSpentTxID = ret.spentTxId;
|
||||
i.doubleSpentIndex = ret.spentIndex;
|
||||
}
|
||||
|
@ -214,6 +217,8 @@ TransactionDb.prototype._fillOutpoints = function(txInfo, cb) {
|
|||
} else if (!ret.spentTxId) {
|
||||
i.dbError = 'Input spent not registered';
|
||||
} else {
|
||||
|
||||
console.log('[TransactionDb.js.219]'); //TODO
|
||||
i.doubleSpentTxID = ret.spentTxId;
|
||||
i.doubleSpentIndex = ret.spentIndex;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue