Fix fee for send all

This commit is contained in:
Gustavo Maximiliano Cortez 2015-12-23 18:05:22 -03:00
commit 66b7fa8f7a
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
5 changed files with 134 additions and 106 deletions

View file

@ -371,14 +371,15 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
};
self.setSpendUnconfirmed = function() {
self.spendUnconfirmed = configService.getSync().wallet.spendUnconfirmed;
self.setSpendUnconfirmed = function(spendUnconfirmed) {
self.spendUnconfirmed = spendUnconfirmed || configService.getSync().wallet.spendUnconfirmed;
};
self.setSendMax = function() {
self.setFeeAndSendMax = function(cb) {
self.feeToSendMaxStr = null;
self.feeRateToSendMax = null;
self.availableMaxBalance = null;
self.currentFeePerKb = null;
// Set Send max
if (self.currentFeeLevel && self.totalBytesToSendMax) {
@ -386,12 +387,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
// KB to send max
var feeToSendMaxSat = parseInt(((self.totalBytesToSendMax * feePerKb) / 1000.).toFixed(0));
self.feeRateToSendMax = feePerKb;
self.currentFeePerKb = feePerKb;
if (self.availableBalanceSat > feeToSendMaxSat) {
self.availableMaxBalance = strip((self.availableBalanceSat - feeToSendMaxSat) * self.satToUnit);
self.feeToSendMaxStr = profileService.formatAmount(feeToSendMaxSat) + ' ' + self.unitName;
}
if (cb) return cb(self.currentFeePerKb, self.availableMaxBalance, self.feeToSendMaxStr);
});
}
@ -399,7 +402,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setCurrentFeeLevel = function(level) {
self.currentFeeLevel = level || configService.getSync().wallet.settings.feeLevel || 'normal';
self.setSendMax();
self.setFeeAndSendMax();
};
@ -1185,8 +1188,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
});
});
$rootScope.$on('Local/SpendUnconfirmedUpdated', function(event) {
self.setSpendUnconfirmed();
$rootScope.$on('Local/SpendUnconfirmedUpdated', function(event, spendUnconfirmed) {
self.setSpendUnconfirmed(spendUnconfirmed);
self.updateAll();
});
@ -1194,6 +1197,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
self.setCurrentFeeLevel(level);
});
$rootScope.$on('Local/SetFeeSendMax', function(event, cb) {
self.setFeeAndSendMax(cb);
});
$rootScope.$on('Local/ProfileBound', function() {
storageService.getRemotePrefsStoredFlag(function(err, val) {
if (err || val) return;
@ -1449,4 +1456,5 @@ angular.module('copayApp.controllers').controller('indexController', function($r
$rootScope.$apply();
});
});
});