fixing outgoing balances

This commit is contained in:
Manuel Araoz 2015-04-30 01:36:14 -03:00
parent c955498f4d
commit 20fec9d17b
3 changed files with 15 additions and 11 deletions

View File

@ -188,10 +188,17 @@ BitcoreNode.prototype.getStatus = function() {
peerCount: this.networkMonitor.getConnectedPeers(), peerCount: this.networkMonitor.getConnectedPeers(),
version: pjson.version, version: pjson.version,
network: bitcore.Networks.defaultNetwork.name, network: bitcore.Networks.defaultNetwork.name,
height: this.blockchain.getCurrentHeight(), height: this.getCurrentHeight(),
}); });
}; };
BitcoreNode.prototype.getCurrentHeight = function() {
if (!this.blockchain) {
return 0;
}
return this.blockchain.getCurrentHeight();
};
BitcoreNode.prototype.getSyncProgress = function() { BitcoreNode.prototype.getSyncProgress = function() {
return !_.isUndefined(this.reportedMaxHeight) ? return !_.isUndefined(this.reportedMaxHeight) ?
(this.blockchain.getCurrentHeight() / this.reportedMaxHeight) : 0; (this.blockchain.getCurrentHeight() / this.reportedMaxHeight) : 0;

View File

@ -140,9 +140,12 @@ TransactionService.prototype._confirmInput = function(ops, block, transaction) {
var self = this; var self = this;
var txid = transaction.id; var txid = transaction.id;
return function(input, index) { return function(input, index) {
if (input.prevTxId.toString('hex') === NULLTXHASH) { if (input.isNull()) {
return Promise.resolve(); return Promise.resolve();
} }
if (input.script.isPublicKeyHashIn()) {
console.log(input.toObject());
}
ops.push({ ops.push({
type: 'put', type: 'put',
key: Index.getOutput(txid, index), key: Index.getOutput(txid, index),
@ -151,12 +154,13 @@ TransactionService.prototype._confirmInput = function(ops, block, transaction) {
})) }))
}); });
var script = input.script; var script = input.script;
if (!(script.isPublicKeyHashIn() || script.isPublicKeyIn() || script.isScriptHashIn())) { if (!(script.isPublicKeyHashIn() || script.isScriptHashIn())) {
return; return;
} }
return Promise.try(function() { return Promise.try(function() {
var address = self._getAddressForInput(input); var address = input.script.toAddress();
console.log('input address!', address.toString());
if (address) { if (address) {
ops.push({ ops.push({
type: 'put', type: 'put',
@ -173,12 +177,6 @@ TransactionService.prototype._confirmInput = function(ops, block, transaction) {
}; };
}; };
TransactionService.prototype._getAddressForInput = function(input) {
var script = input.script;
// TODO: move this to bitcore
return new bitcore.Script(script.chunks[script.chunks.length - 1]).toAddress();
};
TransactionService.prototype._confirmTransaction = function(ops, block, transaction) { TransactionService.prototype._confirmTransaction = function(ops, block, transaction) {
var self = this; var self = this;
ops.push({ ops.push({

View File

@ -39,7 +39,6 @@
"bluebird": "^2.9.12", "bluebird": "^2.9.12",
"body-parser": "^1.12.0", "body-parser": "^1.12.0",
"bufferput": "bitpay/node-bufferput", "bufferput": "bitpay/node-bufferput",
"buffertools": "*",
"compression": "^1.4.1", "compression": "^1.4.1",
"config": "^1.12.0", "config": "^1.12.0",
"cors": "^2.5.3", "cors": "^2.5.3",