Fixed 'Use all funds' link for amounts below fee
This commit is contained in:
parent
6a1cd3b688
commit
9ee04fe45f
2 changed files with 9 additions and 1 deletions
|
|
@ -394,7 +394,8 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.getAvailableAmount = function() {
|
$scope.getAvailableAmount = function() {
|
||||||
return ((($rootScope.availableBalance * config.unitToSatoshi).toFixed(0) - bitcore.TransactionBuilder.FEE_PER_1000B_SAT) / config.unitToSatoshi);
|
var amount = ((($rootScope.availableBalance * config.unitToSatoshi).toFixed(0) - bitcore.TransactionBuilder.FEE_PER_1000B_SAT) / config.unitToSatoshi);
|
||||||
|
return amount > 0 ? amount : 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.topAmount = function(form) {
|
$scope.topAmount = function(form) {
|
||||||
|
|
|
||||||
|
|
@ -411,6 +411,13 @@ describe("Unit: Controllers", function() {
|
||||||
var amount = scope.getAvailableAmount();
|
var amount = scope.getAvailableAmount();
|
||||||
expect(amount).to.equal(123356);
|
expect(amount).to.equal(123356);
|
||||||
});
|
});
|
||||||
|
it('should return 0 if available amount below minimum fee', function() {
|
||||||
|
inject(function($compile, $rootScope, $controller) {
|
||||||
|
$rootScope.availableBalance = 1;
|
||||||
|
});
|
||||||
|
var amount = scope.getAvailableAmount();
|
||||||
|
expect(amount).to.equal(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Import Controller', function() {
|
describe('Import Controller', function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue