paypro: show actual notification if there are no unspent outputs for payment request.

This commit is contained in:
Christopher Jeffrey 2014-08-07 10:36:44 -07:00 committed by Manuel Araoz
parent f5b1afdbf1
commit fe2118fcbe
2 changed files with 6 additions and 9 deletions

View File

@ -1,8 +1,8 @@
'use strict';
angular.module('copayApp.directives')
.directive('validAddress', ['$rootScope',
function($rootScope) {
.directive('validAddress', ['$rootScope', 'notification',
function($rootScope, notification) {
var bitcore = require('bitcore');
var Address = bitcore.Address;
@ -32,17 +32,14 @@ angular.module('copayApp.directives')
var balance = $rootScope.availableBalance;
var available = +(balance * config.unitToSatoshi).toFixed(0);
if ((err && err.message === 'No unspent outputs.')
|| available < +merchantData.total) {
// TODO: Actually display a notification window here
// instead of simply saying the URI is invalid.
ctrl.$setValidity('validAddress', false);
return;
if (merchantData && available < +merchantData.total) {
err = new Error('No unspent outputs available.');
}
if (err) {
if (scope._resetPayPro) scope._resetPayPro();
ctrl.$setValidity('validAddress', false);
notification.error('Error', err.message);
return;
}

View File

@ -934,7 +934,7 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
return this.getUnspent(function(err, unspent) {
if (options.fetch) {
if (!unspent || !unspent.length) {
return cb(new Error('No unspent outputs.'));
return cb(new Error('No unspent outputs available.'));
}
self.createPaymentTxSync(options, merchantData, unspent);
return cb(null, merchantData, pr);