From 0b540956fb02078a1a734e69f6f5038334fb260d Mon Sep 17 00:00:00 2001 From: Joel Lehtonen Date: Tue, 6 Dec 2022 02:19:12 +0200 Subject: [PATCH] exchange_rate: "BTC" to "BTC" rate is not guaranteed to be present Which ccy rates are available depends on the configured exchange (config key use_exchange) and the configured currency (config key currency). Only for some exchanges, the fx.ccy-BTC fx rate is available (depends on the ExchangeBase.get_rates implementation). As they say, for hodlers 1 BTC = 1 BTC. --- electrum/exchange_rate.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/electrum/exchange_rate.py b/electrum/exchange_rate.py index a47923660..260e9770b 100644 --- a/electrum/exchange_rate.py +++ b/electrum/exchange_rate.py @@ -176,6 +176,8 @@ class ExchangeBase(Logger): def get_cached_spot_quote(self, ccy: str) -> Decimal: """Returns the cached exchange rate as a Decimal""" + if ccy == 'BTC': + return Decimal(1) rate = self._quotes.get(ccy) if rate is None: return Decimal('NaN')