paypro: deal with no unspent outputs. see #1043.
This commit is contained in:
parent
8cbc231a06
commit
0a8d734e49
2 changed files with 9 additions and 0 deletions
|
|
@ -17,6 +17,12 @@ angular.module('copayApp.directives')
|
||||||
// Is this a payment protocol URI (BIP-72)?
|
// Is this a payment protocol URI (BIP-72)?
|
||||||
if (uri && uri.merchant) {
|
if (uri && uri.merchant) {
|
||||||
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
||||||
|
if ((err && err.message === 'No unspent outputs.')
|
||||||
|
|| scope.availableBalance < +merchantData.total) {
|
||||||
|
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);
|
||||||
|
|
|
||||||
|
|
@ -937,6 +937,9 @@ 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) {
|
||||||
|
return cb(new Error('No unspent outputs.'));
|
||||||
|
}
|
||||||
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