select first external output as 'addressTo'

This commit is contained in:
Ivan Socolsky 2015-04-10 21:19:46 -03:00
parent c425b53389
commit 70244cc413
2 changed files with 8 additions and 4 deletions

View File

@ -1058,7 +1058,10 @@ WalletService.prototype.getTxHistory = function(opts, cb) {
amount = Math.abs(amount);
if (action == 'sent' || action == 'moved') {
addressTo = outputs[0].address;
var firstExternalOutput = _.find(outputs, {
isMine: false
});
addressTo = firstExternalOutput ? firstExternalOutput.address : 'N/A';
};
var newTx = {

View File

@ -2408,11 +2408,11 @@ describe('Wallet service', function() {
amount: utxos[0].satoshis,
}],
outputs: [{
address: 'external',
amount: helpers.toSatoshi(80) - 5460,
}, {
address: changeAddresses[0].address,
amount: helpers.toSatoshi(20) - 5460,
}, {
address: 'external',
amount: helpers.toSatoshi(80) - 5460,
}],
}];
helpers.stubHistory(txs);
@ -2425,6 +2425,7 @@ describe('Wallet service', function() {
tx.action.should.equal('sent');
tx.amount.should.equal(helpers.toSatoshi(80));
tx.message.should.equal('some message');
tx.addressTo.should.equal('external');
tx.actions.length.should.equal(1);
tx.actions[0].type.should.equal('accept');
tx.actions[0].copayerName.should.equal('copayer 1');