Prevent double tap (in mobile)

This commit is contained in:
Gustavo Maximiliano Cortez 2016-08-01 14:16:47 -03:00
parent 6d79a5da72
commit b210a970d3
No known key found for this signature in database
GPG Key ID: 15EDAD8D9F2EB1AF
2 changed files with 82 additions and 76 deletions

View File

@ -27,46 +27,49 @@ angular.module('copayApp.controllers').controller('txpDetailsController', functi
$scope.error = null;
$scope.loading = 'Signing Transaction';
fingerprintService.check(fc, function(err) {
if (err) {
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
$timeout(function() {
handleEncryptedWallet(function(err) {
fingerprintService.check(fc, function(err) {
if (err) {
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
walletService.signTx(fc, txp, function(err, signedTxp) {
walletService.lock(fc);
handleEncryptedWallet(function(err) {
if (err) {
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
if (signedTxp.status == 'accepted') {
$scope.loading = 'Broadcasting Transaction';
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
walletService.signTx(fc, txp, function(err, signedTxp) {
walletService.lock(fc);
if (err) {
$scope.error = bwcError.msg(err);
$scope.loading = null;
return;
}
if (signedTxp.status == 'accepted') {
$scope.loading = 'Broadcasting Transaction';
walletService.broadcastTx(fc, signedTxp, function(err, broadcastedTxp) {
$scope.loading = null;
$scope.$emit('UpdateTx');
$scope.close(broadcastedTxp);
if (err) {
$scope.error = err;
}
});
} else {
$scope.loading = null;
$scope.$emit('UpdateTx');
$scope.close(broadcastedTxp);
if (err) {
$scope.error = err;
}
});
} else {
$scope.loading = null;
$scope.$emit('UpdateTx');
$scope.close(signedTxp);
}
$scope.close(signedTxp);
}
});
});
});
});
}, 10);
};
$scope.reject = function(txp) {

View File

@ -823,70 +823,73 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
this.error = null;
ongoingProcess.set('calculatingFee', true);
feeService.getCurrentFeeValue(function(err, feePerKb) {
ongoingProcess.set('calculatingFee', false);
if (err || !lodash.isNumber(feePerKb)) {
self.error = gettext('Could not get fee value');
return;
}
$timeout(function() {
var opts = {};
opts.feePerKb = feePerKb;
opts.returnInputs = true;
var config = configService.getSync();
opts.excludeUnconfirmedUtxos = !config.wallet.spendUnconfirmed;
ongoingProcess.set('retrivingInputs', true);
fc.getSendMaxInfo(opts, function(err, resp) {
ongoingProcess.set('retrivingInputs', false);
if (err) {
self.error = err;
$scope.$apply();
feeService.getCurrentFeeValue(function(err, feePerKb) {
ongoingProcess.set('calculatingFee', false);
if (err || !lodash.isNumber(feePerKb)) {
self.error = gettext('Could not get fee value');
return;
}
if (resp.amount == 0) {
self.error = gettext("Not enough funds for fee");
$scope.$apply();
return;
}
var opts = {};
opts.feePerKb = feePerKb;
opts.returnInputs = true;
var config = configService.getSync();
opts.excludeUnconfirmedUtxos = !config.wallet.spendUnconfirmed;
ongoingProcess.set('retrivingInputs', true);
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName
});
fc.getSendMaxInfo(opts, function(err, resp) {
ongoingProcess.set('retrivingInputs', false);
var warningMsg = verifyExcludedUtxos();
if (err) {
self.error = err;
$scope.$apply();
return;
}
if (!lodash.isEmpty(warningMsg))
msg += '. \n' + warningMsg;
if (resp.amount == 0) {
self.error = gettext("Not enough funds for fee");
$scope.$apply();
return;
}
confirmDialog.show(msg, function(confirmed) {
if (confirmed) {
self.sendMaxInfo = resp;
var amount = parseFloat((resp.amount * self.satToUnit).toFixed(self.unitDecimals));
self.setForm(null, amount, null);
} else {
self.resetForm();
var msg = gettextCatalog.getString("{{fee}} will be deducted for bitcoin networking fees", {
fee: profileService.formatAmount(resp.fee) + ' ' + self.unitName
});
var warningMsg = verifyExcludedUtxos();
if (!lodash.isEmpty(warningMsg))
msg += '. \n' + warningMsg;
confirmDialog.show(msg, function(confirmed) {
if (confirmed) {
self.sendMaxInfo = resp;
var amount = parseFloat((resp.amount * self.satToUnit).toFixed(self.unitDecimals));
self.setForm(null, amount, null);
} else {
self.resetForm();
}
});
function verifyExcludedUtxos() {
var warningMsg = [];
if (resp.utxosBelowFee > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
amountBelowFeeStr: profileService.formatAmount(resp.amountBelowFee) + ' ' + self.unitName
}));
}
if (resp.utxosAboveMaxSize > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", {
amountAboveMaxSizeStr: profileService.formatAmount(resp.amountAboveMaxSize) + ' ' + self.unitName
}));
}
return warningMsg.join('\n');
}
});
function verifyExcludedUtxos() {
var warningMsg = [];
if (resp.utxosBelowFee > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountBelowFeeStr}} were excluded. These funds come from UTXOs smaller than the network fee provided.", {
amountBelowFeeStr: profileService.formatAmount(resp.amountBelowFee) + ' ' + self.unitName
}));
}
if (resp.utxosAboveMaxSize > 0) {
warningMsg.push(gettextCatalog.getString("Note: a total of {{amountAboveMaxSizeStr}} were excluded. The maximum size allowed for a transaction was exceeded", {
amountAboveMaxSizeStr: profileService.formatAmount(resp.amountAboveMaxSize) + ' ' + self.unitName
}));
}
return warningMsg.join('\n');
}
});
});
}, 10);
};
/* Start setup */