Advanced send options
This commit is contained in:
parent
77abe774ac
commit
779db5a06c
6 changed files with 73 additions and 33 deletions
|
|
@ -279,6 +279,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
$log.debug('Wallet Status:', walletStatus);
|
||||
self.setPendingTxps(walletStatus.pendingTxps);
|
||||
self.setFees();
|
||||
self.setSpendUnconfirmed();
|
||||
|
||||
// Status Shortcuts
|
||||
self.walletName = walletStatus.wallet.name;
|
||||
|
|
@ -306,6 +307,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
};
|
||||
|
||||
self.setSpendUnconfirmed = function() {
|
||||
self.spendUnconfirmed = configService.getSync().wallet.spendUnconfirmed;
|
||||
};
|
||||
|
||||
self.setCurrentFeeLevel = function(level) {
|
||||
self.currentFeeLevel = level || configService.getSync().wallet.settings.feeLevel || 'priority';
|
||||
};
|
||||
|
|
@ -855,6 +860,10 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/SpendUnconfirmedUpdated', function(event) {
|
||||
self.setSpendUnconfirmed();
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/FeeLevelUpdated', function(event, level) {
|
||||
self.setCurrentFeeLevel(level);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -9,10 +9,25 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
name: config.wallet.settings.alternativeName,
|
||||
isoCode: config.wallet.settings.alternativeIsoCode
|
||||
};
|
||||
$scope.spendUnconfirmed = config.wallet.spendUnconfirmed;
|
||||
var fc = profileService.focusedClient;
|
||||
if (fc)
|
||||
$scope.encrypt = fc.hasPrivKeyEncrypted();
|
||||
|
||||
var unwatchSpendUnconfirmed = $scope.$watch('spendUnconfirmed', function(newVal, oldVal) {
|
||||
if (newVal == oldVal) return;
|
||||
var opts = {
|
||||
wallet: {
|
||||
spendUnconfirmed: newVal
|
||||
}
|
||||
};
|
||||
$rootScope.$emit('Local/SpendUnconfirmedUpdated');
|
||||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) $log.debug(err);
|
||||
});
|
||||
});
|
||||
|
||||
var unwatch = $scope.$watch('encrypt', function(val) {
|
||||
var fc = profileService.focusedClient;
|
||||
if (!fc) return;
|
||||
|
|
@ -49,5 +64,6 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
|
||||
$scope.$on('$destroy', function() {
|
||||
unwatch();
|
||||
unwatchSpendUnconfirmed();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
var self = this;
|
||||
$rootScope.hideMenuBar = false;
|
||||
$rootScope.wpInputFocused = false;
|
||||
$scope.currentSpendUnconfirmed = configService.getSync().wallet.spendUnconfirmed;
|
||||
|
||||
// INIT
|
||||
var config = configService.getSync().wallet.settings;
|
||||
|
|
@ -538,6 +539,15 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
// Send
|
||||
|
||||
var unwatchSpendUnconfirmed = $scope.$watch('currentSpendUnconfirmed', function(newVal, oldVal) {
|
||||
if (newVal == oldVal) return;
|
||||
$scope.currentSpendUnconfirmed = newVal;
|
||||
});
|
||||
|
||||
$scope.$on('$destroy', function() {
|
||||
unwatchSpendUnconfirmed();
|
||||
});
|
||||
|
||||
this.canShowAlternative = function() {
|
||||
return $scope.showAlternative;
|
||||
};
|
||||
|
|
@ -736,7 +746,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
address = form.address.$modelValue;
|
||||
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
|
||||
|
||||
feeService.getCurrentFeeValue(function(err, feePerKb) {
|
||||
feeService.getCurrentFeeValue(self.currentSendFeeLevel, function(err, feePerKb) {
|
||||
if (err) $log.debug(err);
|
||||
fc.sendTxProposal({
|
||||
toAddress: address,
|
||||
|
|
@ -744,6 +754,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
message: comment,
|
||||
payProUrl: paypro ? paypro.url : null,
|
||||
feePerKb: feePerKb,
|
||||
excludeUnconfirmedUtxos: $scope.currentSpendUnconfirmed ? false : true
|
||||
}, function(err, txp) {
|
||||
if (err) {
|
||||
self.setOngoingProcess();
|
||||
|
|
@ -848,6 +859,9 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
|
||||
this.lockAddress = false;
|
||||
this.lockAmount = false;
|
||||
this.currentSendFeeLevel = null;
|
||||
this.hideAdvSend = true;
|
||||
$scope.currentSpendUnconfirmed = configService.getSync().wallet.spendUnconfirmed;
|
||||
|
||||
this._amount = this._address = null;
|
||||
|
||||
|
|
@ -985,36 +999,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
}
|
||||
};
|
||||
|
||||
// Advanced SEND: set temporary fee policy for each transaction
|
||||
this.openAdvancedSendModal = function(feeLevels, currentFeeLevel) {
|
||||
var fc = profileService.focusedClient;
|
||||
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
$scope.feeLevels = feeLevels;
|
||||
$scope.currentFeeLevel = currentFeeLevel
|
||||
$scope.network = fc.credentials.network;
|
||||
$scope.color = fc.backgroundColor;
|
||||
$scope.save = function(level) {
|
||||
$scope.currentFeeLevel = level;
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
};
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl: 'views/modals/advancedSend.html',
|
||||
windowClass: 'full animated slideInUp',
|
||||
controller: ModalInstanceCtrl
|
||||
});
|
||||
|
||||
modalInstance.result.finally(function() {
|
||||
var m = angular.element(document.getElementsByClassName('reveal-modal'));
|
||||
m.addClass('slideOutDown');
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
// History
|
||||
|
||||
function strip(number) {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,10 @@ angular.module('copayApp.services').factory('feeService', function($log, profile
|
|||
economy: gettextCatalog.getString('Economy')
|
||||
};
|
||||
|
||||
root.getCurrentFeeValue = function(cb) {
|
||||
root.getCurrentFeeValue = function(currentSendFeeLevel, cb) {
|
||||
var fc = profileService.focusedClient;
|
||||
var config = configService.getSync().wallet.settings;
|
||||
var feeLevel = config.feeLevel || 'normal';
|
||||
var feeLevel = currentSendFeeLevel || config.feeLevel || 'normal';
|
||||
// static fee
|
||||
var fee = 10000;
|
||||
fc.getFeeLevels(fc.credentials.network, function(err, levels) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue