Merge pull request #3569 from cmgustavo/ref/remove-adv-send

Ref/remove adv send
This commit is contained in:
Gustavo Maximiliano Cortez 2015-12-02 12:34:55 -03:00
commit bf0c69c4ab
6 changed files with 105 additions and 177 deletions

View file

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Buy'; goBackToState = 'glidera'">
ng-init="titleSection='Buy'; goBackToState = 'glidera'; noColor = true">
</div>

View file

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Preferences'; goBackToState = 'glidera'">
ng-init="titleSection='Preferences'; goBackToState = 'glidera'; noColor = true">
</div>
<div class="content preferences" ng-controller="preferencesGlideraController as glidera">

View file

@ -1,7 +1,7 @@
<div
class="topbar-container"
ng-include="'views/includes/topbar.html'"
ng-init="titleSection='Sell'; goBackToState = 'glidera'">
ng-init="titleSection='Sell'; goBackToState = 'glidera'; noColor = true">
</div>
@ -111,7 +111,7 @@
Please, enter the code below
</p>
<form name="sellForm"
ng-submit="sell.createTx(index.glideraToken, index.glideraPermissions, twoFaCode)" novalidate>
ng-submit="sell.createTx(index.glideraToken, index.glideraPermissions, twoFaCode, index.feeRateToSendMax)" novalidate>
<input type="number" ng-model="twoFaCode" required>
<input class="button black expand round"
ng-style="{'background-color':index.backgroundColor}"

View file

@ -270,7 +270,7 @@
<available-balance></available-balance>
<a class="db"
ng-if="index.feeToSendMaxStr && index.availableBalanceSat > 0 && !home.blockUx && !home.lockAmount"
ng-click="home.sendAll(index.availableMaxBalance, index.feeToSendMaxStr, index.feeRateToSendMax, index.currentFeeLevel)"
ng-click="home.sendAll(index.availableMaxBalance, index.feeToSendMaxStr)"
translate> Send All
</a>
</h4>
@ -280,7 +280,7 @@
</div>
<div class="row m20t">
<div class="large-12 large-centered columns m20t">
<form name="sendForm" ng-submit="home.submitForm()" ng-disabled="home.blockUx || home.onGoingProcess" novalidate>
<form name="sendForm" ng-submit="home.submitForm(index.feeRateToSendMax)" ng-disabled="home.blockUx || home.onGoingProcess" novalidate>
<div class="box-notification" ng-show="home.error" ng-click="home.resetError()">
<span class="text-warning">
{{home.error|translate}}
@ -311,7 +311,7 @@
</div>
<a class="postfix button"
ng-style="{'background-color':index.backgroundColor}"
ng-click="openDestinationAddressModal(index.otherWallets, _address)">
ng-click="home.openDestinationAddressModal(index.otherWallets, _address)">
<i class="fi-plus size-14 lh"></i>
</a>
</div>
@ -377,35 +377,6 @@
</div>
</div>
<div class="m20b" ng-init="home.hideAdvSend=true" ng-show="!home.disableAdvSend">
<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.setFee(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">&nbsp;</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>

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('sellGlideraController',
function($scope, $timeout, $log, $modal, configService, profileService, addressService, feeService, glideraService, bwsError, lodash, isChromeApp, animationService) {
function($scope, $timeout, $log, $modal, configService, profileService, addressService, glideraService, bwsError, lodash, isChromeApp, animationService) {
var self = this;
var config = configService.getSync();
@ -11,7 +11,6 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
this.error = null;
this.loading = null;
this.currentSpendUnconfirmed = config.wallet.spendUnconfirmed;
this.currentFeeLevel = config.wallet.settings.feeLevel || 'normal';
var fc;
var otherWallets = function(testnet) {
@ -123,7 +122,7 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
}, 100);
};
this.createTx = function(token, permissions, twoFaCode) {
this.createTx = function(token, permissions, twoFaCode, currentFeePerKb) {
var self = this;
self.error = null;
@ -143,65 +142,62 @@ angular.module('copayApp.controllers').controller('sellGlideraController',
}
var amount = parseInt((self.sellPrice.qty * 100000000).toFixed(0));
feeService.getCurrentFeeValue(self.currentFeeLevel, function(err, feePerKb) {
if (err) $log.debug(err);
fc.sendTxProposal({
toAddress: sellAddress,
amount: amount,
message: 'Glidera transaction',
customData: {'glideraToken': token},
payProUrl: null,
feePerKb: feePerKb,
excludeUnconfirmedUtxos: self.currentSpendUnconfirmed ? false : true
}, function(err, txp) {
if (err) {
profileService.lockFC();
$log.error(err);
$timeout(function() {
self.loading = null;
self.error = bwsError.msg(err, 'Error');
}, 1);
return;
}
if (!fc.canSign()) {
fc.sendTxProposal({
toAddress: sellAddress,
amount: amount,
message: 'Glidera transaction',
customData: {'glideraToken': token},
payProUrl: null,
feePerKb: currentFeePerKb,
excludeUnconfirmedUtxos: self.currentSpendUnconfirmed ? false : true
}, function(err, txp) {
if (err) {
profileService.lockFC();
$log.error(err);
$timeout(function() {
self.loading = null;
$log.info('No signing proposal: No private key');
return;
}
self.error = bwsError.msg(err, 'Error');
}, 1);
return;
}
_signTx(txp, function(err, txp, rawTx) {
profileService.lockFC();
if (err) {
if (!fc.canSign()) {
self.loading = null;
$log.info('No signing proposal: No private key');
return;
}
_signTx(txp, function(err, txp, rawTx) {
profileService.lockFC();
if (err) {
self.loading = null;
self.error = err;
$scope.$apply();
}
else {
var data = {
refundAddress: refundAddress,
signedTransaction: rawTx,
priceUuid: self.sellPrice.priceUuid,
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
ip: null
};
glideraService.sell(token, twoFaCode, data, function(err, data) {
self.loading = null;
self.error = err;
$scope.$apply();
}
else {
var data = {
refundAddress: refundAddress,
signedTransaction: rawTx,
priceUuid: self.sellPrice.priceUuid,
useCurrentPrice: self.sellPrice.priceUuid ? false : true,
ip: null
};
glideraService.sell(token, twoFaCode, data, function(err, data) {
self.loading = null;
if (err) {
self.error = err;
fc.removeTxProposal(txp, function(err, txpb) {
$timeout(function() {
$scope.$emit('Local/GlideraError');
}, 100);
});
}
else {
self.success = data;
$scope.$emit('Local/GlideraTx');
}
});
}
});
if (err) {
self.error = err;
fc.removeTxProposal(txp, function(err, txpb) {
$timeout(function() {
$scope.$emit('Local/GlideraError');
}, 100);
});
}
else {
self.success = data;
$scope.$emit('Local/GlideraTx');
}
});
}
});
});
});

View file

@ -1,13 +1,12 @@
'use strict';
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, feeService, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go) {
angular.module('copayApp.controllers').controller('walletHomeController', function($scope, $rootScope, $timeout, $filter, $modal, $log, notification, txStatus, isCordova, profileService, lodash, configService, rateService, storageService, bitcore, isChromeApp, gettext, gettextCatalog, nodeWebkit, addressService, ledger, bwsError, confirmDialog, txFormatService, animationService, addressbookService, go) {
var self = this;
$rootScope.hideMenuBar = false;
$rootScope.wpInputFocused = false;
var config = configService.getSync();
var configWallet = config.wallet;
$scope.currentSpendUnconfirmed = configWallet.spendUnconfirmed;
// INIT
var walletSettings = configWallet.settings;
@ -23,7 +22,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.isMobile = isMobile.any();
this.isWindowsPhoneApp = isMobile.Windows() && isCordova;
this.blockUx = false;
this.disableAdvSend = false;
this.isRateAvailable = false;
this.showScanner = false;
this.isMobile = isMobile.any();
@ -115,10 +113,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
var cancel_msg = gettextCatalog.getString('Cancel');
var confirm_msg = gettextCatalog.getString('Confirm');
$scope.openDestinationAddressModal = function(wallets, address) {
this.openDestinationAddressModal = function(wallets, address) {
$rootScope.modalOpened = true;
var fc = profileService.focusedClient;
self.resetForm();
self.lockAddress = false;
self._address = null;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.wallets = wallets;
@ -272,7 +271,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
$rootScope.modalOpened = true;
var fc = profileService.focusedClient;
var refreshUntilItChanges = false;
var currentSpendUnconfirmed = $scope.currentSpendUnconfirmed;
var currentSpendUnconfirmed = configWallet.spendUnconfirmed;
var ModalInstanceCtrl = function($scope, $modalInstance) {
$scope.error = null;
$scope.copayers = copayers
@ -662,15 +661,6 @@ 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;
};
@ -838,13 +828,10 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
};
};
this.setFee = function(level) {
this.currentSendFeeLevel = level;
};
this.submitForm = function() {
this.submitForm = function(currentFeePerKb) {
var fc = profileService.focusedClient;
var unitToSat = this.unitToSatoshi;
var currentSpendUnconfirmed = configWallet.spendUnconfirmed;
if (isCordova && this.isWindowsPhoneApp) {
this.hideAddress = false;
@ -882,14 +869,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
address = form.address.$modelValue;
amount = parseInt((form.amount.$modelValue * unitToSat).toFixed(0));
var getFee = function(cb) {
if (form.feePerKb) {
cb(null, form.feePerKb);
} else {
feeService.getCurrentFeeValue(self.currentSendFeeLevel, cb);
}
};
requestTouchid(function(err) {
if (err) {
profileService.lockFC();
@ -901,43 +880,40 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return;
}
getFee(function(err, feePerKb) {
if (err) $log.debug(err);
fc.sendTxProposal({
toAddress: address,
amount: amount,
message: comment,
payProUrl: paypro ? paypro.url : null,
feePerKb: feePerKb,
excludeUnconfirmedUtxos: $scope.currentSpendUnconfirmed ? false : true
}, function(err, txp) {
if (err) {
self.setOngoingProcess();
profileService.lockFC();
return self.setSendError(err);
}
fc.sendTxProposal({
toAddress: address,
amount: amount,
message: comment,
payProUrl: paypro ? paypro.url : null,
feePerKb: currentFeePerKb,
excludeUnconfirmedUtxos: currentSpendUnconfirmed ? false : true
}, function(err, txp) {
if (err) {
self.setOngoingProcess();
profileService.lockFC();
return self.setSendError(err);
}
if (!fc.canSign() && !fc.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key')
self.setOngoingProcess();
self.resetForm();
txStatus.notify(txp, function() {
return $scope.$emit('Local/TxProposalAction');
});
return;
}
self.signAndBroadcast(txp, function(err) {
self.setOngoingProcess();
self.resetForm();
if (err) {
self.error = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen');
$scope.$emit('Local/TxProposalAction');
$timeout(function() {
$scope.$digest();
}, 1);
}
if (!fc.canSign() && !fc.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key')
self.setOngoingProcess();
self.resetForm();
txStatus.notify(txp, function() {
return $scope.$emit('Local/TxProposalAction');
});
return;
}
self.signAndBroadcast(txp, function(err) {
self.setOngoingProcess();
self.resetForm();
if (err) {
self.error = err.message ? err.message : gettext('The payment was created but could not be completed. Please try again from home screen');
$scope.$emit('Local/TxProposalAction');
$timeout(function() {
$scope.$digest();
}, 1);
}
});
});
});
@ -994,7 +970,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
});
};
this.setForm = function(to, amount, comment, feeRate) {
this.setForm = function(to, amount, comment) {
var form = $scope.sendForm;
if (to) {
form.address.$setViewValue(to);
@ -1015,10 +991,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
form.comment.$isValid = true;
form.comment.$render();
}
if (feeRate) {
form.feeRate = feeRate;
}
};
@ -1029,19 +1001,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.lockAddress = false;
this.lockAmount = false;
this.currentSendFeeLevel = null;
this.hideAdvSend = true;
this.disableAdvSend = false;
$scope.currentSpendUnconfirmed = configService.getSync().wallet.spendUnconfirmed;
this._amount = this._address = null;
var form = $scope.sendForm;
if (form && form.feeRate) {
form.feeRate = null;
}
if (form && form.amount) {
form.amount.$pristine = true;
form.amount.$setViewValue('');
@ -1291,11 +1255,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
return actions.hasOwnProperty('create');
};
this._doSendAll = function(amount, feeRate) {
this.setForm(null, amount, null, feeRate);
this._doSendAll = function(amount) {
this.setForm(null, amount, null);
};
this.sendAll = function(amount, feeStr, feeRate, currentFeeLevel) {
this.sendAll = function(amount, feeStr) {
var self = this;
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
fee: feeStr
@ -1303,10 +1267,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
confirmDialog.show(msg, function(confirmed) {
if (confirmed) {
self._doSendAll(amount, feeRate);
self.disableAdvSend = true;
self.currentSendFeeLevel = currentFeeLevel;
$scope.currentSpendUnconfirmed = configService.getSync().wallet.spendUnconfirmed;
self._doSendAll(amount);
}
});
};