better tx create at confirm

This commit is contained in:
Matias Alejo Garcia 2016-09-02 14:17:47 -03:00
commit d7e025c2d0
No known key found for this signature in database
GPG key ID: 02470DB551277AB3
7 changed files with 34 additions and 29 deletions

View file

@ -17,13 +17,6 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.commentPopupSave = function(description) {
$log.debug('Saving description: ' + description);
$scope.description = description;
$scope.txp = null;
createTx($scope.wallet, function(err, txp) {
if (err) return;
cachedTxp[$scope.wallet.id] = txp;
apply(txp);
});
commentPopup.close();
};
};
@ -165,7 +158,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
apply(cachedTxp[wallet.id]);
} else {
stop = $timeout(function() {
createTx(wallet, function(err, txp) {
createTx(wallet, true, function(err, txp) {
if (err) return;
cachedTxp[wallet.id] = txp;
apply(txp);
@ -184,7 +177,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.$apply();
};
var createTx = function(wallet, cb) {
var createTx = function(wallet, dryRun, cb) {
var config = configService.getSync().wallet;
var currentSpendUnconfirmed = config.spendUnconfirmed;
var outputs = [];
@ -227,6 +220,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
txp.payProUrl = paypro;
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
txp.feeLevel = config.settings.feeLevel || 'normal';
txp.dryRun = dryRun;
walletService.createTx(wallet, txp, function(err, ctxp) {
if (err) {
@ -247,14 +241,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
$scope.approve = function() {
var wallet = $scope.wallet;
var txp = $scope.txp;
if (!wallet) {
return setSendError(gettextCatalog.getString('No wallet selected'));
};
if (!txp) {
return setSendError(gettextCatalog.getString('No transaction'));
};
if (!wallet.canSign() && !wallet.isPrivKeyExternal()) {
$log.info('No signing proposal: No private key');
@ -265,9 +255,12 @@ angular.module('copayApp.controllers').controller('confirmController', function(
});
}
walletService.publishAndSign(wallet, txp, function(err, txp) {
if (err) return setSendError(err);
$state.transitionTo('tabs.home');
createTx(wallet, false, function(err, txp) {
if (err) return;
walletService.publishAndSign(wallet, txp, function(err, txp) {
if (err) return setSendError(err);
$state.transitionTo('tabs.home');
});
});
};