diff --git a/js/controllers/send.js b/js/controllers/send.js index fd9338194..e4f378c1c 100644 --- a/js/controllers/send.js +++ b/js/controllers/send.js @@ -143,7 +143,7 @@ angular.module('copayApp.controllers').controller('SendController', if (merchantData.pr.ca) { message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.'; } - message += ' Message from server: ' + merchantData.ack.memo; + message += ' Message from server: ' + merchantData.pr.pd.memo; message += ' For merchant: ' + merchantData.pr.pd.payment_url; } notification.success('Success', message); @@ -156,7 +156,7 @@ angular.module('copayApp.controllers').controller('SendController', if (merchantData.pr.ca) { message += ' This payment protocol transaction' + ' has been verified through ' + merchantData.pr.ca + '.'; } - message += ' Message from server: ' + merchantData.ack.memo; + message += ' Message from server: ' + merchantData.pr.pd.memo; message += ' For merchant: ' + merchantData.pr.pd.payment_url; } notification.success('Transaction broadcasted', message); @@ -464,6 +464,7 @@ angular.module('copayApp.controllers').controller('SendController', // whether we're in the Send scope or not. if (!scope.sendForm || !scope.sendForm.address) { delete $rootScope.merchant; + $rootScope.merchantError = false; if (callback) callback(); return; } @@ -547,9 +548,8 @@ angular.module('copayApp.controllers').controller('SendController', var balance = $rootScope.availableBalance; var available = +(balance * w.settings.unitToSatoshi).toFixed(0); - if (merchantData && available < +merchantData.total) { - err = new Error('No unspent outputs available.'); + err = new Error('Insufficient funds.'); err.amount = merchantData.total; } diff --git a/js/models/Wallet.js b/js/models/Wallet.js index 8c63878f6..de618a830 100644 --- a/js/models/Wallet.js +++ b/js/models/Wallet.js @@ -1434,7 +1434,7 @@ Wallet.prototype.createPaymentTx = function(options, cb) { return self.receivePaymentRequest(options, pr, cb); }) .error(function(data, status, headers, config) { - log.debug('Server was did not return PaymentRequest.'); + log.debug('Server did not return PaymentRequest.'); log.debug('XHR status: ' + status); if (options.fetch) { return cb(new Error('Status: ' + status)); @@ -1592,6 +1592,8 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) { self.sendIndexes(); self.sendTxProposal(ntxid); self.emit('txProposalsUpdated'); + } else { + return cb(new Error('Error creating the transaction')); } log.debug('You are currently on this BTC network:', network); @@ -1867,9 +1869,15 @@ Wallet.prototype.createPaymentTxSync = function(options, merchantData, unspent) merchantData.total = merchantData.total.toString(10); - var b = new Builder(opts) - .setUnspent(unspent) - .setOutputs(outs); + var b; + try { + b = new Builder(opts) + .setUnspent(unspent) + .setOutputs(outs); + } catch (e) { + log.debug(e.message); + return; + }; merchantData.pr.pd.outputs.forEach(function(output, i) { var script = { @@ -2304,7 +2312,7 @@ Wallet.prototype.createTx = function(toAddress, amountSatStr, comment, opts, cb) var ntxid = self.createTxSync(toAddress, amountSatStr, comment, safeUnspent, opts); if (!ntxid) { - return cb(new Error('Error creating the Transaction')); + return cb(new Error('Error creating the transaction')); } self.sendIndexes(); diff --git a/views/send.html b/views/send.html index 69236e72a..7707ce9dd 100644 --- a/views/send.html +++ b/views/send.html @@ -72,7 +72,7 @@