mirror of https://github.com/BTCPrivate/copay.git
paypro: minor refactor - clean up whitespace in directives.
This commit is contained in:
parent
d58bfe9de8
commit
80ceca3b73
|
@ -12,10 +12,22 @@ angular.module('copayApp.directives')
|
|||
require: 'ngModel',
|
||||
link: function(scope, elem, attrs, ctrl) {
|
||||
var validator = function(value) {
|
||||
var uri = copay.HDPath.parseBitcoinURI(value);
|
||||
var uri;
|
||||
|
||||
// Is this a payment protocol URI (BIP-72)?
|
||||
if (uri && uri.merchant) {
|
||||
if (/^https?:\/\//.test(value)) {
|
||||
uri = { merchant: value };
|
||||
} else {
|
||||
uri = copay.HDPath.parseBitcoinURI(value);
|
||||
}
|
||||
|
||||
// Regular Address
|
||||
if (!uri || !uri.merchant) {
|
||||
var a = new Address(value);
|
||||
ctrl.$setValidity('validAddress', a.isValid() && a.network().name === config.networkName);
|
||||
return value;
|
||||
}
|
||||
|
||||
// Payment Protocol URI (BIP-72)
|
||||
scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
|
||||
var balance = $rootScope.availableBalance;
|
||||
var available = +(balance * config.unitToSatoshi).toFixed(0);
|
||||
|
@ -147,11 +159,6 @@ angular.module('copayApp.directives')
|
|||
ctrl.$setValidity('validAddress', true);
|
||||
|
||||
return 'Merchant: '+ uri.merchant;
|
||||
}
|
||||
|
||||
var a = new Address(value);
|
||||
ctrl.$setValidity('validAddress', a.isValid() && a.network().name === config.networkName);
|
||||
return value;
|
||||
};
|
||||
|
||||
ctrl.$parsers.unshift(validator);
|
||||
|
|
Loading…
Reference in New Issue