HomePhabricator

[electrum] fix historical fiat prices via CoinGecko

Description

[electrum] fix historical fiat prices via CoinGecko

Summary:
CoinGecko changed the rules for using their API:

{"error":{"status":{"timestamp":"2024-03-30T07:22:29.427+00:00","error_code":10012,"error_message":"Your request exceeds the allowed time range. Public API users are limited to querying historical data within the past 365 days. Upgrade to a paid plan to enjoy full historical data access: https://www.coingecko.com/en/api/pricing. "}}}

We can no longer fetch the entire price history for a fiat currency. So limit the call to the maximum allowed 365 days, and don't overwrite the existing cached data, update it.

Consequences:

  • For existing users who run Electrum ABC at least once a year, the previous behavior is preserved, they will keep seeing a complete fiat history for previously cached fiat currencies
  • User running Electrum ABC less often than once a year will now have gaps in the historical prices
  • New users or existing users selecting a new fiat currency will initially no longer see historical prices older than 365 days prior to activating the feature or selecting the currency.

Test Plan:
Make sure the cached data file is older than 24 hours, to trigger the API call

touch -d "2 days ago" ~/.electrum-abc/cache/CoinGecko_GBP

Start Electrum ABC with historical fiat prices enabled on a wallet with both recent transactions and transactions older than one year, check that both the recent transactions and the old transactions show the fiat balance (iff the historical fiat prices were already enabled prior to CoinGecko changing the rules).

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

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

Details

Provenance
PiRKAuthored on Apr 1 2024, 07:41
PiRKPushed on Apr 1 2024, 17:40
Reviewer
Restricted Project
Differential Revision
D15841: [electrum] fix historical fiat prices via CoinGecko
Parents
rABC7c07351d2e58: [Cashtab] Parse mint txs
Branches
Unknown
Tags
Unknown