diff --git a/lbrynet/core/LBRYMetadata.py b/lbrynet/core/LBRYMetadata.py index 2bf31c9c7..9a0ea49c4 100644 --- a/lbrynet/core/LBRYMetadata.py +++ b/lbrynet/core/LBRYMetadata.py @@ -43,10 +43,15 @@ class LBRYFeeValidator(dict): self.address = self[self.currency_symbol]['address'] def _get_amount(self): - if isinstance(self[self.currency_symbol]['amount'], float): - return self[self.currency_symbol]['amount'] + amt = self[self.currency_symbol]['amount'] + if isinstance(amt, float): + return amt else: - return float(self[self.currency_symbol]['amount']) + try: + return float(amt) + except TypeError: + log.error('Failed to convert %s to float', amt) + raise def _verify_fee(self, currency, f): # str in case someone made a claim with a wierd fee diff --git a/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py b/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py index cc924ab7e..b578a2983 100644 --- a/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py +++ b/lbrynet/lbrynet_daemon/LBRYExchangeRateManager.py @@ -131,12 +131,15 @@ class ExchangeRateManager(object): def convert_currency(self, from_currency, to_currency, amount): log.info("Converting %f %s to %s" % (amount, from_currency, to_currency)) + if from_currency == to_currency: + return amount for market in self.market_feeds: if market.rate.currency_pair == (from_currency, to_currency): return amount * market.rate.spot for market in self.market_feeds: if market.rate.currency_pair[0] == from_currency: return self.convert_currency(market.rate.currency_pair[1], to_currency, amount * market.rate.spot) + raise Exception('Unable to convert {} from {} to {}'.format(amount, from_current, to_currency)) def fee_dict(self): return {market: market.rate.as_dict() for market in self.market_feeds}