Merge pull request #2799 from matiu/bug/broadcast-fail
better handling of sign/broadcast fail
This commit is contained in:
commit
55585f0a94
3 changed files with 40 additions and 24 deletions
|
|
@ -278,7 +278,7 @@
|
||||||
<div>
|
<div>
|
||||||
<h4 class="title m0">
|
<h4 class="title m0">
|
||||||
|
|
||||||
<div ng-show="!index.lockedBalance">
|
<div ng-show="!index.lockedBalance && index.availableBalanceStr">
|
||||||
<div class="size-12">
|
<div class="size-12">
|
||||||
<span class="db text-bold">
|
<span class="db text-bold">
|
||||||
<span translate>Available Balance</span>:
|
<span translate>Available Balance</span>:
|
||||||
|
|
@ -297,7 +297,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="text-gray" >
|
<span class="text-gray" >
|
||||||
{{index.lockedBalanceStr}}
|
{{index.lockedBalanceStr}}
|
||||||
<span translate>in pending payments</span>
|
<span translate>locked by pending payments</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -75,6 +75,9 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
|
|
||||||
// Clean status
|
// Clean status
|
||||||
self.lockedBalance = null;
|
self.lockedBalance = null;
|
||||||
|
self.availableBalanceStr = null;
|
||||||
|
self.totalBalanceStr = null;
|
||||||
|
self.lockedBalanceStr = null;
|
||||||
self.totalBalanceStr = null;
|
self.totalBalanceStr = null;
|
||||||
self.alternativeBalanceAvailable = false;
|
self.alternativeBalanceAvailable = false;
|
||||||
self.totalBalanceAlternative = null;
|
self.totalBalanceAlternative = null;
|
||||||
|
|
@ -82,7 +85,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.txHistory = [];
|
self.txHistory = [];
|
||||||
self.txHistoryPaging = false;
|
self.txHistoryPaging = false;
|
||||||
self.pendingTxProposalsCountForUs = null;
|
self.pendingTxProposalsCountForUs = null;
|
||||||
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
self.hasProfile = true;
|
self.hasProfile = true;
|
||||||
self.noFocusedWallet = false;
|
self.noFocusedWallet = false;
|
||||||
|
|
@ -158,11 +160,21 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var _walletStatusHash = function(walletStatus) {
|
||||||
|
var bal;
|
||||||
|
if (walletStatus) {
|
||||||
|
bal = walletStatus.balance.totalAmount;
|
||||||
|
} else {
|
||||||
|
bal = self.totalBalanceSat;
|
||||||
|
}
|
||||||
|
return bal;
|
||||||
|
};
|
||||||
|
|
||||||
self.updateAll = function(walletStatus, untilItChanges, initBalance, tries) {
|
self.updateAll = function(walletStatus, untilItChanges, initStatusHash, tries) {
|
||||||
tries = tries || 0;
|
tries = tries || 0;
|
||||||
if (untilItChanges && lodash.isUndefined(initBalance)) {
|
if (untilItChanges && lodash.isUndefined(initStatusHash)) {
|
||||||
initBalance = self.totalBalanceSat;
|
initStatusHash = _walletStatusHash();
|
||||||
|
$log.debug('Updating status until it changes. initStatusHash:' + initStatusHash)
|
||||||
}
|
}
|
||||||
var get = function(cb) {
|
var get = function(cb) {
|
||||||
if (walletStatus)
|
if (walletStatus)
|
||||||
|
|
@ -187,9 +199,12 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.setOngoingProcess('updatingStatus', true);
|
self.setOngoingProcess('updatingStatus', true);
|
||||||
$log.debug('Updating Status:', fc, tries);
|
$log.debug('Updating Status:', fc, tries);
|
||||||
get(function(err, walletStatus) {
|
get(function(err, walletStatus) {
|
||||||
if (!err && untilItChanges && initBalance == walletStatus.balance.totalAmount && tries < 7) {
|
var currentStatusHash = _walletStatusHash(walletStatus);
|
||||||
|
$log.debug('Status update. hash:' + currentStatusHash + ' Try:'+ tries);
|
||||||
|
if (!err && untilItChanges && initStatusHash == currentStatusHash && tries < 7) {
|
||||||
return $timeout(function() {
|
return $timeout(function() {
|
||||||
return self.updateAll(null, true, initBalance, ++tries);
|
$log.debug('Retrying update... Try:' + tries)
|
||||||
|
return self.updateAll(null, true, initStatusHash, ++tries);
|
||||||
}, 1400 * tries);
|
}, 1400 * tries);
|
||||||
}
|
}
|
||||||
self.setOngoingProcess('updatingStatus', false);
|
self.setOngoingProcess('updatingStatus', false);
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
|
|
||||||
this.openTxpModal = function(tx, copayers) {
|
this.openTxpModal = function(tx, copayers) {
|
||||||
var fc = profileService.focusedClient;
|
var fc = profileService.focusedClient;
|
||||||
|
var refreshUntilItChanges = false;
|
||||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||||
$scope.error = null;
|
$scope.error = null;
|
||||||
$scope.tx = tx;
|
$scope.tx = tx;
|
||||||
|
|
@ -136,6 +137,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
$scope.copayerId = fc.credentials.copayerId;
|
$scope.copayerId = fc.credentials.copayerId;
|
||||||
$scope.loading = null;
|
$scope.loading = null;
|
||||||
$scope.color = fc.backgroundColor;
|
$scope.color = fc.backgroundColor;
|
||||||
|
refreshUntilItChanges = false;
|
||||||
|
|
||||||
$scope.getShortNetworkName = function() {
|
$scope.getShortNetworkName = function() {
|
||||||
return fc.credentials.networkName.substring(0, 4);
|
return fc.credentials.networkName.substring(0, 4);
|
||||||
|
|
@ -218,12 +220,11 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
$scope.error = gettext('Could not broadcast payment. Check you connection and try again');
|
$scope.error = gettext('Could not broadcast payment. Check you connection and try again');
|
||||||
$scope.$digest();
|
$scope.$digest();
|
||||||
} else {
|
} else {
|
||||||
|
$log.debug('Transaction signed and broadcasted')
|
||||||
console.log('[walletHome.js.219]'); //TODO
|
|
||||||
if (memo)
|
if (memo)
|
||||||
$log.info(memo);
|
$log.info(memo);
|
||||||
|
|
||||||
txpsb.refreshUntilItChanges = true;
|
refreshUntilItChanges = true;
|
||||||
$modalInstance.close(txpsb);
|
$modalInstance.close(txpsb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -294,7 +295,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
if (memo)
|
if (memo)
|
||||||
$log.info(memo);
|
$log.info(memo);
|
||||||
|
|
||||||
txpb.refreshUntilItChanges = true;
|
refreshUntilItChanges = true;
|
||||||
$modalInstance.close(txpb);
|
$modalInstance.close(txpb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -323,8 +324,6 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
});
|
});
|
||||||
|
|
||||||
modalInstance.result.then(function(txp) {
|
modalInstance.result.then(function(txp) {
|
||||||
var refreshUntilItChanges = txp.refreshUntilItChanges;
|
|
||||||
console.log('[walletHome.js.323:refreshUntilItChanges:]', refreshUntilItChanges); //TODO
|
|
||||||
self.setOngoingProcess();
|
self.setOngoingProcess();
|
||||||
if (txp) {
|
if (txp) {
|
||||||
txStatus.notify(txp, function() {
|
txStatus.notify(txp, function() {
|
||||||
|
|
@ -332,7 +331,7 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$emit('Local/TxProposalAction');
|
$scope.$emit('Local/TxProposalAction', refreshUntilItChanges);
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -614,12 +613,16 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
}
|
}
|
||||||
|
|
||||||
self.signAndBroadcast(txp, function(err) {
|
self.signAndBroadcast(txp, function(err) {
|
||||||
if (err) {
|
self.setOngoingProcess();
|
||||||
self.setOngoingProcess();
|
profileService.lockFC();
|
||||||
return self.setSendError(err);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.resetForm();
|
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);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
|
|
@ -631,20 +634,18 @@ angular.module('copayApp.controllers').controller('walletHomeController', functi
|
||||||
self.setOngoingProcess(gettext('Signing transaction'));
|
self.setOngoingProcess(gettext('Signing transaction'));
|
||||||
fc.signTxProposal(txp, function(err, signedTx) {
|
fc.signTxProposal(txp, function(err, signedTx) {
|
||||||
profileService.lockFC();
|
profileService.lockFC();
|
||||||
|
self.setOngoingProcess();
|
||||||
if (err) {
|
if (err) {
|
||||||
self.setOngoingProcess();
|
err.message = gettext('The payment was created but could not be signed. Please try again from home screen.') + (err.message ? ' ' + err.message : '');
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (signedTx.status == 'accepted') {
|
if (signedTx.status == 'accepted') {
|
||||||
self.setOngoingProcess(gettext('Broadcasting transaction'));
|
self.setOngoingProcess(gettext('Broadcasting transaction'));
|
||||||
|
|
||||||
fc.broadcastTxProposal(signedTx, function(err, btx, memo) {
|
fc.broadcastTxProposal(signedTx, function(err, btx, memo) {
|
||||||
self.setOngoingProcess();
|
self.setOngoingProcess();
|
||||||
if (err) {
|
if (err) {
|
||||||
$scope.error = gettext('Transaction not broadcasted. Please try again.');
|
err.message = gettext('The payment was signed but could not be broadcasted. Please try again from home screen.') + (err.message ? ' ' + err.message : '');
|
||||||
$scope.$digest();
|
|
||||||
return cb(err);
|
return cb(err);
|
||||||
}
|
}
|
||||||
if (memo)
|
if (memo)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue