better "insufficient funds" message"
This commit is contained in:
parent
b45c2cfab0
commit
9fddde615a
3 changed files with 35 additions and 21 deletions
|
|
@ -58,9 +58,10 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
function setNoWallet(msg) {
|
function setNoWallet(msg, criticalError) {
|
||||||
$scope.wallet = null;
|
$scope.wallet = null;
|
||||||
$scope.noWalletMessage = msg;
|
$scope.noWalletMessage = msg;
|
||||||
|
$scope.criticalError = criticalError;
|
||||||
$log.warn('Not ready to make the payment:' + msg);
|
$log.warn('Not ready to make the payment:' + msg);
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
|
|
@ -81,7 +82,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!$scope.wallets || !$scope.wallets.length) {
|
if (!$scope.wallets || !$scope.wallets.length) {
|
||||||
setNoWallet(gettextCatalog.getString('No wallets available'));
|
setNoWallet(gettextCatalog.getString('No wallets available'), true);
|
||||||
return cb();
|
return cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,7 +111,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
|
||||||
return cb('Could not update any wallet');
|
return cb('Could not update any wallet');
|
||||||
|
|
||||||
if (lodash.isEmpty(filteredWallets)) {
|
if (lodash.isEmpty(filteredWallets)) {
|
||||||
setNoWallet(gettextCatalog.getString('Insufficient funds'));
|
setNoWallet(gettextCatalog.getString('Insufficient funds'), true);
|
||||||
}
|
}
|
||||||
$scope.wallets = lodash.clone(filteredWallets);
|
$scope.wallets = lodash.clone(filteredWallets);
|
||||||
return cb();
|
return cb();
|
||||||
|
|
|
||||||
|
|
@ -84,14 +84,9 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
|
|
||||||
data = sanitizeUri(data);
|
data = sanitizeUri(data);
|
||||||
|
|
||||||
// Bitcoin or Bitcoin Cash URL
|
// Bitcoin URL
|
||||||
if ((/^bitcoin(cash)?:/).exec(data)) {
|
if (bitcore.URI.isValid(data)) {
|
||||||
var coin = 'btc';
|
var coin = 'btc';
|
||||||
if ((/^bitcoincash:/).exec(data)) {
|
|
||||||
coin = 'bch';
|
|
||||||
data = data.replace(/bitcoincash:/, 'bitcoin:');
|
|
||||||
}
|
|
||||||
if (bitcore.URI.isValid(data)) {
|
|
||||||
var parsed = new bitcore.URI(data);
|
var parsed = new bitcore.URI(data);
|
||||||
|
|
||||||
var addr = parsed.address ? parsed.address.toString() : '';
|
var addr = parsed.address ? parsed.address.toString() : '';
|
||||||
|
|
@ -111,11 +106,30 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
} else {
|
} else if (bitcoreCash.URI.isValid(data)) {
|
||||||
$log.error('Invalid Bitcoin URL');
|
var coin = 'bch';
|
||||||
return false;
|
var parsed = new bitcoreCash.URI(data);
|
||||||
}
|
|
||||||
|
|
||||||
|
var addr = parsed.address ? parsed.address.toString() : '';
|
||||||
|
var message = parsed.message;
|
||||||
|
|
||||||
|
var amount = parsed.amount ? parsed.amount : '';
|
||||||
|
|
||||||
|
// paypro not yet supported on cash
|
||||||
|
if (parsed.r) {
|
||||||
|
payproService.getPayProDetails(parsed.r, function(err, details) {
|
||||||
|
if (err) {
|
||||||
|
if (addr && amount)
|
||||||
|
goSend(addr, amount, message, coin);
|
||||||
|
else
|
||||||
|
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||||
|
}
|
||||||
|
handlePayPro(details, coin);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
goSend(addr, amount, message, coin);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
// Plain URL
|
// Plain URL
|
||||||
} else if (/^https?:\/\//.test(data)) {
|
} else if (/^https?:\/\//.test(data)) {
|
||||||
|
|
||||||
|
|
@ -259,9 +273,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function goToAmountPage(toAddress, coin) {
|
function goToAmountPage(toAddress, coin) {
|
||||||
|
|
@ -277,12 +289,13 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePayPro(payProDetails) {
|
function handlePayPro(payProDetails, coin) {
|
||||||
var stateParams = {
|
var stateParams = {
|
||||||
toAmount: payProDetails.amount,
|
toAmount: payProDetails.amount,
|
||||||
toAddress: payProDetails.toAddress,
|
toAddress: payProDetails.toAddress,
|
||||||
description: payProDetails.memo,
|
description: payProDetails.memo,
|
||||||
paypro: payProDetails
|
paypro: payProDetails,
|
||||||
|
coin: coin,
|
||||||
};
|
};
|
||||||
scannerService.pausePreview();
|
scannerService.pausePreview();
|
||||||
$state.go('tabs.send', {}, {
|
$state.go('tabs.send', {}, {
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
<ion-content class="add-bottom-for-cta">
|
<ion-content class="add-bottom-for-cta">
|
||||||
<div class="list">
|
<div class="list">
|
||||||
<div class="item head">
|
<div class="item head" ng-hide="criticalError">
|
||||||
<div class="sending-label">
|
<div class="sending-label">
|
||||||
<img src="img/icon-tx-sent-outline.svg">
|
<img src="img/icon-tx-sent-outline.svg">
|
||||||
<span translate ng-if="!tx.sendMax">Sending</span>
|
<span translate ng-if="!tx.sendMax">Sending</span>
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
<span class="item-note" ng-if="paymentExpired" ng-style="{'color': 'red'}" translate>Expired</span>
|
<span class="item-note" ng-if="paymentExpired" ng-style="{'color': 'red'}" translate>Expired</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="item">
|
<div class="item" ng-hide="criticalError">
|
||||||
<span class="label" translate>To</span>
|
<span class="label" translate>To</span>
|
||||||
<span class="payment-proposal-to" ng-if="!recipientType">
|
<span class="payment-proposal-to" ng-if="!recipientType">
|
||||||
<img src="img/icon-bitcoin-small.svg">
|
<img src="img/icon-bitcoin-small.svg">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue