From fe2118fcbe147e612933072d31f2e5c4c832fe51 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Thu, 7 Aug 2014 10:36:44 -0700 Subject: [PATCH] paypro: show actual notification if there are no unspent outputs for payment request. --- js/directives.js | 13 +++++-------- js/models/core/Wallet.js | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/js/directives.js b/js/directives.js index ddf24b7cb..4d99e4d38 100644 --- a/js/directives.js +++ b/js/directives.js @@ -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; } diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index 98664efcd..cf8c9354b 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -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);