Merge pull request #2901 from matiu/feat/send-all
Feature: send all and fee customization.
This commit is contained in:
commit
99e2953cc5
11 changed files with 149 additions and 16 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.24",
|
||||
"angular-bitcore-wallet-client": "^0.0.25",
|
||||
"angular-ui-router": "~0.2.13",
|
||||
"qrcode-decoder-js": "*",
|
||||
"fastclick": "*",
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
<span class="label gray radius">{{alternativeAmountStr}}</span>
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p10">
|
||||
<span class="text-gray" translate>Fee</span>:
|
||||
<span class="right">{{feeStr}}</span>
|
||||
</li>
|
||||
<li class="line-b p10">
|
||||
<span class="text-gray" translate>Time</span>:
|
||||
<span class="right">
|
||||
|
|
|
|||
|
|
@ -77,6 +77,14 @@
|
|||
{{preferences.selectedAlternative.name}}
|
||||
</span>
|
||||
</li>
|
||||
<li class="line-b p20" ng-click="$root.go('preferencesFee')">
|
||||
<span translate>Bitcoin Network Fee Policy</span>
|
||||
<span class="right text-gray">
|
||||
<i class="icon-arrow-right3 size-24 right"></i>
|
||||
{{preferences.feeName}}
|
||||
</span>
|
||||
</li>
|
||||
|
||||
|
||||
<li class="line-b p20" ng-click="$root.go('preferencesBwsUrl')">
|
||||
<span>Bitcore Wallet Service</span>
|
||||
|
|
|
|||
14
public/views/preferencesFee.html
Normal file
14
public/views/preferencesFee.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
<div
|
||||
class="topbar-container"
|
||||
ng-include="'views/includes/topbar.html'"
|
||||
ng-init="titleSection='Fee Policy'; goBackToState = 'preferences'; noColor = true">
|
||||
</div>
|
||||
|
||||
|
||||
<div class="content preferences" ng-controller="preferencesFeeController as prefFee">
|
||||
<div ng-repeat="fee in prefFee.feeOpts" ng-click="prefFee.save(fee)" class="line-b p20 size-14">
|
||||
<span>{{fee.name}} ({{fee.value}} bits per kB)</span>
|
||||
<i class="fi-check size-16 right" ng-show="prefFee.feeName == fee.name"></i>
|
||||
</div>
|
||||
</div>
|
||||
<div class="extra-margin-bottom"></div>
|
||||
|
|
@ -278,8 +278,14 @@
|
|||
<div>
|
||||
<h4 class="title m0">
|
||||
|
||||
<a class="right lh"
|
||||
ng-if="index.feeToSendMaxStr && index.availableBalance > 0 && !home.blockUx && !home.lockAmount"
|
||||
ng-click="home.sendAll(index.availableMaxBalance, index.feeToSendMaxStr)"
|
||||
translate> Send All
|
||||
</a>
|
||||
|
||||
<div ng-show="!index.lockedBalance && index.availableBalanceStr">
|
||||
<div class="size-12">
|
||||
<div class="size-10">
|
||||
<span class="db text-bold">
|
||||
<span translate>Available Balance</span>:
|
||||
{{index.availableBalanceStr }}
|
||||
|
|
@ -288,9 +294,9 @@
|
|||
</div>
|
||||
<div ng-show="index.lockedBalance">
|
||||
<div class="left">
|
||||
<i class="fi-info size-36 m10r lh"></i>
|
||||
<i class="fi-info size-24 m10r"></i>
|
||||
</div>
|
||||
<div class="size-12">
|
||||
<div class="size-10">
|
||||
<span class="db text-bold">
|
||||
<span translate>Available Balance</span>:
|
||||
{{index.availableBalanceStr }}
|
||||
|
|
@ -397,10 +403,10 @@
|
|||
</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)">
|
||||
<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>
|
||||
</div>
|
||||
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress)}">
|
||||
<div class="columns" ng-class="{'small-6 medium-6 large-6':(home._paypro || home.lockAddress || home.lockAmount)}">
|
||||
<button type="submit" class="button black round expand" ng-disabled="sendForm.$invalid || home.blockUx || index.isOffline"
|
||||
ng-style="{'background-color':index.backgroundColor}" translate>
|
||||
Send
|
||||
|
|
|
|||
|
|
@ -49,6 +49,13 @@ h4.title {
|
|||
font-size: 0.7rem;
|
||||
}
|
||||
|
||||
h4.title a {
|
||||
text-transform: none;
|
||||
font-weight: 400;
|
||||
padding: 7px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
body, html{
|
||||
height:100%;
|
||||
width:100%;
|
||||
|
|
|
|||
|
|
@ -57,9 +57,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
isoCode: 'pt',
|
||||
}];
|
||||
|
||||
self.setOngoingProcess = function(processName, isOn, quiet) {
|
||||
self.setOngoingProcess = function(processName, isOn) {
|
||||
$log.debug('onGoingProcess', processName, isOn);
|
||||
if (quiet) return;
|
||||
self[processName] = isOn;
|
||||
self.onGoingProcess[processName] = isOn;
|
||||
|
||||
|
|
@ -179,13 +178,14 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
|
||||
self.updateAll = function(opts, initStatusHash, tries) {
|
||||
tries = tries || 0;
|
||||
var quiet = (opts && opts.quiet) ? true : null;
|
||||
if (opts && opts.untilItChanges && lodash.isUndefined(initStatusHash)) {
|
||||
opts = opts || {};
|
||||
|
||||
if (opts.untilItChanges && lodash.isUndefined(initStatusHash)) {
|
||||
initStatusHash = _walletStatusHash();
|
||||
$log.debug('Updating status until it changes. initStatusHash:' + initStatusHash)
|
||||
}
|
||||
var get = function(cb) {
|
||||
if (opts && opts.walletStatus)
|
||||
if (opts.walletStatus)
|
||||
return cb(null, opts.walletStatus);
|
||||
else {
|
||||
self.updateError = false;
|
||||
|
|
@ -193,7 +193,8 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
if (err) {
|
||||
self.updateError = true;
|
||||
} else {
|
||||
self.setOngoingProcess('scanning', ret.wallet.scanning, quiet);
|
||||
if (!opts.quiet)
|
||||
self.setOngoingProcess('scanning', ret.wallet.scanning);
|
||||
}
|
||||
return cb(err, ret);
|
||||
});
|
||||
|
|
@ -204,18 +205,23 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
if (!fc) return;
|
||||
|
||||
$timeout(function() {
|
||||
self.setOngoingProcess('updatingStatus', true, quiet);
|
||||
|
||||
if (!opts.quiet)
|
||||
self.setOngoingProcess('updatingStatus', true);
|
||||
|
||||
$log.debug('Updating Status:', fc, tries);
|
||||
get(function(err, walletStatus) {
|
||||
var currentStatusHash = _walletStatusHash(walletStatus);
|
||||
$log.debug('Status update. hash:' + currentStatusHash + ' Try:'+ tries);
|
||||
if (!err && (opts && opts.untilItChanges) && initStatusHash == currentStatusHash && tries < 7) {
|
||||
if (!err && opts.untilItChanges && initStatusHash == currentStatusHash && tries < 7) {
|
||||
return $timeout(function() {
|
||||
$log.debug('Retrying update... Try:' + tries)
|
||||
return self.updateAll({walletStatus: null, untilItChanges: true}, initStatusHash, ++tries);
|
||||
}, 1400 * tries);
|
||||
}
|
||||
self.setOngoingProcess('updatingStatus', false, quiet);
|
||||
if (!opts.quiet)
|
||||
self.setOngoingProcess('updatingStatus', false);
|
||||
|
||||
if (err) {
|
||||
self.handleError(err);
|
||||
return;
|
||||
|
|
@ -343,6 +349,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
lodash.each(txps, function(tx) {
|
||||
var amount = tx.amount * self.satToUnit;
|
||||
tx.amountStr = profileService.formatAmount(tx.amount) + ' ' + config.unitName;
|
||||
tx.feeStr = profileService.formatAmount(tx.fee) + ' ' + config.unitName;
|
||||
tx.alternativeAmount = rateService.toFiat(tx.amount, config.alternativeIsoCode) ? rateService.toFiat(tx.amount, config.alternativeIsoCode).toFixed(2) : 'N/A';
|
||||
tx.alternativeAmountStr = tx.alternativeAmount + " " + config.alternativeIsoCode;
|
||||
tx.alternativeIsoCode = config.alternativeIsoCode;
|
||||
|
|
@ -436,6 +443,16 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
self.lockedBalanceBTC = strip(self.lockedBalanceSat / COIN);
|
||||
self.availableBalanceBTC = strip(self.availableBalanceBTC / COIN);
|
||||
|
||||
// KB to send max
|
||||
self.feePerKbSat = config.feeValue || 10000;
|
||||
if (balance.totalKbToSendMax) {
|
||||
var feeToSendMaxSat = balance.totalKbToSendMax * self.feePerKbSat;
|
||||
|
||||
self.availableMaxBalance = strip((self.availableBalanceSat - feeToSendMaxSat) * self.satToUnit);
|
||||
self.feeToSendMaxStr = profileService.formatAmount(feeToSendMaxSat) + ' ' + self.unitName;
|
||||
} else {
|
||||
self.feeToSendMaxStr = null;
|
||||
}
|
||||
|
||||
//STR
|
||||
self.totalBalanceStr = profileService.formatAmount(self.totalBalanceSat) + ' ' + self.unitName;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ angular.module('copayApp.controllers').controller('preferencesController',
|
|||
function($scope, $rootScope, $filter, $timeout, $modal, $log, lodash, configService, profileService) {
|
||||
var config = configService.getSync();
|
||||
this.unitName = config.wallet.settings.unitName;
|
||||
this.feeName = config.wallet.settings.feeName || 'Priority';
|
||||
this.bwsurl = config.bws.url;
|
||||
this.selectedAlternative = {
|
||||
name: config.wallet.settings.alternativeName,
|
||||
|
|
|
|||
35
src/js/controllers/preferencesFee.js
Normal file
35
src/js/controllers/preferencesFee.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesFeeController',
|
||||
function($rootScope, $scope, configService, go) {
|
||||
var config = configService.getSync();
|
||||
this.feeName = config.wallet.settings.feeName || 'Priority';
|
||||
this.feeOpts = [{
|
||||
name: 'Priority',
|
||||
value: 100,
|
||||
}, {
|
||||
name: 'Normal',
|
||||
value: 50,
|
||||
}, {
|
||||
name: 'Economy',
|
||||
value: 10,
|
||||
}];
|
||||
|
||||
this.save = function(newFee) {
|
||||
var opts = {
|
||||
wallet: {
|
||||
settings: {
|
||||
feeName: newFee.name,
|
||||
feeValue: newFee.value * 100,
|
||||
}
|
||||
}
|
||||
};
|
||||
this.feeName = newFee.name;
|
||||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) console.log(err);
|
||||
$scope.$emit('Local/UnitSettingUpdated');
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
|
@ -132,6 +132,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
$scope.error = null;
|
||||
$scope.tx = tx;
|
||||
$scope.amountStr = tx.amountStr;
|
||||
$scope.feeStr = tx.feeStr;
|
||||
$scope.alternativeAmountStr = tx.alternativeAmountStr;
|
||||
$scope.copayers = copayers
|
||||
$scope.copayerId = fc.credentials.copayerId;
|
||||
|
|
@ -608,6 +609,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
amount: amount,
|
||||
message: comment,
|
||||
payProUrl: paypro ? paypro.url : null,
|
||||
feePerKb: config.feeValue || 10000,
|
||||
}, function(err, txp) {
|
||||
if (err) {
|
||||
self.setOngoingProcess();
|
||||
|
|
@ -917,6 +919,32 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
return actions.hasOwnProperty('create');
|
||||
};
|
||||
|
||||
this._doSendAll = function(amount) {
|
||||
this.setForm(null, amount);
|
||||
};
|
||||
|
||||
this.sendAll = function(amount, feeStr) {
|
||||
var self = this;
|
||||
var msg = gettextCatalog.getString("{{fee}} will be discounted for bitcoin networking fees", {
|
||||
fee: feeStr
|
||||
});
|
||||
if (isCordova) {
|
||||
navigator.notification.confirm(
|
||||
msg,
|
||||
function(buttonIndex) {
|
||||
if (buttonIndex == 1)
|
||||
$timeout(function() {
|
||||
self._doSendAll(amount);
|
||||
}, 1);
|
||||
}
|
||||
);
|
||||
} else {
|
||||
if (confirm(msg))
|
||||
this._doSendAll(amount);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.bindTouchDown();
|
||||
this.setAddress();
|
||||
this.setSendFormInputs();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ angular
|
|||
historicLog.add(level, args.join(' '));
|
||||
orig.apply(null, args);
|
||||
} catch (e) {
|
||||
console.log('Error at log decorator:', e);
|
||||
console.log('ERROR (at log decorator):', e, args[0]);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
@ -245,6 +245,18 @@ angular
|
|||
},
|
||||
}
|
||||
})
|
||||
.state('preferencesFee', {
|
||||
url: '/preferencesFee',
|
||||
templateUrl: 'views/preferencesFee.html',
|
||||
walletShouldBeComplete: true,
|
||||
needProfile: true,
|
||||
views: {
|
||||
'main': {
|
||||
templateUrl: 'views/preferencesFee.html'
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
.state('preferencesAdvanced', {
|
||||
url: '/preferencesAdvanced',
|
||||
templateUrl: 'views/preferencesAdvanced.html',
|
||||
|
|
@ -451,6 +463,7 @@ angular
|
|||
delete: 13,
|
||||
preferencesLanguage: 12,
|
||||
preferencesUnit: 12,
|
||||
preferencesFee: 12,
|
||||
preferencesAltCurrency: 12,
|
||||
preferencesBwsUrl: 12,
|
||||
preferencesAlias: 12,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue