currencyrate: new rust plugin to provide the currencyconvert API
#8842
+2,346
−1,042
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #8825
I described my approach for doing API calls in the issue but i repeat it here:
I added 7 default price sources of which one (bitstamp) never seems to work (HTTP 403) when using a tor proxy. Out of these 6-7
CONVERT_SOURCES_COUNT(3) are chosen at random whencurrencyconvertis called, unless we are inside the cache time window.I like this approach because:
CACHE_DURATIONS_SECS(10)CONVERT_SOURCES_COUNT(3) sources aslong as enough are configured and return a valid resultCACHE_DURATIONS_SECS(10)CONVERT_SOURCES_COUNT(3)What i don't like about it:
SOURCE_TIMEOUT_SECS(5) * n (where n is >1 if any of the initial 3 fail but is at most thenumber of sources configured - 2) and i expect this to be called right before doing a payment, delaying it by up to that much. If it's only used for recurring payments i would assume response time is not that critical, so i found this acceptableTo always instantly have a response, we would either have to look for API endpoints that return all currency pairs and cache them or ask the user what currency they are interested in or use historic user queries to know wich currency to track.
I also tried my best to be compatible with the python version of
currencyrate, meaning i left the options and rpc methods the same, except for themsatsuffix. But i can see if you want to break this since the option names inside CLN are a little under-descriptive (add-source,disable-source). I also added support for positional members when usingadd-source(kraken needs it).Please let me know:
are you happy with the API call approach or do you prefer a different one, if so please let me know what you value more response time, data age, API rate limit etc.
where and how you want this documented
should i mark the tests as flaky since they make real-live API calls and they can easily fail if one of them doesn't return a valid result
The changelog has been updated in the relevant commit(s) according to the guidelines.
Tests have been added or modified to reflect the changes.
Documentation has been reviewed and updated as needed.
Related issues have been listed and linked, including any that this PR closes.
Important All PRs must consider how to reverse any persistent changes for
tools/lightning-downgrade