mirror of https://github.com/BTCPrivate/copay.git
fix negative amount in send all function
This commit is contained in:
parent
bb73a058a0
commit
6cb373f961
|
@ -147,7 +147,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.addAddressbookEntry = false;
|
||||
$scope.selectedAddressbook = {};
|
||||
$scope.newAddress = address;
|
||||
$scope.addressbook = { 'address' : ($scope.newAddress || '') , 'label' : ''};
|
||||
$scope.addressbook = {
|
||||
'address': ($scope.newAddress || ''),
|
||||
'label': ''
|
||||
};
|
||||
$scope.color = fc.backgroundColor;
|
||||
|
||||
$scope.beforeQrCodeScann = function() {
|
||||
|
@ -185,7 +188,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
$scope.toggleAddAddressbookEntry = function() {
|
||||
$scope.error = null;
|
||||
$scope.addressbook = { 'address' : ($scope.newAddress || '') , 'label' : ''};
|
||||
$scope.addressbook = {
|
||||
'address': ($scope.newAddress || ''),
|
||||
'label': ''
|
||||
};
|
||||
$scope.addAddressbookEntry = !$scope.addAddressbookEntry;
|
||||
};
|
||||
|
||||
|
@ -1159,6 +1165,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
this.setFromUri = function(uri) {
|
||||
var self = this;
|
||||
|
||||
function sanitizeUri(uri) {
|
||||
// Fixes when a region uses comma to separate decimals
|
||||
var regex = /[\?\&]amount=(\d+([\,\.]\d+)?)/i;
|
||||
|
@ -1302,40 +1309,19 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
this.setForm(null, amount, null, feeRate);
|
||||
};
|
||||
|
||||
// TODO: showPopup alike
|
||||
this.confirmDialog = function(msg, cb) {
|
||||
if (isCordova) {
|
||||
navigator.notification.confirm(
|
||||
msg,
|
||||
function(buttonIndex) {
|
||||
if (buttonIndex == 1) {
|
||||
$timeout(function() {
|
||||
return cb(true);
|
||||
}, 1);
|
||||
} else {
|
||||
return cb(false);
|
||||
}
|
||||
},
|
||||
confirm_msg, [accept_msg, cancel_msg]
|
||||
);
|
||||
} else if (isChromeApp) {
|
||||
// No feedback, alert/confirm not supported.
|
||||
return cb(true);
|
||||
} else {
|
||||
return cb(confirm(msg));
|
||||
}
|
||||
};
|
||||
|
||||
this.sendAll = function(amount, feeStr, feeRate) {
|
||||
var self = this;
|
||||
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
|
||||
fee: feeStr
|
||||
});
|
||||
|
||||
this.confirmDialog(msg, function(confirmed) {
|
||||
if (amount - parseInt(feeStr) > 0) {
|
||||
confirmDialog.show(msg, function(confirmed) {
|
||||
if (confirmed)
|
||||
self._doSendAll(amount, feeRate);
|
||||
});
|
||||
} else
|
||||
$rootScope.$emit('Local/ShowAlert', gettextCatalog.getString('Not enough funds for network fees'));
|
||||
};
|
||||
|
||||
/* Start setup */
|
||||
|
@ -1345,5 +1331,4 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
this.setAddress();
|
||||
this.setSendFormInputs();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue