Merge pull request #3060 from cmgustavo/feat/adv-send
Advanced send options
This commit is contained in:
commit
8189d571bf
14 changed files with 122 additions and 59 deletions
|
|
@ -17,7 +17,7 @@
|
|||
"ng-lodash": "~0.2.0",
|
||||
"angular-moment": "~0.10.1",
|
||||
"moment": "~2.10.3",
|
||||
"angular-bitcore-wallet-client": "^0.0.28",
|
||||
"angular-bitcore-wallet-client": "^0.1.1",
|
||||
"angular-ui-router": "~0.2.13",
|
||||
"qrcode-decoder-js": "*",
|
||||
"fastclick": "*",
|
||||
|
|
|
|||
|
|
@ -468,6 +468,10 @@ msgstr ""
|
|||
msgid "Fee Policy"
|
||||
msgstr ""
|
||||
|
||||
#: public/views/walletHome.html
|
||||
msgid "Fee policy for this transaction"
|
||||
msgstr ""
|
||||
|
||||
#. Get information of payment if using Payment Protocol
|
||||
#: src/js/controllers/walletHome.js
|
||||
msgid "Fetching Payment Information"
|
||||
|
|
@ -524,7 +528,8 @@ msgstr ""
|
|||
#: public/views/backup.html
|
||||
#: public/views/create.html
|
||||
#: public/views/join.html
|
||||
msgid "Hide Advanced options"
|
||||
#: public/views/walletHome.html
|
||||
msgid "Hide advanced options"
|
||||
msgstr ""
|
||||
|
||||
#: src/js/controllers/index.js
|
||||
|
|
@ -689,6 +694,7 @@ msgstr ""
|
|||
|
||||
#: public/views/walletHome.html
|
||||
#: public/views/includes/output.html
|
||||
#: public/views/modals/tx-details.html
|
||||
msgid "Note"
|
||||
msgstr ""
|
||||
|
||||
|
|
@ -1012,7 +1018,8 @@ msgstr ""
|
|||
#: public/views/backup.html
|
||||
#: public/views/create.html
|
||||
#: public/views/join.html
|
||||
msgid "Show Advanced options"
|
||||
#: public/views/walletHome.html
|
||||
msgid "Show advanced options"
|
||||
msgstr ""
|
||||
|
||||
#: src/js/controllers/walletHome.js
|
||||
|
|
@ -1148,6 +1155,15 @@ msgstr ""
|
|||
msgid "Updating Wallet..."
|
||||
msgstr ""
|
||||
|
||||
#: public/views/preferences.html
|
||||
#: public/views/walletHome.html
|
||||
msgid "Use Unconfirmed Funds"
|
||||
msgstr ""
|
||||
|
||||
#: public/views/modals/txp-details.html
|
||||
msgid "Uses unconfirmed funds"
|
||||
msgstr ""
|
||||
|
||||
#: public/views/preferencesAbout.html
|
||||
msgid "Version"
|
||||
msgstr ""
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@
|
|||
<div class="m10t oh" ng-init="hideAdv=true">
|
||||
<a class="button outline light-gray expand tiny" ng-click="hideAdv=!hideAdv">
|
||||
<i class="fi-widget m3r"></i>
|
||||
<span translate ng-hide="!hideAdv">Show Advanced options</span>
|
||||
<span translate ng-hide="hideAdv">Hide Advanced options</span>
|
||||
<span translate ng-hide="!hideAdv">Show advanced options</span>
|
||||
<span translate ng-hide="hideAdv">Hide advanced options</span>
|
||||
<i ng-if="hideAdv" class="icon-arrow-down4"></i>
|
||||
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -81,8 +81,8 @@
|
|||
<div class="m10t oh" ng-init="hideAdv=true">
|
||||
<a class="button outline light-gray expand tiny" ng-click="hideAdv=!hideAdv">
|
||||
<i class="fi-widget m3r"></i>
|
||||
<span translate ng-hide="!hideAdv">Show Advanced options</span>
|
||||
<span translate ng-hide="hideAdv">Hide Advanced options</span>
|
||||
<span translate ng-hide="!hideAdv">Show advanced options</span>
|
||||
<span translate ng-hide="hideAdv">Hide advanced options</span>
|
||||
<i ng-if="hideAdv" class="icon-arrow-down4"></i>
|
||||
<i ng-if="!hideAdv" class="icon-arrow-up4"></i>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="ng-animate-disabled row collapse line-b" ng-class="text-gray">
|
||||
<div class="ng-animate-disabled row collapse">
|
||||
<li ng-if="output.isSummary" class="line-b p10 oh" ng-click="toggleOutputDetails(output)">
|
||||
<span class="text-gray" translate>Recipients</span>:
|
||||
<span class="right enable_text_select">{{output.recipientCount}}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@
|
|||
|
||||
<a class="button outline light-gray tiny expand" ng-click="join.hideAdv=!join.hideAdv">
|
||||
<i class="fi-widget m3r"></i>
|
||||
<span translate ng-show="!join.hideAdv">Show Advanced options</span>
|
||||
<span translate ng-show="join.hideAdv">Hide Advanced options</span>
|
||||
<span translate ng-show="!join.hideAdv">Show advanced options</span>
|
||||
<span translate ng-show="join.hideAdv">Hide advanced options</span>
|
||||
<i ng-show="!join.hideAdv" class="icon-arrow-down4"></i>
|
||||
<i ng-show="join.hideAdv" class="icon-arrow-up4"></i>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@
|
|||
<span class="text-gray" translate>Fee</span>:
|
||||
<span class="right">{{feeStr}}</span>
|
||||
</li>
|
||||
<li class="line-b p10">
|
||||
<span class="text-gray" translate>Uses unconfirmed funds</span>:
|
||||
<span class="right">{{(tx.excludeUnconfirmedUtxos ? 'No' : 'Yes')|translate}}</span>
|
||||
</li>
|
||||
<li class="line-b p10">
|
||||
<span class="text-gray" translate>Time</span>:
|
||||
<span class="right">
|
||||
|
|
|
|||
|
|
@ -77,13 +77,18 @@
|
|||
{{preferences.selectedAlternative.name}}
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p20" ng-click="$root.go('preferencesFee')">
|
||||
<li class="line-b p20" ng-click="$root.go('preferencesFee')"
|
||||
ng-show="(index.network == 'livenet' ? index.feeLevels.livenet : index.feeLevels.testnet)">
|
||||
<span translate>Bitcoin Network Fee Policy</span>
|
||||
<span class="right text-gray">
|
||||
<i class="icon-arrow-right3 size-24 right"></i>
|
||||
<span class="text-capitalize">{{index.feeOpts[index.currentFeeLevel]|translate}}</span>
|
||||
{{index.feeOpts[index.currentFeeLevel]|translate}}
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p20">
|
||||
<span translate>Use Unconfirmed Funds</span>
|
||||
<switch id="spend-unconfirmed" name="spendUnconfirmed" ng-model="spendUnconfirmed" class="green right"></switch>
|
||||
</li>
|
||||
<li class="line-b p20" ng-click="$root.go('preferencesBwsUrl')">
|
||||
<span>Bitcore Wallet Service</span>
|
||||
<span class="text-gray db">
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
<ul class="no-bullet m0 size-14">
|
||||
<li ng-repeat="fee in (index.network == 'livenet' ? index.feeLevels.livenet : index.feeLevels.testnet)"
|
||||
ng-click="prefFee.save(fee.level)" class="line-b p20">
|
||||
<span class="text-capitalize">{{index.feeOpts[fee.level]|translate}}</span>
|
||||
{{index.feeOpts[fee.level]|translate}}
|
||||
<i class="fi-check size-16 right" ng-show="index.currentFeeLevel == fee.level"></i>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
|
|||
|
|
@ -418,6 +418,35 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="m20b" ng-init="home.hideAdvSend=true">
|
||||
<a class="button outline light-gray expand tiny m0" ng-click="home.hideAdvSend=!home.hideAdvSend">
|
||||
<i class="fi-widget m3r"></i>
|
||||
<span translate ng-hide="!home.hideAdvSend">Show advanced options</span>
|
||||
<span translate ng-hide="home.hideAdvSend">Hide advanced options</span>
|
||||
<i ng-if="home.hideAdvSend" class="icon-arrow-down4"></i>
|
||||
<i ng-if="!home.hideAdvSend" class="icon-arrow-up4"></i>
|
||||
</a>
|
||||
<div class="m10t" ng-hide="home.hideAdvSend">
|
||||
<div ng-show="(index.network == 'livenet' ? index.feeLevels.livenet : index.feeLevels.testnet)">
|
||||
<h4 class="title m0" translate>Fee policy for this transaction</h4>
|
||||
<ul class="no-bullet m0 size-14">
|
||||
<li ng-repeat="fee in (index.network == 'livenet' ? index.feeLevels.livenet : index.feeLevels.testnet)"
|
||||
ng-click="home.currentSendFeeLevel = fee.level" class="line-b p20">
|
||||
{{index.feeOpts[fee.level]|translate}}
|
||||
<i class="fi-check size-16 right"
|
||||
ng-show="(home.currentSendFeeLevel || index.currentFeeLevel) == fee.level"></i>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<h4 class="title m0"> </h4>
|
||||
<div class="p20 line-b">
|
||||
<span class="size-14" translate>Use Unconfirmed Funds</span>
|
||||
<switch id="spend-unconfirmed" name="currentSpendUnconfirmed" ng-model="currentSpendUnconfirmed" class="green right"></switch>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row" ng-show="!home.onGoingProcess">
|
||||
<div class="large-6 medium-6 small-6 columns" ng-show="!home.blockUx && (home._paypro || home.lockAddress || home.lockAmount)">
|
||||
<a ng-click="home.resetForm(sendForm)" class="button expand outline dark-gray round" translate>Cancel</a>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService) {
|
||||
angular.module('copayApp.controllers').controller('indexController', function($rootScope, $scope, $log, $filter, $timeout, lodash, go, profileService, configService, isCordova, rateService, storageService, addressService, gettextCatalog, gettext, amMoment, nodeWebkit, addonManager, feeService, isChromeApp) {
|
||||
var self = this;
|
||||
self.isCordova = isCordova;
|
||||
self.onGoingProcess = {};
|
||||
|
|
@ -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';
|
||||
};
|
||||
|
|
@ -395,9 +400,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
self.handleError = function(err) {
|
||||
$log.warn('Client ERROR:', err);
|
||||
if (err.code === 'NOTAUTHORIZED') {
|
||||
if (err.code === 'NOT_AUTHORIZED') {
|
||||
$scope.$emit('Local/NotAuthorized');
|
||||
} else if (err.code === 'NOTFOUND') {
|
||||
} else if (err.code === 'NOT_FOUND') {
|
||||
$scope.$emit('Local/BWSNotFound');
|
||||
} else {
|
||||
$scope.$emit('Local/ClientError', (err.error ? err.error : err));
|
||||
|
|
@ -747,7 +752,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
'Wallet Server Error', ['OK']
|
||||
);
|
||||
} else {
|
||||
alert(err);
|
||||
if (!isChromeApp) {
|
||||
alert(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -759,7 +766,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
'Device Error', ['OK']
|
||||
);
|
||||
} else {
|
||||
alert(err);
|
||||
if (!isChromeApp) {
|
||||
alert(err);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -855,6 +864,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);
|
||||
});
|
||||
|
|
@ -951,12 +964,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
});
|
||||
|
||||
$rootScope.$on('Local/ClientError', function(event, err) {
|
||||
if (err.code && err.code === 'NOTAUTHORIZED') {
|
||||
if (err.code && err.code === 'NOT_AUTHORIZED') {
|
||||
// Show not error, just redirect to home (where the recreate option is shown)
|
||||
go.walletHome();
|
||||
} else if (err && err.cors == 'rejected') {
|
||||
$log.debug('CORS error:', err);
|
||||
} else if (err.code === 'ETIMEDOUT' || err.code === 'CONNERROR') {
|
||||
} else if (err.code === 'ETIMEDOUT' || err.code === 'CONNECTION_ERROR') {
|
||||
$log.debug('Time out:', err);
|
||||
} else {
|
||||
var msg = 'Error at Wallet Service: ';
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services').factory('feeService', function($log, profileService, configService, gettextCatalog) {
|
||||
angular.module('copayApp.services').factory('feeService', function($log, profileService, configService, gettextCatalog, lodash) {
|
||||
var root = {};
|
||||
|
||||
// Constant fee options to translate
|
||||
|
|
@ -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) {
|
||||
|
|
@ -21,11 +21,7 @@ angular.module('copayApp.services').factory('feeService', function($log, profile
|
|||
return cb({message: 'Could not get dynamic fee. Using static 10000sat'}, fee);
|
||||
}
|
||||
else {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
if (levels[i].level == feeLevel) {
|
||||
fee = levels[i].feePerKB;
|
||||
}
|
||||
}
|
||||
fee = lodash.find(levels, { level: feeLevel }).feePerKB;
|
||||
$log.debug('Dynamic fee for ' + feeLevel + ': ' + fee);
|
||||
return cb(null, fee);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue