paypro: show actual notification if there are no unspent outputs for payment request.
This commit is contained in:
parent
f5b1afdbf1
commit
fe2118fcbe
2 changed files with 6 additions and 9 deletions
|
|
@ -1,8 +1,8 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.directives')
|
angular.module('copayApp.directives')
|
||||||
.directive('validAddress', ['$rootScope',
|
.directive('validAddress', ['$rootScope', 'notification',
|
||||||
function($rootScope) {
|
function($rootScope, notification) {
|
||||||
|
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
var Address = bitcore.Address;
|
var Address = bitcore.Address;
|
||||||
|
|
@ -32,17 +32,14 @@ angular.module('copayApp.directives')
|
||||||
var balance = $rootScope.availableBalance;
|
var balance = $rootScope.availableBalance;
|
||||||
var available = +(balance * config.unitToSatoshi).toFixed(0);
|
var available = +(balance * config.unitToSatoshi).toFixed(0);
|
||||||
|
|
||||||
if ((err && err.message === 'No unspent outputs.')
|
if (merchantData && available < +merchantData.total) {
|
||||||
|| available < +merchantData.total) {
|
err = new Error('No unspent outputs available.');
|
||||||
// TODO: Actually display a notification window here
|
|
||||||
// instead of simply saying the URI is invalid.
|
|
||||||
ctrl.$setValidity('validAddress', false);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err) {
|
if (err) {
|
||||||
if (scope._resetPayPro) scope._resetPayPro();
|
if (scope._resetPayPro) scope._resetPayPro();
|
||||||
ctrl.$setValidity('validAddress', false);
|
ctrl.$setValidity('validAddress', false);
|
||||||
|
notification.error('Error', err.message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -934,7 +934,7 @@ Wallet.prototype.receivePaymentRequest = function(options, pr, cb) {
|
||||||
return this.getUnspent(function(err, unspent) {
|
return this.getUnspent(function(err, unspent) {
|
||||||
if (options.fetch) {
|
if (options.fetch) {
|
||||||
if (!unspent || !unspent.length) {
|
if (!unspent || !unspent.length) {
|
||||||
return cb(new Error('No unspent outputs.'));
|
return cb(new Error('No unspent outputs available.'));
|
||||||
}
|
}
|
||||||
self.createPaymentTxSync(options, merchantData, unspent);
|
self.createPaymentTxSync(options, merchantData, unspent);
|
||||||
return cb(null, merchantData, pr);
|
return cb(null, merchantData, pr);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue