feat: add rate endpoint per currency (#2641)

this is already used and implemented by tpos, lnurlp and i probably need
it for satspay aswell
This commit is contained in:
dni ⚡ 2024-08-20 11:52:39 +02:00 committed by GitHub
parent 1900cf9aa4
commit 65ecca2507
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -33,6 +33,7 @@ from lnbits.settings import settings
from lnbits.utils.exchange_rates import (
allowed_currencies,
fiat_amount_as_satoshis,
get_fiat_rate_satoshis,
satoshis_amount_as_fiat,
)
@ -200,6 +201,12 @@ async def api_perform_lnurlauth(
return ""
@api_router.get("/api/v1/rate/{currency}")
async def api_check_fiat_rate(currency: str) -> Dict[str, float]:
rate = await get_fiat_rate_satoshis(currency)
return {"rate": rate}
@api_router.get("/api/v1/currencies")
async def api_list_currencies_available() -> List[str]:
return allowed_currencies()