From 9827734ab6f3fec2f0c7e74cfe2e05550678182b Mon Sep 17 00:00:00 2001 From: f321x Date: Wed, 8 Apr 2026 10:20:01 +0200 Subject: [PATCH] exchange rate: fix coingecko api The CoinGecko API failed as the Honduran Lempira currency returned null as value, rendering the API unusable: ``` 11.19 | I | exchange_rate.CoinGecko | getting fx quotes for EUR 11.41 | E | exchange_rate.CoinGecko | failed fx quotes: InvalidOperation([]) Traceback (most recent call last): File "/var/home/user/code/vibecoding_vm/electrum/electrum/exchange_rate.py", line 87, in update_safe self._quotes = await self.get_rates(ccy) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/var/home/user/code/vibecoding_vm/electrum/electrum/exchange_rate.py", line 449, in get_rates return dict([(ccy.upper(), to_decimal(d['value'])) ~~~~~~~~~~^^^^^^^^^^^^ File "/var/home/user/code/vibecoding_vm/electrum/electrum/util.py", line 243, in to_decimal return Decimal(str(x)) decimal.InvalidOperation: [] ``` ``` "hnl":{"name":"Honduran Lempira","unit":"L","value":null,"type":"fiat"} ``` --- electrum/exchange_rate.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py index 2f2fc4506..6c7583735 100644 --- a/electrum/exchange_rate.py +++ b/electrum/exchange_rate.py @@ -447,7 +447,7 @@ class CoinGecko(ExchangeBase): async def get_rates(self, ccy): json = await self.get_json('api.coingecko.com', '/api/v3/exchange_rates') return dict([(ccy.upper(), to_decimal(d['value'])) - for ccy, d in json['rates'].items()]) + for ccy, d in json['rates'].items() if d.get('value') is not None]) def history_ccys(self): # CoinGecko seems to have historical data for all ccys it supports