2022-01-07 22:46:30 +00:00
|
|
|
|
2022-01-11 14:36:43 +00:00
|
|
|
import requests, ring, os
|
2022-01-07 22:46:30 +00:00
|
|
|
from decouple import config
|
|
|
|
|
2022-01-11 14:36:43 +00:00
|
|
|
market_cache = {}
|
2022-01-10 01:12:58 +00:00
|
|
|
|
2022-01-11 14:36:43 +00:00
|
|
|
@ring.dict(market_cache, expire=30) #keeps in cache for 30 seconds
|
2022-01-07 22:46:30 +00:00
|
|
|
def get_exchange_rate(currency):
|
|
|
|
# TODO Add fallback Public APIs and error handling
|
|
|
|
# Think about polling price data in a different way (e.g. store locally every t seconds)
|
|
|
|
|
|
|
|
market_prices = requests.get(config('MARKET_PRICE_API')).json()
|
|
|
|
exchange_rate = float(market_prices[currency]['last'])
|
|
|
|
|
2022-01-11 14:36:43 +00:00
|
|
|
return exchange_rate
|
|
|
|
|
|
|
|
lnd_v_cache = {}
|
|
|
|
|
|
|
|
@ring.dict(lnd_v_cache, expire=3600) #keeps in cache for 3600 seconds
|
|
|
|
def get_lnd_version():
|
|
|
|
|
|
|
|
stream = os.popen('lnd --version')
|
|
|
|
lnd_version = stream.read()[:-1]
|
|
|
|
|
|
|
|
return lnd_version
|
|
|
|
|
|
|
|
robosats_commit_cache = {}
|
|
|
|
|
|
|
|
@ring.dict(robosats_commit_cache, expire=3600)
|
|
|
|
def get_commit_robosats():
|
|
|
|
|
|
|
|
stream = os.popen('git log -n 1 --pretty=format:"%H"')
|
|
|
|
lnd_version = stream.read()
|
|
|
|
|
|
|
|
return lnd_version
|
|
|
|
|