Add BTC (rBTC, wBTC, swaps...). Fix setup guide and env-sample.

This commit is contained in:
Reckless_Satoshi 2022-02-16 14:02:21 -08:00
parent e8b28d794d
commit 1e0bd51f1f
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
8 changed files with 22 additions and 11 deletions

View File

@ -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

View File

@ -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):

View File

@ -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),

View File

@ -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]

View File

@ -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 '🏳';
};

View File

@ -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

View File

@ -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`