Option for custom rates endpoint #2489
Replies: 7 comments 19 replies
-
@btcmaine you want to be able to specify your own custom endpoint which would return coin prices instead of having to pick one from the list provided by BTCPay? Do I understand you correctly? |
Beta Was this translation helpful? Give feedback.
-
Please provide more details about the UX to do this. Where should it be configurable, what to input where |
Beta Was this translation helpful? Give feedback.
-
This is an underrated requested feature. We cannot use Argentinean, Cuban, Belorussia and Venezuela exchange rate properly because the lack of this. I really need to integrate yadio.io wich is the API for all countries without forex market. |
Beta Was this translation helpful? Give feedback.
-
I'm also looking into this. The use case is that you have provider that guarantees a specific exchange rate. So if you are invoicing 1 euro with BTCPayserver and received XXXXX sats and forward it immediately to that provider, you are guaranteed 1 euro. It is important because if you use the wrong exchange rate and receive 0.99 euro or 1.01 euro, the fiat accounting won't match up. So you need to use the exchange rate which is published by that provider. One way to approach to solve this is to make a provider for localhost. So for example http://localhost:1234/btc_usd would give you the exchange rate for USD. Then a simple python webserver could listen on localhost and be responsible for fetching the exchange rate. This way, you can tell btcpayserver to use the the localhost provider, and then just make sure you have a webserver running on the same server as btcpayserver which is responsible for supplying whatever exchange rate you want. Another approach is to tell BTCPayserver to use coingecko, but MITM the connection. For this to work, you need to set up a webserver that emulates https://api.coingecko.com/api/v3/exchange_rates, but add api.coingecko.com to /etc/hosts so that btcpayserver goes to fetch your spoofed coingecko rates instead of the real ones. You also need to add a self signed SSL certificate that you tell the BTCPayserver host to trust. And of course you need to provide your rates in the same way format that coingecko does. For the MITM approach to work:
|
Beta Was this translation helpful? Give feedback.
-
Hi there :) this return a Json with the current rate that you can use calculate the crypto amount on the fly... you can get the rate of all the available paires in the data source separated by coma (,). best wishes :) |
Beta Was this translation helpful? Give feedback.
-
Implementing a man-in-the-middle approach and emulating https://api.coingecko.com/api/v3/exchange_rates actually worked, but I suspect a C# provider that does a similar thing except without the MITM part is probably a better long term solution. Proof of concept here: https://github.com/amperstrand/mitm-rates I also discovered that btcpayserver will use a cached exchange rate if it fails to fetch an exchange rate. Will this is probably usually a good fail-safe, it might in some cases be preferable to fail safe and refuse to provide invoices if the exchange rate is not available. |
Beta Was this translation helpful? Give feedback.
-
https://github.com/amperstrand/mitm-rates now includes a readme bash script which should mostly just work. It deploys a docker container that can man in the middle the rates between btcpayserver and the following providers:
I have also made a fork of btcpayserver where I have copied the bitbank rates provider but pointed it to https://customrates.local/tickers instead: I would like to ask for feedback from @btcmaine @Zaxounette @IT4Bitcoin @dubdam and others that might find this useful:
The MITM style endpoint works well enough for me, but I might keep working on this if there is interest from others. I think it might be possible to adapt https://github.com/amperstrand/mitm-rates to talk to strike and actually receive a quote with your API key so that the amount of fiat that you are asking from the customer is the amount of fiat that you get. I understand that API limits are a potential issue, but this responsibility would be moved to the custom rates provider. The use case that is not being covered by BTCPayserver as it exists without this is that it is not possible to connect it to a rates provider that will give you a guaranteed conversion rate to fiat which would be useful for shops that do all of their accounting in fiat and just want to add Bitcoin as a payment option. |
Beta Was this translation helpful? Give feedback.
-
I would like to provide my own endpoint for coin prices. I can put a bounty on this feature of 0.01 BTC if done within 30 days as an addon. Would be a great advanced feature for the main release as well.
For the past 3 years I have solved the issue by invoicing the specific BTC amount, but this fix makes many features of BTCPay unusable for me.
Beta Was this translation helpful? Give feedback.
All reactions