<commit_before>'use strict';

angular.module('copayApp.directives')
  .directive('validAddress', ['$rootScope',
    function($rootScope) {

      var bitcore = require('bitcore');
      var Address = bitcore.Address;
      var bignum = bitcore.Bignum;

      return {
        require: 'ngModel',
        link: function(scope, elem, attrs, ctrl) {
          var validator = function(value) {
            var uri = copay.HDPath.parseBitcoinURI(value);

            // Is this a payment protocol URI (BIP-72)?
            if (uri && uri.merchant) {
              scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
                var balance = $rootScope.availableBalance;
                var available = +(balance * config.unitToSatoshi).toFixed(0);

                if ((err && err.message === 'No unspent outputs.')
                    || available < +merchantData.total) {
                  ctrl.$setValidity('validAddress', false);
                  return;
                }
<commit_msg>paypro: minor - comment.<commit_after>'use strict';

angular.module('copayApp.directives')
  .directive('validAddress', ['$rootScope',
    function($rootScope) {

      var bitcore = require('bitcore');
      var Address = bitcore.Address;
      var bignum = bitcore.Bignum;

      return {
        require: 'ngModel',
        link: function(scope, elem, attrs, ctrl) {
          var validator = function(value) {
            var uri = copay.HDPath.parseBitcoinURI(value);

            // Is this a payment protocol URI (BIP-72)?
            if (uri && uri.merchant) {
              scope.wallet.fetchPaymentTx(uri.merchant, function(err, merchantData) {
                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;
                }

{'fraction_non_alphanumeric': 0.1184331797235023, 'fraction_numerical': 0.0027649769585253456, 'mean_word_length': 1.965846994535519, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2831875', 'n_tokens_mistral': 601, 'n_tokens_neox': 578, 'n_words': 137}