WIP: Ref topup. Fix sendmax

This commit is contained in:
Gustavo Maximiliano Cortez 2017-06-27 19:10:54 -03:00
commit 36b64bdfa7
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 241 additions and 190 deletions

View file

@ -45,8 +45,7 @@ angular.module('copayApp.services').factory('ongoingProcess', function($log, $ti
'cancelingGiftCard': 'Canceling Gift Card...',
'creatingGiftCard': 'Creating Gift Card...',
'buyingGiftCard': 'Buying Gift Card...',
'topup': gettext('Top up in progress...'),
'creatingInvoice': gettext('Creating invoice...')
'topup': gettext('Top up in progress...')
};
root.clear = function() {

View file

@ -10,7 +10,7 @@ angular.module('copayApp.services').service('sendMaxService', function(feeServic
*
*/
this.getInfo = function(wallet, cb) {
feeService.getCurrentFeeRate(wallet.credentials.network, null, function(err, feePerKb) {
feeService.getCurrentFeeRate(wallet.credentials.network, function(err, feePerKb) {
if (err) return cb(err);
var config = configService.getSync().wallet;

View file

@ -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