Merge pull request #3689 from cmgustavo/bug/multiple-outputs

Fixes proposals with multiple outputs with only one output
This commit is contained in:
Matias Alejo Garcia 2015-12-16 16:43:47 -03:00
commit 0f57f489e2
2 changed files with 21 additions and 3 deletions

View File

@ -495,6 +495,25 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.pendingTxProposalsCountForUs = 0;
var now = Math.floor(Date.now() / 1000);
/* Uncomment to test multiple outputs */
/*
var txp = {
message: 'test multi-output',
fee: 1000,
createdOn: new Date() / 1000,
outputs: []
};
function addOutput(n) {
txp.outputs.push({
amount: 600,
toAddress: '2N8bhEwbKtMvR2jqMRcTCQqzHP6zXGToXcK',
message: 'output #' + (Number(n) + 1)
});
};
lodash.times(150, addOutput);
txps.push(txp);
*/
lodash.each(txps, function(tx) {
tx = txFormatService.processTx(tx);

View File

@ -24,10 +24,9 @@ angular.module('copayApp.services').factory('txFormatService', function(profileS
root.processTx = function(tx) {
if (!tx) return;
var outputs = tx.outputs ? tx.outputs.length : 0;
if (outputs > 1 && tx.action != 'received') {
if (lodash.isArray(tx.outputs) && tx.outputs.length > 0 && tx.action != 'received') {
tx.hasMultiplesOutputs = true;
tx.recipientCount = outputs;
tx.recipientCount = tx.outputs.length;
tx.amount = lodash.reduce(tx.outputs, function(total, o) {
o.amountStr = formatAmountStr(o.amount);
o.alternativeAmountStr = formatAlternativeStr(o.amount);