diff --git a/lib/server.js b/lib/server.js index b604010..0043088 100644 --- a/lib/server.js +++ b/lib/server.js @@ -1446,6 +1446,8 @@ WalletService.prototype.getNotifications = function(opts, cb) { WalletService.prototype._normalizeTxHistory = function(txs) { + var now = Math.floor(Date.now() / 1000); + return _.map(txs, function(tx) { var inputs = _.map(tx.vin, function(item) { return { @@ -1471,7 +1473,7 @@ WalletService.prototype._normalizeTxHistory = function(txs) { txid: tx.txid, confirmations: tx.confirmations, fees: parseInt((tx.fees * 1e8).toFixed(0)), - time: !_.isNaN(tx.time) ? tx.time : Math.floor(Date.now() / 1000), + time: tx.firstSeenTs || (!_.isNaN(tx.time) ? tx.time : now) || now, inputs: inputs, outputs: outputs, }; @@ -1517,8 +1519,6 @@ WalletService.prototype.getTxHistory = function(opts, cb) { }); }; - var now = Math.floor(Date.now() / 1000); - return _.map(txs, function(tx) { var amountIn, amountOut, amountOutChange; @@ -1557,7 +1557,7 @@ WalletService.prototype.getTxHistory = function(opts, cb) { action: action, amount: amount, fees: tx.fees, - time: tx.firstSeenTs || tx.time || now, + time: tx.time, addressTo: addressTo, confirmations: tx.confirmations, }; diff --git a/package.json b/package.json index 26cac9e..12c0032 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "bitcore-wallet-service", "description": "A service for Mutisig HD Bitcoin Wallets", "author": "BitPay Inc", - "version": "0.0.44", + "version": "0.0.45", "keywords": [ "bitcoin", "copay", diff --git a/test/integration/server.js b/test/integration/server.js index 1a783b0..4ae1ea6 100644 --- a/test/integration/server.js +++ b/test/integration/server.js @@ -3472,7 +3472,6 @@ describe('Wallet service', function() { confirmations: 1, fees: 100, time: 20, - firstSeenTs: 2, inputs: [{ address: 'external', amount: 500, @@ -3491,7 +3490,7 @@ describe('Wallet service', function() { tx.action.should.equal('received'); tx.amount.should.equal(200); tx.fees.should.equal(100); - tx.time.should.equal(2); + tx.time.should.equal(20); done(); }); }); diff --git a/test/testdata.js b/test/testdata.js index 8fc9fb8..3f2c57b 100644 --- a/test/testdata.js +++ b/test/testdata.js @@ -147,7 +147,7 @@ var history = [{ } }], confirmations: 2, - time: 1424471041, + firstSeenTs: 1424471041, blocktime: 1424471041, valueOut: 0.01345753, valueIn: 0.01371235,