mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-14 03:16:24 +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'
|
# To disable auto unlock, comment out 'wallet-unlock-password-file=/tmp/pwd' from 'docker/lnd/lnd.conf'
|
||||||
AUTO_UNLOCK_PWD='1234'
|
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.
|
# 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
|
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_choices = [(int(val), label) for val, label in list(currency_dict.items())]
|
||||||
|
|
||||||
currency = models.PositiveSmallIntegerField(choices=currency_choices, null=False, unique=True)
|
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)
|
timestamp = models.DateTimeField(auto_now_add=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
|
20
api/tasks.py
20
api/tasks.py
@ -106,17 +106,23 @@ def cache_market():
|
|||||||
|
|
||||||
from django.utils import timezone
|
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 = {}
|
results = {}
|
||||||
for val in Currency.currency_dict:
|
for i in range(len(Currency.currency_dict.values())): # currecies are indexed starting at 1 (USD)
|
||||||
rate = exchange_rates[int(val)-1] # currecies are indexed starting at 1 (USD)
|
|
||||||
results[val] = {Currency.currency_dict[val], rate}
|
rate = exchange_rates[i]
|
||||||
if str(rate) == 'nan': continue # Do not update if no new rate was found
|
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
|
# Create / Update database cached prices
|
||||||
|
currency_key = list(Currency.currency_dict.keys())[i]
|
||||||
Currency.objects.update_or_create(
|
Currency.objects.update_or_create(
|
||||||
id = int(val),
|
id = int(currency_key),
|
||||||
currency = int(val),
|
currency = int(currency_key),
|
||||||
# if there is a Cached market prices matching that id, it updates it with defaults below
|
# if there is a Cached market prices matching that id, it updates it with defaults below
|
||||||
defaults = {
|
defaults = {
|
||||||
'exchange_rate': float(rate),
|
'exchange_rate': float(rate),
|
||||||
|
@ -60,7 +60,7 @@ def get_lnd_version():
|
|||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# If not dockerized, and LND is local, read from CLI
|
# If not dockerized and LND is local, read from CLI
|
||||||
try:
|
try:
|
||||||
stream = os.popen('lnd --version')
|
stream = os.popen('lnd --version')
|
||||||
lnd_version = stream.read()[:-1]
|
lnd_version = stream.read()[:-1]
|
||||||
|
@ -34,5 +34,6 @@ export default function getFlags(code){
|
|||||||
if(code == 'UYU') return '🇺🇾';
|
if(code == 'UYU') return '🇺🇾';
|
||||||
if(code == 'PYG') return '🇵🇾';
|
if(code == 'PYG') return '🇵🇾';
|
||||||
if(code == 'BOB') return '🇧🇴';
|
if(code == 'BOB') return '🇧🇴';
|
||||||
|
if(code == 'BTC') return '₿';
|
||||||
return '🏳';
|
return '🏳';
|
||||||
};
|
};
|
@ -34,5 +34,6 @@
|
|||||||
"33":"PEN",
|
"33":"PEN",
|
||||||
"34":"UYU",
|
"34":"UYU",
|
||||||
"35":"PYG",
|
"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 exec -it django-dev python3 manage.py createsuperuser
|
||||||
docker-compose restart
|
docker-compose restart
|
||||||
```
|
```
|
||||||
|
Copy the `.env-sample` file into `.env` and check the settings are of your liking.
|
||||||
|
|
||||||
Spinning up any other time:
|
Spinning up any other time:
|
||||||
`docker-compose up -d`
|
`docker-compose up -d`
|
||||||
|
Loading…
Reference in New Issue
Block a user