+
diff --git a/js/controllers/send.js b/js/controllers/send.js
index 49a5506c8..349d60d82 100644
--- a/js/controllers/send.js
+++ b/js/controllers/send.js
@@ -33,7 +33,7 @@ angular.module('copayApp.controllers').controller('SendController',
$scope.submitForm = function(form) {
if (form.$invalid) {
$rootScope.$flashMessage = {
- message: 'You can not send a proposal transaction. Please, try again',
+ message: 'Unable to send a transaction proposal. Please, try again',
type: 'error'
};
return;
@@ -254,4 +254,9 @@ angular.module('copayApp.controllers').controller('SendController',
});
};
+ $scope.topAmount = function() {
+ var maxSat = ($rootScope.availableBalance * config.unitToSatoshi).toFixed(0)
+ - bitcore.TransactionBuilder.FEE_PER_1000B_SAT;
+ $scope.amount = maxSat / config.unitToSatoshi;
+ };
});
diff --git a/test/unit/controllers/controllersSpec.js b/test/unit/controllers/controllersSpec.js
index c183ebcf9..d56804be9 100644
--- a/test/unit/controllers/controllersSpec.js
+++ b/test/unit/controllers/controllersSpec.js
@@ -128,10 +128,12 @@ describe("Unit: Controllers", function() {
);
scope.model = {
newaddress: null,
- newlabel: null
+ newlabel: null,
};
$compile(element)(scope);
- $controller('SendController', {$scope: scope});
+ $controller('SendController', {$scope: scope,
+ $modal: {},
+ });
scope.$digest();
form = scope.form;
}));
@@ -244,6 +246,7 @@ describe("Unit: Controllers", function() {
var sendCtrl;
beforeEach(inject(function($controller, $rootScope) {
scope = $rootScope.$new();
+ $rootScope.availableBalance = 123456;
sendCtrl = $controller('SendController', {
$scope: scope,
$modal: {},
@@ -253,6 +256,10 @@ describe("Unit: Controllers", function() {
it('should have a SendController', function() {
expect(scope.isMobile).not.to.equal(null);
});
+ it('should autotop balance correctly', function() {
+ scope.topAmount();
+ expect(scope.amount).to.equal(123356);
+ });
});
});