Cleaner way without redundant code
This commit is contained in:
parent
1e1f5deb2a
commit
6c6d90ebfe
1 changed files with 9 additions and 12 deletions
|
|
@ -1180,20 +1180,17 @@ angular.module('copayApp.services').factory('walletService', function($log, $tim
|
|||
if (signedTxp.status == 'accepted') {
|
||||
ongoingProcess.set('broadcastingTx', true, customStatusHandler);
|
||||
|
||||
var handleBroadcastTx = function(err, broadcastedTxp) {
|
||||
ongoingProcess.set('broadcastingTx', false, customStatusHandler);
|
||||
if (err) return cb(bwcError.msg(err));
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return cb(null, broadcastedTxp);
|
||||
};
|
||||
|
||||
if (signedTxp.payProUrl && signedTxp.coin == 'bch') {
|
||||
payproService.broadcastBchTx(signedTxp, function(err, broadcastedTxp) {
|
||||
ongoingProcess.set('broadcastingTx', false, customStatusHandler);
|
||||
if (err) return cb(bwcError.msg(err));
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return cb(null, broadcastedTxp);
|
||||
});
|
||||
payproService.broadcastBchTx(signedTxp, handleBroadcastTx);
|
||||
} else {
|
||||
root.broadcastTx(wallet, signedTxp, function(err, broadcastedTxp) {
|
||||
ongoingProcess.set('broadcastingTx', false, customStatusHandler);
|
||||
if (err) return cb(bwcError.msg(err));
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
return cb(null, broadcastedTxp);
|
||||
});
|
||||
root.broadcastTx(wallet, signedTxp, handleBroadcastTx);
|
||||
}
|
||||
} else {
|
||||
$rootScope.$emit('Local/TxAction', wallet.id);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue