From 7ffd48380786b0a029d0a29a321d86a7faaa8157 Mon Sep 17 00:00:00 2001 From: Gustavo Maximiliano Cortez Date: Fri, 13 Feb 2015 17:39:30 -0300 Subject: [PATCH] Catch error when transaction could not be sent. Update locked balance if transaction failed --- js/controllers/send.js | 16 +++++++++++----- js/models/Wallet.js | 1 + 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/js/controllers/send.js b/js/controllers/send.js index 100531945..fa5d49d07 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -163,6 +163,9 @@ angular.module('copayApp.controllers').controller('SendController', if (msg.match('expired')) msg = 'The payment request has expired'; + if (msg.match('XMLHttpRequest')) + msg = 'Error when sending to the blockchain. Resend it from Home'; + var message = 'The transaction' + ($scope.requiresMultipleSignatures ? ' proposal' : '') + ' could not be created: ' + msg; @@ -203,12 +206,15 @@ angular.module('copayApp.controllers').controller('SendController', }, function (err, txid, status) { $scope.loading = false; if ($scope.isWindowsPhoneApp) - $rootScope.wpInputFocused = false; + $rootScope.wpInputFocused = false; - if (err) - return $scope.setError(err); - txStatus.notify(status); - $scope.resetForm(); + if (err) { + $scope.setError(err); + } + else { + txStatus.notify(status); + $scope.resetForm(); + } }); }, 100); }; diff --git a/js/models/Wallet.js b/js/models/Wallet.js index 4f272f6d4..5f757a149 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -1651,6 +1651,7 @@ Wallet.prototype.broadcastToBitcoinNetwork = function(ntxid, cb) { log.debug('Wallet:' + self.getName() + ' Send failed:' + err); self._checkIfTxIsSent(ntxid, function(err, txid) { + self.emitAndKeepAlive('balanceUpdated'); return cb(err, txid); }); } else {