paypro: even better notification when user has insufficient funds.
This commit is contained in:
parent
eea59bc0e1
commit
8e86826b68
2 changed files with 18 additions and 3 deletions
|
|
@ -425,12 +425,17 @@ angular.module('copayApp.controllers').controller('SendController',
|
|||
|
||||
if (merchantData && available < +merchantData.total) {
|
||||
err = new Error('No unspent outputs available.');
|
||||
scope.notEnoughAmount = true;
|
||||
scope.sendForm.amount.$isValid = false;
|
||||
err.amount = merchantData.total;
|
||||
}
|
||||
|
||||
if (err) {
|
||||
scope.sendForm.address.$isValid = false;
|
||||
if (err.amount) {
|
||||
scope.sendForm.amount.$setViewValue(+err.amount / config.unitToSatoshi);
|
||||
scope.sendForm.amount.$render();
|
||||
scope.sendForm.amount.$isValid = false;
|
||||
scope.notEnoughAmount = true;
|
||||
}
|
||||
notification.error('Error', err.message || 'Bad payment server.');
|
||||
if ($rootScope.$$phase !== '$apply' && $rootScope.$$phase !== '$digest') {
|
||||
$rootScope.$apply();
|
||||
|
|
|
|||
|
|
@ -932,7 +932,17 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
|
|||
if (!unspent || !unspent.length) {
|
||||
return cb(new Error('No unspent outputs available.'));
|
||||
}
|
||||
self.createPaymentTxSync(options, merchantData, unspent);
|
||||
try {
|
||||
self.createPaymentTxSync(options, merchantData, unspent);
|
||||
} catch (e) {
|
||||
var msg = e.message || '';
|
||||
if (msg.indexOf('not enough unspent tx outputs to fulfill')) {
|
||||
var sat = /(\d+)/.exec(msg)[1];
|
||||
e = new Error('No unspent outputs available.');
|
||||
e.amount = sat;
|
||||
return cb(e);
|
||||
}
|
||||
}
|
||||
return cb(null, merchantData, pr);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue