fix double spent reports
This commit is contained in:
parent
4ac7165276
commit
4eb31758e4
21
dev-util/getTx.js
Executable file
21
dev-util/getTx.js
Executable file
@ -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}));
|
||||
});
|
||||
|
||||
|
||||
|
||||
@ -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
Block a user