From e493f2284299506fafdd92f3d7b940a2b6f58f63 Mon Sep 17 00:00:00 2001
From: Reckless_Satoshi
Date: Mon, 10 Jan 2022 10:47:16 -0800
Subject: [PATCH] add lnd grpc
---
.gitignore | 2 ++
api/{lightning.py => lightning/node.py} | 5 +++--
api/logics.py | 2 +-
api/views.py | 5 +++++
frontend/src/components/MakerPage.js | 1 -
frontend/src/components/TradeBox.js | 19 ++++++++++++-------
setup.md | 15 ++++++++++++---
7 files changed, 35 insertions(+), 14 deletions(-)
rename api/{lightning.py => lightning/node.py} (97%)
diff --git a/.gitignore b/.gitignore
index 2acb0130..bb835b12 100755
--- a/.gitignore
+++ b/.gitignore
@@ -641,3 +641,5 @@ frontend/static/frontend/main*
# robosats
frontend/static/assets/avatars*
+api/lightning/lightning*
+api/lightning/googleapis*
diff --git a/api/lightning.py b/api/lightning/node.py
similarity index 97%
rename from api/lightning.py
rename to api/lightning/node.py
index 295a3085..324e250e 100644
--- a/api/lightning.py
+++ b/api/lightning/node.py
@@ -1,5 +1,6 @@
-# import codecs, grpc, os
-# import lightning_pb2 as lnrpc, lightning_pb2_grpc as lightningstub
+import codecs, grpc, os
+from . import lightning_pb2 as ln
+from . import lightning_pb2_grpc as lnrpc
from datetime import timedelta
from django.utils import timezone
diff --git a/api/logics.py b/api/logics.py
index 7cdc48d7..7b074a4e 100644
--- a/api/logics.py
+++ b/api/logics.py
@@ -1,6 +1,6 @@
from datetime import timedelta
from django.utils import timezone
-from .lightning import LNNode
+from .lightning.node import LNNode
from .models import Order, LNPayment, MarketTick, User
from decouple import config
diff --git a/api/views.py b/api/views.py
index f92c5e7a..fcdf9865 100644
--- a/api/views.py
+++ b/api/views.py
@@ -22,6 +22,8 @@ from datetime import timedelta
from django.utils import timezone
from decouple import config
+import ring
+
EXP_MAKER_BOND_INVOICE = int(config('EXP_MAKER_BOND_INVOICE'))
FEE = float(config('FEE'))
@@ -388,6 +390,9 @@ class BookView(ListAPIView):
class InfoView(ListAPIView):
+ storage = {}
+
+ @ring.dict(storage, expire=60) # keeps in cache for 60 seconds
def get(self, request):
context = {}
diff --git a/frontend/src/components/MakerPage.js b/frontend/src/components/MakerPage.js
index a89fd95f..2abc6e36 100644
--- a/frontend/src/components/MakerPage.js
+++ b/frontend/src/components/MakerPage.js
@@ -181,7 +181,6 @@ export default class MakerPage extends Component {
onChange={this.handleAmountChange}
/>
-
+
+
+
+ 🔒 Your maker bond is safely locked
+
+
{/* TODO API sends data for a more confortable wait */}
@@ -186,7 +191,7 @@ export default class TradeBox extends Component {
-
+
Submit a LN invoice for {pn(this.props.data.invoiceAmount)} Sats
diff --git a/setup.md b/setup.md
index a96618fe..e601ec9d 100644
--- a/setup.md
+++ b/setup.md
@@ -6,8 +6,6 @@
### Install virtual environments
```
pip install virtualenvwrapper
-pip install python-decouple
-pip install ring
```
### Add to .bashrc
@@ -45,9 +43,20 @@ python3 manage.py migrate
python3 manage.py runserver
```
-### Install python dependencies
+### Install other python dependencies
```
pip install robohash
+pip install python-decouple
+pip install ring
+```
+
+### Install LND python dependencies
+```
+cd api/lightning
+pip install grpcio grpcio-tools googleapis-common-protos
+git clone https://github.com/googleapis/googleapis.git
+curl -o lightning.proto -s https://raw.githubusercontent.com/lightningnetwork/lnd/master/lnrpc/lightning.proto
+python3 -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. lightning.proto
```
## React development environment