Merge pull request #1791 from matiu/bug/use-all-funds

Fix #1789 - use all funds button
This commit is contained in:
Esteban Ordano 2014-11-12 22:17:50 -03:00
commit 4726570b7a
8 changed files with 43 additions and 72 deletions

View file

@ -71,9 +71,9 @@ angular.module('copayApp.controllers').controller('SendController',
configurable: true
});
$scope.loadTxs = function() {
controllerUtils.updateTxs();
setTimeout(function() {
$scope.loading = false;
$rootScope.$digest();
@ -120,6 +120,9 @@ angular.module('copayApp.controllers').controller('SendController',
if (msg.match('BIG'))
msg = 'The transaction have too many inputs. Try creating many transactions for smaller amounts.'
if (msg.match('totalNeededAmount'))
msg = 'Not enough funds.'
var message = 'The transaction' + (w.isShared() ? ' proposal' : '') + ' could not be created: ' + msg;
$scope.error = message;
$scope.loading = false;
@ -400,17 +403,8 @@ angular.module('copayApp.controllers').controller('SendController',
});
};
$scope.getAvailableAmount = function() {
if (!$rootScope.safeUnspentCount) return null;
var estimatedFee = copay.Wallet.estimatedFee($rootScope.safeUnspentCount);
var amount = ((($rootScope.availableBalance * w.settings.unitToSatoshi).toFixed(0) - estimatedFee) / w.settings.unitToSatoshi);
return amount > 0 ? amount : 0;
};
$scope.topAmount = function(form) {
$scope.amount = $scope.getAvailableAmount();
$scope.setTopAmount = function() {
$scope.amount = $rootScope.topAmount;
};
@ -449,6 +443,7 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.loadTxs();
return;
}
$scope.error = undefined;
var p = w.txProposals.getTxProposal(ntxid);
if (p.builder.isFullySigned()) {