Dockerize dev stack, now fully functional

This commit is contained in:
Reckless_Satoshi 2022-02-09 11:45:11 -08:00
parent ee7786c5c1
commit 96be0d8f80
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
5 changed files with 48 additions and 37 deletions

View File

@ -1,4 +1,4 @@
import grpc, os, hashlib, secrets, json
import grpc, os, hashlib, secrets
from . import lightning_pb2 as lnrpc, lightning_pb2_grpc as lightningstub
from . import invoices_pb2 as invoicesrpc, invoices_pb2_grpc as invoicesstub
from . import router_pb2 as routerrpc, router_pb2_grpc as routerstub
@ -14,8 +14,18 @@ from api.models import LNPayment
# Should work with LND (c-lightning in the future if there are features that deserve the work)
#######
CERT = b64decode(config('LND_CERT_BASE64'))
MACAROON = b64decode(config('LND_MACAROON_BASE64'))
# Read tls.cert from file or .env variable string encoded as base64
try:
CERT = open(os.path.join(config('LND_DIR'),'tls.cert'), 'rb').read()
except:
CERT = b64decode(config('LND_CERT_BASE64'))
# Read macaroon from file or .env variable string encoded as base64
try:
MACAROON = open(os.path.join(config('LND_DIR'), config('MACAROON_path')), 'rb').read()
except:
MACAROON = b64decode(config('LND_MACAROON_BASE64'))
LND_GRPC_HOST = config('LND_GRPC_HOST')
class LNNode():

View File

@ -538,8 +538,11 @@ class Logics():
invoice_expiry=Order.t_to_expire[Order.Status.WFB],
cltv_expiry_secs=BOND_EXPIRY*3600)
except Exception as e:
if 'status = StatusCode.UNAVAILABLE' in str(e):
print(str(e))
if 'failed to connect to all addresses' in str(e):
return False, {'bad_request':'The Lightning Network Daemon (LND) is down. Write in the Telegram group to make sure the staff is aware.'}
if 'wallet locked' in str(e):
return False, {'bad_request':"This is weird, RoboSats' lightning wallet is locked. Check in the Telegram group, maybe the staff has died."}
order.maker_bond = LNPayment.objects.create(
concept = LNPayment.Concepts.MAKEBOND,

View File

@ -41,11 +41,9 @@ def follow_send_payment(lnpayment):
from django.utils import timezone
from datetime import timedelta
from api.lightning.node import LNNode
from api.lightning.node import LNNode, MACAROON
from api.models import LNPayment, Order
MACAROON = b64decode(config('LND_MACAROON_BASE64'))
fee_limit_sat = int(max(lnpayment.num_satoshis * float(config('PROPORTIONAL_ROUTING_FEE_LIMIT')), float(config('MIN_FLAT_ROUTING_FEE_LIMIT')))) # 200 ppm or 10 sats
request = LNNode.routerrpc.SendPaymentRequest(
payment_request=lnpayment.invoice,

View File

@ -6,8 +6,7 @@ services:
restart: always
volumes:
- redisdata:/data
networks:
- redis_network
network_mode: service:tor
backend:
build: .
@ -15,19 +14,16 @@ services:
restart: always
depends_on:
- bitcoind
# - lnd-dev
- lnd
- redis
environment:
DEVELOPMENT: 1
volumes:
- .:/usr/src/robosats
- /mnt/development/database:/usr/src/database
networks:
- nginx_network
- redis_network
- /mnt/development/lnd:/lnd
command: python3 manage.py runserver 0.0.0.0:8000
ports:
- 8000:8000
network_mode: service:tor
frontend:
build: ./frontend
@ -35,9 +31,6 @@ services:
restart: always
volumes:
- ./frontend:/usr/src/frontend
networks:
- nginx_network
- redis_network
clean-orders:
build: .
@ -54,11 +47,12 @@ services:
restart: always
depends_on:
- bitcoind
# - lnd-testnet
- lnd
command: python3 manage.py follow_invoices
volumes:
- .:/usr/src/robosats
- /mnt/development/database:/usr/src/database
network_mode: service:tor
celery:
build: .
@ -66,14 +60,11 @@ services:
restart: always
command: celery -A robosats worker --beat -l info -S django
environment:
REDIS_URL: redis://redis:6379
REDIS_URL: redis://localhost:6379
volumes:
- .:/usr/src/robosats
- /mnt/development/database:/usr/src/database
depends_on:
- redis
networks:
- redis_network
network_mode: service:tor
tor:
build: ./docker/tor
@ -86,8 +77,7 @@ services:
- /mnt/development/tor/data:/var/lib/tor
- /mnt/development/tor/config:/etc/tor
ports:
- '10009'
- '8080'
- 8000:8000
lnd:
build: ./docker/lnd
@ -108,6 +98,7 @@ services:
LOCAL_GROUP_ID: 1000
LND_RPC_PORT: 10009
LND_REST_PORT: 8080
# AUTO_UNLOCK_PWD: ${AUTO_UNLOCK_PWD}
bitcoind:
build: ./docker/bitcoind
@ -125,10 +116,4 @@ services:
- /mnt/development/bitcoin:/home/bitcoin/.bitcoin
volumes:
redisdata:
networks:
nginx_network:
driver: bridge
redis_network:
driver: bridge
redisdata:

View File

@ -5,9 +5,9 @@ Spinning up docker for the first time
```
docker-compose build --no-cache
docker-compose up -d
sudo docker exec -it django-dev python3 manage.py makemigrations
sudo docker exec -it django-dev python3 manage.py migrate
sudo docker exec -it django-dev python3 manage.py createsuperuser
docker exec -it django-dev python3 manage.py makemigrations
docker exec -it django-dev python3 manage.py migrate
docker exec -it django-dev python3 manage.py createsuperuser
docker-compose restart
```
@ -20,7 +20,22 @@ Then monitor in a terminal the Django dev docker service
And the NPM dev docker service
`docker attach npm-dev`
Ready to roll!
Ready to roll! But maybe you also are interested on these:
Unlock or 'create' the lnd node
`docker exec -it lnd-dev lncli unlock`
Create p2wkh addresses
`docker exec -it lnd-dev lncli --network=testnet newaddress p2wkh`
Wallet balance
`docker exec -it lnd-dev lncli --network=testnet walletbalance`
Connect
`docker exec -it lnd-dev lncli --network=testnet connect node_id@ip:9735`
Open channel
`docker exec -it lnd-dev lncli --network=testnet openchannel node_id --local_amt LOCAL_AMT --push_amt PUSH_AMT`
# The harder way
## Django development environment