fix tx history normalization
This commit is contained in:
parent
c064b5e041
commit
c22cfd561e
|
@ -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,
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -147,7 +147,7 @@ var history = [{
|
|||
}
|
||||
}],
|
||||
confirmations: 2,
|
||||
time: 1424471041,
|
||||
firstSeenTs: 1424471041,
|
||||
blocktime: 1424471041,
|
||||
valueOut: 0.01345753,
|
||||
valueIn: 0.01371235,
|
||||
|
|
Loading…
Reference in New Issue