Removes AdvSend and Ref getFeeLevels before send
This commit is contained in:
parent
4de200656d
commit
e4729fa40c
6 changed files with 97 additions and 162 deletions
|
|
@ -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');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
@ -272,7 +270,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 +660,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 +827,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 +868,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 +879,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);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1029,10 +1004,6 @@ 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;
|
||||
|
||||
|
|
@ -1295,7 +1266,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
|||
this.setForm(null, amount, null, feeRate);
|
||||
};
|
||||
|
||||
this.sendAll = function(amount, feeStr, feeRate, currentFeeLevel) {
|
||||
this.sendAll = function(amount, feeStr, feeRate) {
|
||||
var self = this;
|
||||
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
|
||||
fee: feeStr
|
||||
|
|
@ -1304,9 +1275,6 @@ 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;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue