Fixed issue with mempool transactions.

This commit is contained in:
Chris Kleeschulte 2017-08-15 21:37:29 -04:00
parent d7169ff639
commit 11c9aa022f
2 changed files with 15 additions and 6 deletions

View File

@ -36,6 +36,7 @@ MempoolService.prototype.getPublishEvents = function() {
];
};
MempoolService.prototype.subscribe = function(name, emitter) {
this._subscriptions[name].push(emitter);

View File

@ -5,7 +5,6 @@ var inherits = require('util').inherits;
var Encoding = require('./encoding');
var utils = require('../../utils');
var _ = require('lodash');
var Unit = require('bitcore-lib').Unit;
var log = require('../../index').log;
var async = require('async');
var assert = require('assert');
@ -92,8 +91,8 @@ TransactionService.prototype._setMetaInfo = function(tx, options, callback) {
});
var feeSatoshis = inputSatoshis - outputSatoshis;
tx.inputSatosbis = inputSatoshis;
tx.feeSatosbis = feeSatoshis;
tx.inputSatoshis = inputSatoshis;
tx.feeSatoshis = feeSatoshis;
}
@ -117,7 +116,7 @@ TransactionService.prototype._getMempoolTransaction = function(txid, tx, options
}
if (!tx) {
return callback();
return callback(null, tx, options);
}
tx.confirmations = 0;
@ -140,7 +139,7 @@ TransactionService.prototype._getTransaction = function(txid, options, callback)
}
if (!tx) {
return callback(null, tx, options);
return callback(null, txid, tx, options);
}
tx = self._encoding.decodeTransactionValue(tx);
@ -167,8 +166,17 @@ TransactionService.prototype._getTransaction = function(txid, options, callback)
TransactionService.prototype.getInputValues = function(tx, options, callback) {
var self = this;
if (!tx) {
return callback(null, tx, options);
}
async.eachOfLimit(tx.inputs, 4, function(input, index, next) {
if (!tx.__inputValues) {
tx.__inputValues = [];
}
var inputSatoshis = tx.__inputValues[index];
if (inputSatoshis >= 0 || input.isCoinbase()) {
@ -185,7 +193,7 @@ TransactionService.prototype.getInputValues = function(tx, options, callback) {
var output = _tx.outputs[outputIndex];
assert(output, 'Expected an output, but did not get one for tx: ' + _tx.txid() + ' outputIndex: ' + outputIndex);
tx.__inputValues[index] = Unit.fromBTC(output.value).toSatoshis();
tx.__inputValues[index] = output.value;
next();
});