mirror of https://github.com/BTCPrivate/copay.git
Set min max allowed valued
This commit is contained in:
parent
f413857a97
commit
3cac9a30bc
|
@ -2,7 +2,9 @@
|
|||
|
||||
angular.module('copayApp.controllers').controller('feeLevelsController', function($scope, $timeout, $log, lodash, gettextCatalog, configService, feeService, ongoingProcess, popupService) {
|
||||
|
||||
var MAX_RECOMMENDED_FEE = 1000;
|
||||
var FEE_MULTIPLIER = 10;
|
||||
var FEE_MIN = 0;
|
||||
var FEE_MAX = 1000000;
|
||||
|
||||
var showErrorAndClose = function(title, msg) {
|
||||
title = title || gettextCatalog.getString('Error');
|
||||
|
@ -21,7 +23,10 @@ angular.module('copayApp.controllers').controller('feeLevelsController', functio
|
|||
};
|
||||
|
||||
var getMaxRecommended = function() {
|
||||
return MAX_RECOMMENDED_FEE;
|
||||
var value = lodash.find($scope.feeLevels[$scope.network], {
|
||||
level: 'urgent'
|
||||
});
|
||||
return parseInt((value.feePerKB / 1000).toFixed());
|
||||
};
|
||||
|
||||
$scope.ok = function() {
|
||||
|
@ -30,18 +35,22 @@ angular.module('copayApp.controllers').controller('feeLevelsController', functio
|
|||
};
|
||||
|
||||
$scope.setFeesRecommended = function() {
|
||||
$scope.maxFeeRecommended = getMaxRecommended();
|
||||
$scope.minFeeAllowed = FEE_MIN;
|
||||
$scope.maxFeeAllowed = FEE_MAX;
|
||||
$scope.maxFeeRecommended = getMaxRecommended() * FEE_MULTIPLIER;
|
||||
$scope.minFeeRecommended = getMinRecommended();
|
||||
};
|
||||
|
||||
$scope.checkFees = function(feePerSatByte) {
|
||||
if (Number(feePerSatByte) == 0) $scope.showError = true;
|
||||
var fee = Number(feePerSatByte);
|
||||
|
||||
if (fee <= $scope.minFeeAllowed) $scope.showError = true;
|
||||
else $scope.showError = false;
|
||||
|
||||
if (Number(feePerSatByte) < $scope.minFeeRecommended) $scope.showMinWarning = true;
|
||||
if (fee > $scope.minFeeAllowed && fee < $scope.minFeeRecommended) $scope.showMinWarning = true;
|
||||
else $scope.showMinWarning = false;
|
||||
|
||||
if (Number(feePerSatByte) > $scope.maxFeeRecommended) $scope.showMaxWarning = true;
|
||||
if (fee < $scope.maxFeeAllowed && fee > $scope.maxFeeRecommended) $scope.showMaxWarning = true;
|
||||
else $scope.showMaxWarning = false;
|
||||
};
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
<input
|
||||
type="number"
|
||||
placeholder="{{'Enter custom fee'|translate}}"
|
||||
ng-min="0"
|
||||
ng-max="maxFeeRecommended + 10000"
|
||||
ng-min="minFeeAllowed"
|
||||
ng-max="maxFeeAllowed"
|
||||
min="minFeeRecommended"
|
||||
max="maxFeeRecommended"
|
||||
ng-change="checkFees(customSatPerByte.value)"
|
||||
|
@ -52,7 +52,7 @@
|
|||
<div class="error-fee" ng-if="showError">
|
||||
<i class="icon ion-close-circled"></i>
|
||||
<span translate>
|
||||
Zero value for fee are not allowed.
|
||||
Transactions without fee are not supported.
|
||||
</span>
|
||||
</div>
|
||||
<div class="warning-fee" ng-if="showMinWarning || showMaxWarning">
|
||||
|
@ -61,7 +61,7 @@
|
|||
Your fee is lower than recommended.
|
||||
</span>
|
||||
<span ng-if="showMaxWarning" translate>
|
||||
You should not set a fee higher than 1000 satoshis/byte.
|
||||
You should not set a fee higher than {{maxFeeRecommended}} satoshis/byte.
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue