diff --git a/lib/node.js b/lib/node.js index 4ebcb503..0d7ac927 100644 --- a/lib/node.js +++ b/lib/node.js @@ -188,10 +188,17 @@ BitcoreNode.prototype.getStatus = function() { peerCount: this.networkMonitor.getConnectedPeers(), version: pjson.version, 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() { return !_.isUndefined(this.reportedMaxHeight) ? (this.blockchain.getCurrentHeight() / this.reportedMaxHeight) : 0; diff --git a/lib/services/transaction.js b/lib/services/transaction.js index d042a28c..01cf5730 100644 --- a/lib/services/transaction.js +++ b/lib/services/transaction.js @@ -140,9 +140,12 @@ TransactionService.prototype._confirmInput = function(ops, block, transaction) { var self = this; var txid = transaction.id; return function(input, index) { - if (input.prevTxId.toString('hex') === NULLTXHASH) { + if (input.isNull()) { return Promise.resolve(); } + if (input.script.isPublicKeyHashIn()) { + console.log(input.toObject()); + } ops.push({ type: 'put', key: Index.getOutput(txid, index), @@ -151,12 +154,13 @@ TransactionService.prototype._confirmInput = function(ops, block, transaction) { })) }); var script = input.script; - if (!(script.isPublicKeyHashIn() || script.isPublicKeyIn() || script.isScriptHashIn())) { + if (!(script.isPublicKeyHashIn() || script.isScriptHashIn())) { return; } return Promise.try(function() { - var address = self._getAddressForInput(input); + var address = input.script.toAddress(); + console.log('input address!', address.toString()); if (address) { ops.push({ 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) { var self = this; ops.push({ diff --git a/package.json b/package.json index cd14a3c0..e6b75fd4 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,6 @@ "bluebird": "^2.9.12", "body-parser": "^1.12.0", "bufferput": "bitpay/node-bufferput", - "buffertools": "*", "compression": "^1.4.1", "config": "^1.12.0", "cors": "^2.5.3",