compute alternative currency for pending txps

This commit is contained in:
Ivan Socolsky 2014-11-04 10:56:13 -03:00
parent 67b392bdc3
commit 9db19422e4
1 changed files with 14 additions and 0 deletions

View File

@ -324,6 +324,17 @@ angular.module('copayApp.services')
};
root.updateTxs = function(opts) {
function computeAlternativeAmount(w, tx, cb) {
rateService.whenAvailable(function() {
_.each(tx.outs, function(out) {
var valueSat = out.value * w.settings.unitToSatoshi;
out.alternativeAmount = rateService.toFiat(valueSat, w.settings.alternativeIsoCode);
out.alternativeIsoCode = w.settings.alternativeIsoCode;
});
if (cb) return cb();
});
};
var w = opts.wallet || $rootScope.wallet;
if (!w) return;
opts = opts || $rootScope.txsOpts || {};
@ -364,6 +375,9 @@ angular.module('copayApp.services')
i.fee = i.builder.feeSat * satToUnit;
i.missingSignatures = tx.countInputMissingSignatures(0);
i.actionList = getActionList(i.peerActions);
if (i.isPending) {
computeAlternativeAmount(w, i);
}
txs.push(i);
}
});