diff --git a/lib/server.js b/lib/server.js index 9718476..5465335 100644 --- a/lib/server.js +++ b/lib/server.js @@ -2838,7 +2838,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) { if (err || !height) return next(err); _.each(txs, function(tx) { if (tx.blockheight >= 0) { - tx.confirmations = height - tx.blockheight; + tx.confirmations = height - tx.blockheight + 1; } }); next(); diff --git a/test/integration/server.js b/test/integration/server.js index c415c82..d3205a2 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -6271,7 +6271,7 @@ describe('Wallet service', function() { calls[0].args[3].length.should.equal(5); // 5 txs have confirmations>= 100 // should be reversed! - calls[0].args[3][0].confirmations.should.equal(currentHeight - (totalItems - (skip + limit))); + calls[0].args[3][0].confirmations.should.equal(currentHeight - (totalItems - (skip + limit)) + 1); calls[0].args[3][0].txid.should.equal(h[skip + limit - 1].txid); server.storage.storeTxHistoryCache.restore(); done(); @@ -6325,7 +6325,7 @@ describe('Wallet service', function() { calls[0].args[3].length.should.equal(5); // should be reversed! - calls[0].args[3][0].confirmations.should.equal(currentHeight); + calls[0].args[3][0].confirmations.should.equal(currentHeight + 1); calls[0].args[3][0].txid.should.equal(h[totalItems - 1].txid); server.storage.storeTxHistoryCache.restore(); done(); @@ -6354,8 +6354,8 @@ describe('Wallet service', function() { var calls = storeTxHistoryCacheSpy.getCalls(); calls.length.should.equal(1); - _.first(txs).confirmations.should.equal(81); - _.last(txs).confirmations.should.equal(100); + _.first(txs).confirmations.should.equal(82); + _.last(txs).confirmations.should.equal(101); server.storage.storeTxHistoryCache.restore(); Defaults.CONFIRMATIONS_TO_START_CACHING = _confirmations;