HomePhabricator

[electrum] fix fiat price cache not being created if it does not already exist

Description

[electrum] fix fiat price cache not being created if it does not already exist

Summary:
The read_historcial_rates method returned None, so the cached_history var in get_historical_rates_safe was not properly initialized to an empty dict, and therefore cached_history.update(new_history) would raise (with the exception caught and ignored).
This makes cached_history is an empty dict {} if the file does not already exist.

Similar fix to commit a42cdb6 electroncash#2898

Test Plan:
Run the application ./electrum-abc, go to Tools > Preferences > Fiat select a fiat currency that was never selected before, check the Show history rates checkbox.
Check that a new file was created for this currency in ~/.electrum-abc/cache and has a year worth of data.

Close Electrum ABC, edit the cache file (remove the last few entries) and save it, make sure the cached data file is older than 24 hours (touch -d "2 days ago" ~/.electrum-abc/cache/CoinGecko_GBP) so that the API call is triggered on the next restart of the application. Restart Electrum ABC, check that the cache file get updated with the previously removed entries).

Reviewers: #bitcoin_abc, bytesofman

Reviewed By: #bitcoin_abc, bytesofman

Differential Revision: https://reviews.bitcoinabc.org/D16663

Details

Provenance
PiRKAuthored on Aug 20 2024, 09:28
PiRKPushed on Aug 26 2024, 19:01
Reviewer
Restricted Project
Differential Revision
D16663: [electrum] fix fiat price cache not being created if it does not already exist
Parents
rABC2e0146732b59: [electrum] bump mnemonic dependency to >=0.21
Branches
Unknown
Tags
Unknown