From baf75b2d60ac5bc7ede79a3f30de8e4273dbb1b0 Mon Sep 17 00:00:00 2001 From: Chris Kleeschulte Date: Wed, 1 Nov 2017 16:00:39 -0400 Subject: [PATCH] Fixed confirmations. --- lib/services/address/index.js | 2 +- lib/services/transaction/index.js | 2 ++ test/services/address/index.unit.js | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/services/address/index.js b/lib/services/address/index.js index 7633396c..97144cd8 100644 --- a/lib/services/address/index.js +++ b/lib/services/address/index.js @@ -278,7 +278,7 @@ AddressService.prototype.getAddressUnspentOutputs = function(address, options, c amount: Unit.fromSatoshis(value.satoshis).toBTC(), height: value.height, satoshis: value.satoshis, - confirmationsFromCache: true + confirmations: self._block.getTip().height - value.height + 1 }); }); diff --git a/lib/services/transaction/index.js b/lib/services/transaction/index.js index 933e1eaf..4235683f 100644 --- a/lib/services/transaction/index.js +++ b/lib/services/transaction/index.js @@ -265,6 +265,8 @@ TransactionService.prototype._getTransaction = function(txid, options, callback) tx = self._encoding.decodeTransactionValue(tx); tx.confirmations = self._block.getTip().height - tx.__height + 1; + tx.__confirmations = self._block.getTip().height - tx.__height + 1; + tx.height = tx.__height; tx.blockhash = tx.__blockhash; callback(null, txid, tx, options); diff --git a/test/services/address/index.unit.js b/test/services/address/index.unit.js index a8a9e90a..60024db5 100644 --- a/test/services/address/index.unit.js +++ b/test/services/address/index.unit.js @@ -177,7 +177,7 @@ describe('Address Service', function() { value: encoding.encodeUtxoIndexValue(123, 120000, ts, tx.outputs[1].script.raw) }; - addressService._header = { getBestHeight: function() { return 150; } }; + addressService._block = { getTip: function() { return { height: 150 }; } }; var txidStream = new EventEmitter(); @@ -193,7 +193,7 @@ describe('Address Service', function() { address: 'a', amount: 0.0012, height: 123, - confirmationsFromCache: true, + confirmations: 28, satoshis: 120000, scriptPubKey: '76a91449f8c749a9960dc29b5cbe7d2397cea7d26611bb88ac', ts: 1546300800,