mirror of https://github.com/BTCPrivate/copay.git
added comment from proposal if available
This commit is contained in:
parent
b6f5b342f2
commit
d44b56d564
|
@ -2917,6 +2917,7 @@ Wallet.prototype.getTransactionHistory = function(cb) {
|
|||
var self = this;
|
||||
|
||||
var addresses = self.getAddressesInfo();
|
||||
var proposals = self.getTxProposals();
|
||||
var satToUnit = 1 / self.settings.unitToSatoshi;
|
||||
|
||||
function extractInsOuts(tx) {
|
||||
|
@ -2997,6 +2998,12 @@ Wallet.prototype.getTransactionHistory = function(cb) {
|
|||
var firstOut = _.findWhere(items, {
|
||||
type: 'out'
|
||||
});
|
||||
|
||||
var proposal = _.findWhere(proposals, {
|
||||
ntxid: tx.txid
|
||||
});
|
||||
|
||||
tx.comment = proposal ? proposal.comment : undefined;
|
||||
tx.labelTo = firstOut ? firstOut.label : undefined;
|
||||
tx.amountSat = Math.abs(amount);
|
||||
tx.amount = tx.amountSat * satToUnit;
|
||||
|
|
|
@ -2127,7 +2127,54 @@ describe('Wallet model', function() {
|
|||
done();
|
||||
});
|
||||
});
|
||||
it('should assign comment from tx proposal if found', function(done) {
|
||||
var w = cachedCreateW2();
|
||||
var txs = [{
|
||||
txid: 'id1',
|
||||
vin: [{
|
||||
addr: 'addr_in_1',
|
||||
valueSat: 3000
|
||||
}, {
|
||||
addr: 'addr_in_2',
|
||||
valueSat: 2000
|
||||
}],
|
||||
vout: [{
|
||||
scriptPubKey: {
|
||||
addresses: ['addr_out_1'],
|
||||
},
|
||||
value: '0.00003900',
|
||||
}, {
|
||||
scriptPubKey: {
|
||||
addresses: ['change'],
|
||||
},
|
||||
value: '0.00001000',
|
||||
}],
|
||||
fees: 0.00000100
|
||||
}];
|
||||
|
||||
w.blockchain.getTransactions = sinon.stub().yields(null, txs);
|
||||
w.getAddressesInfo = sinon.stub().returns([{
|
||||
addressStr: 'addr_in_1'
|
||||
}, {
|
||||
addressStr: 'addr_in_2'
|
||||
}, {
|
||||
addressStr: 'change',
|
||||
isChange: true,
|
||||
}]);
|
||||
|
||||
w.getTxProposals = sinon.stub().returns([{
|
||||
ntxid: 'id0',
|
||||
comment: 'My comment',
|
||||
}, {
|
||||
ntxid: 'id1',
|
||||
comment: 'Another comment',
|
||||
}]);
|
||||
w.getTransactionHistory(function(err, res) {
|
||||
res.should.exist;
|
||||
res[0].comment.should.equal('Another comment');
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue