mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 02:46:28 +00:00
Add BTC (rBTC, wBTC, swaps...). Fix setup guide and env-sample.
This commit is contained in:
parent
e8b28d794d
commit
1e0bd51f1f
@ -13,6 +13,8 @@ LND_MACAROON_BASE64='AgEDbG5kAvgBAwoQsyI+PK+fyb7F2UyTeZ4seRIBMBoWCgdhZGRyZXNzEgR
|
||||
# To disable auto unlock, comment out 'wallet-unlock-password-file=/tmp/pwd' from 'docker/lnd/lnd.conf'
|
||||
AUTO_UNLOCK_PWD='1234'
|
||||
|
||||
REDIS_URL='redis://localhost:6379/1'
|
||||
|
||||
# List of market price public APIs. If the currency is available in more than 1 API, will use median price.
|
||||
MARKET_PRICE_APIS = https://blockchain.info/ticker, https://api.yadio.io/exrates/BTC
|
||||
|
||||
|
@ -24,7 +24,7 @@ class Currency(models.Model):
|
||||
currency_choices = [(int(val), label) for val, label in list(currency_dict.items())]
|
||||
|
||||
currency = models.PositiveSmallIntegerField(choices=currency_choices, null=False, unique=True)
|
||||
exchange_rate = models.DecimalField(max_digits=16, decimal_places=5, default=None, null=True, validators=[MinValueValidator(0)])
|
||||
exchange_rate = models.DecimalField(max_digits=20, decimal_places=8, default=None, null=True, validators=[MinValueValidator(0)])
|
||||
timestamp = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
def __str__(self):
|
||||
|
20
api/tasks.py
20
api/tasks.py
@ -106,17 +106,23 @@ def cache_market():
|
||||
|
||||
from django.utils import timezone
|
||||
|
||||
exchange_rates = get_exchange_rates(list(Currency.currency_dict.values()))
|
||||
currency_codes = list(Currency.currency_dict.values())
|
||||
exchange_rates = get_exchange_rates(currency_codes)
|
||||
|
||||
results = {}
|
||||
for val in Currency.currency_dict:
|
||||
rate = exchange_rates[int(val)-1] # currecies are indexed starting at 1 (USD)
|
||||
results[val] = {Currency.currency_dict[val], rate}
|
||||
if str(rate) == 'nan': continue # Do not update if no new rate was found
|
||||
for i in range(len(Currency.currency_dict.values())): # currecies are indexed starting at 1 (USD)
|
||||
|
||||
rate = exchange_rates[i]
|
||||
results[i] = {currency_codes[i], rate}
|
||||
|
||||
# Do not update if no new rate was found
|
||||
if str(rate) == 'nan': continue
|
||||
|
||||
# Create / Update database cached prices
|
||||
currency_key = list(Currency.currency_dict.keys())[i]
|
||||
Currency.objects.update_or_create(
|
||||
id = int(val),
|
||||
currency = int(val),
|
||||
id = int(currency_key),
|
||||
currency = int(currency_key),
|
||||
# if there is a Cached market prices matching that id, it updates it with defaults below
|
||||
defaults = {
|
||||
'exchange_rate': float(rate),
|
||||
|
@ -60,7 +60,7 @@ def get_lnd_version():
|
||||
except:
|
||||
pass
|
||||
|
||||
# If not dockerized, and LND is local, read from CLI
|
||||
# If not dockerized and LND is local, read from CLI
|
||||
try:
|
||||
stream = os.popen('lnd --version')
|
||||
lnd_version = stream.read()[:-1]
|
||||
|
@ -34,5 +34,6 @@ export default function getFlags(code){
|
||||
if(code == 'UYU') return '🇺🇾';
|
||||
if(code == 'PYG') return '🇵🇾';
|
||||
if(code == 'BOB') return '🇧🇴';
|
||||
if(code == 'BTC') return '₿';
|
||||
return '🏳';
|
||||
};
|
@ -34,5 +34,6 @@
|
||||
"33":"PEN",
|
||||
"34":"UYU",
|
||||
"35":"PYG",
|
||||
"36":"BOB"
|
||||
"36":"BOB",
|
||||
"1000":"BTC"
|
||||
}
|
File diff suppressed because one or more lines are too long
1
setup.md
1
setup.md
@ -10,6 +10,7 @@ docker exec -it django-dev python3 manage.py migrate
|
||||
docker exec -it django-dev python3 manage.py createsuperuser
|
||||
docker-compose restart
|
||||
```
|
||||
Copy the `.env-sample` file into `.env` and check the settings are of your liking.
|
||||
|
||||
Spinning up any other time:
|
||||
`docker-compose up -d`
|
||||
|
Loading…
Reference in New Issue
Block a user