WIP: Ref topup. Fix sendmax
This commit is contained in:
parent
dbd137f0a4
commit
36b64bdfa7
5 changed files with 241 additions and 190 deletions
|
|
@ -23,6 +23,26 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
return root.formatAmount(satoshis) + ' ' + config.unitName;
|
||||
};
|
||||
|
||||
root.formatToCode = function(satoshis, code, cb) {
|
||||
if (isNaN(satoshis)) return;
|
||||
var val = function() {
|
||||
var v1 = rateService.toFiat(satoshis, code);
|
||||
if (!v1) return null;
|
||||
|
||||
return v1.toFixed(2);
|
||||
};
|
||||
|
||||
// Async version
|
||||
if (cb) {
|
||||
rateService.whenAvailable(function() {
|
||||
return cb(val());
|
||||
});
|
||||
} else {
|
||||
if (!rateService.isAvailable()) return null;
|
||||
return val();
|
||||
};
|
||||
};
|
||||
|
||||
root.formatToUSD = function(satoshis, cb) {
|
||||
if (isNaN(satoshis)) return;
|
||||
var val = function() {
|
||||
|
|
@ -181,8 +201,8 @@ angular.module('copayApp.services').factory('txFormatService', function($filter,
|
|||
}
|
||||
|
||||
return {
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
amount: amount,
|
||||
currency: currency,
|
||||
alternativeIsoCode: alternativeIsoCode,
|
||||
amountSat: amountSat,
|
||||
amountUnitStr: amountUnitStr
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue