Page MenuHomePhabricator

[electrum] fix historical fiat prices via CoinGecko
ClosedPublic

Authored by PiRK on Apr 1 2024, 08:27.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABCa6ab58f19c2d: [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).

Diff Detail

Repository
rABC Bitcoin ABC
Branch
coingecko_price_apiwq
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 28231
Build 56007: Build Diffelectrum-tests
Build 56006: arc lint + arc unit