Given a crypto address, find which currency it likely belongs to.
    Raises an exception if it can't find a match. Raises exception if address
    is invalid.
765703
def guess_currency_from_address(address):
    
    if is_py2:
        fixer = lambda x: int(x.encode('hex'), 16)
    else:
        fixer = lambda x: x # does nothing

    first_byte = fixer(b58decode_check(address)[0])
    double_first_byte = fixer(b58decode_check(address)[:2])

    hits = []
    for currency, data in crypto_data.items():
        if hasattr(data, 'get'): # skip incomplete data listings
            version = data.get('address_version_byte', None)
            if version is not None and version in [double_first_byte, first_byte]:
                hits.append([currency, data['name']])

    if hits:
        return hits

    raise ValueError("Unknown Currency with first byte: %s" % first_byte)
609727
def match_country( value )
    if value =~ /^country:/       # country:
      country_key = value[8..-1]  # cut off country: prefix
      country = WorldDb::Model::Country.find_by_key!( country_key )
      yield( country )
      true # bingo - match found
    else
      false # no match found
    end
  end
433556
def check_address(self, address):
        """"""
        if address is None:
            self.raise_error(InvalidAddress, details='address is None')
        if all(letter == address[0] for letter in address) or len(address) < self.minFundingAddressLength or ' ' in address:
            self.raise_error(InvalidAddress, details='address is invalid or has less than ' + str(self.minFundingAddressLength) + ' characters: "' + str(address) + '"')
        return address
784919
@Override
  public String requestDepositAddress(Currency currency, String... arguments) throws IOException {
    if (currency.equals(Currency.BTC)) {
      return getBitstampBitcoinDepositAddress().getDepositAddress();
    } else if (currency.equals(Currency.LTC)) {
      return getBitstampLitecoinDepositAddress().getDepositAddress();
    } else if (currency.equals(Currency.XRP)) {
      return getRippleDepositAddress().getAddressAndDt();
    } else if (currency.equals(Currency.BCH)) {
      return getBitstampBitcoinCashDepositAddress().getDepositAddress();
    } else if (currency.equals(Currency.ETH)) {
      return getBitstampEthereumDepositAddress().getDepositAddress();
    } else {
      throw new IllegalStateException("Unsupported currency " + currency);
    }
  }
1011609
public Optional<String> findCommonCcy(final CurrencyPair otherPair) {
        if (containsCcy(otherPair.getCcy1())) {
            return Optional.of(otherPair.getCcy1());
        }
        return containsCcy(otherPair.getCcy2()) ? Optional.of(otherPair.getCcy2()) : Optional.empty();
    }
661859
def convert_currency(amount, from_currency, to_currency):
    '''
    

    '''
    try:
        rate = CurrencyRate.objects.get(
            from_currency__iso_code=from_currency,
            to_currency__iso_code=to_currency)
    except CurrencyRate.DoesNotExist:
        return _('n/a')
    try:
        history = rate.history.all()[0]
    except IndexError:
        return _('n/a')
    return amount * history.value
1174026
def matches_address(self, address):
        
        if self.address == address:
            return True
        for alias in self.aliases:
            if alias == address:
                return True
        if self._alias_regexp and self._alias_regexp.match(address):
            return True
        return False
668240
function findCurrencySymbol(code, format) {
    var /** @type {?} */ currency = CURRENCIES[code] || {};
    var /** @type {?} */ symbol = currency[0] || code;
    return format === 'wide' ? symbol : currency[1] || symbol;
}
1295497
function getAddress(addressInput) {
  var address = addressInput; // eslint-disable-line
  var result = null; // eslint-disable-line

  if (typeof(address) !== 'string') { throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`); }

  // Missing the 0x prefix
  if (address.substring(0, 2) !== '0x' &&
      address.substring(0, 2) !== 'XE') { address = `0x${address}`; }

  if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
    result = getChecksumAddress(address);

    // It is a checksummed address with a bad checksum
    if (address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) && result !== address) {
      throw new Error('[ethjs-account] invalid address checksum');
    }

  // Maybe ICAP? (we only support direct mode)
  } else if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
    throw new Error('[ethjs-account] ICAP and IBAN addresses, not supported yet..');

    /*
    // It is an ICAP address with a bad checksum
    if (address.substring(2, 4) !== ibanChecksum(address)) {
      throw new Error('invalid address icap checksum');
    }

    result = (new BN(address.substring(4), 36)).toString(16);
    while (result.length < 40) { result = '0' + result; }
    result = getChecksumAddress('0x' + result);
    */
  } else {
    throw new Error(`[ethjs-account] invalid address value ${JSON.stringify(address)} not a valid hex string`);
  }

  return result;
}
606360
public static Predicate<MonetaryAmount> isCurrency(
			CurrencyUnit... currencies) {

		if (Objects.isNull(currencies) || currencies.length == 0) {
			return m -> true;
		}
		Predicate<MonetaryAmount> predicate = null;

		for (CurrencyUnit currencyUnit : currencies) {
			if (Objects.isNull(predicate)) {
				predicate = m -> m.getCurrency().equals(currencyUnit);
			} else {
				predicate = predicate.or(m -> m.getCurrency().equals(
						currencyUnit));
			}
		}
		return predicate;
    }
1196128
def load_currency(self, mnemonic: str):
        
        # , base_currency: str <= ignored for now.
        if self.rate and self.rate.currency == mnemonic:
            # Already loaded.
            return

        app = PriceDbApplication()
        # TODO use the base_currency parameter for the query #33
        symbol = SecuritySymbol("CURRENCY", mnemonic)
        self.rate = app.get_latest_price(symbol)
        if not self.rate:
            raise ValueError(f"No rate found for {mnemonic}!")
738662
def get_supported_currency_choices(api_key):
	
	import stripe

	stripe.api_key = api_key

	account = stripe.Account.retrieve()
	supported_payment_currencies = stripe.CountrySpec.retrieve(account["country"])[
		"supported_payment_currencies"
	]

	return [(currency, currency.upper()) for currency in supported_payment_currencies]
768012
def parseAddress(address):
    
    parts = []
    parser = _AddressParser()
    end = parser(parts, address)
    if end != len(address):
        raise InvalidTrailingBytes()
    return parts[0]
746382
def _parse_address(self, address_string):
        ''''''
        match = utils.match(self.rules, address_string, flags=re.VERBOSE | re.U)
        if match:
            match_as_dict = match.groupdict()
            match_as_dict.update({'country_id': self.country})
            # combine results
            cleaned_dict = self._combine_results(match_as_dict)
            # create object containing results
            return address.Address(**cleaned_dict)

        return False
513353
function getCurrencySymbol(code, format, locale) {
    if (locale === void 0) { locale = 'en'; }
    var currency = getLocaleCurrencies(locale)[code] || CURRENCIES_EN[code] || [];
    var symbolNarrow = currency[1 /* SymbolNarrow */];
    if (format === 'narrow' && typeof symbolNarrow === 'string') {
        return symbolNarrow;
    }
    return currency[0 /* Symbol */] || code;
}
816547
@Override
  public String requestDepositAddress(Currency currency, String... arguments) throws IOException {
    if (currency.equals(Currency.BTC))
      return getQuadrigaCxBitcoinDepositAddress().getDepositAddress();
    else if (currency.equals(Currency.ETH))
      return getQuadrigaCxEtherDepositAddress().getDepositAddress();
    else if (currency.equals(Currency.BCH))
      return getQuadrigaCxBitcoinCachDepositAddress().getDepositAddress();
    else if (currency.equals(Currency.BTG))
      return getQuadrigaCxBitcoinGoldDepositAddress().getDepositAddress();
    else if (currency.equals(Currency.LTC))
      return getQuadrigaCxLitecoinDepositAddress().getDepositAddress();
    else throw new IllegalStateException("unsupported ccy " + currency);
  }
973265
def gpg_key(value):
    
    try:
        return crypto.get_key(value)
    except GPGProblem as e:
        raise ValidateError(str(e))