add lnd grpc

This commit is contained in:
Reckless_Satoshi 2022-01-10 10:47:16 -08:00
parent de66040893
commit e493f22842
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
7 changed files with 35 additions and 14 deletions

2
.gitignore vendored
View File

@ -641,3 +641,5 @@ frontend/static/frontend/main*
# robosats
frontend/static/assets/avatars*
api/lightning/lightning*
api/lightning/googleapis*

View File

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

View File

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

View File

@ -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 = {}

View File

@ -181,7 +181,6 @@ export default class MakerPage extends Component {
onChange={this.handleAmountChange}
/>
<Select
label="Select Payment Currency"
required="true"
defaultValue={this.defaultCurrency}
inputProps={{

View File

@ -34,16 +34,16 @@ export default class TradeBox extends Component {
<Grid container spacing={1}>
<Grid item xs={12} align="center">
<Typography component="body2" variant="body2">
Robots around here usually show commitment
Robosats show commitment to their peers
</Typography>
</Grid>
<Grid item xs={12} align="center">
{this.props.data.isMaker ?
<Typography component="subtitle1" variant="subtitle1">
<Typography color="primary" component="subtitle1" variant="subtitle1">
<b>Lock {pn(this.props.data.bondSatoshis)} Sats to PUBLISH order </b>
</Typography>
:
<Typography component="subtitle1" variant="subtitle1">
<Typography color="primary" component="subtitle1" variant="subtitle1">
<b>Lock {pn(this.props.data.bondSatoshis)} Sats to TAKE the order </b>
</Typography>
}
@ -71,7 +71,7 @@ export default class TradeBox extends Component {
return (
<Grid container spacing={1}>
<Grid item xs={12} align="center">
<Typography component="subtitle1" variant="subtitle1">
<Typography color="primary" component="subtitle1" variant="subtitle1">
<b>Deposit {pn(this.props.data.escrowSatoshis)} Sats as trade collateral </b>
</Typography>
</Grid>
@ -119,7 +119,7 @@ export default class TradeBox extends Component {
<Grid container spacing={1}>
<Grid item xs={12} align="center">
<Typography component="subtitle1" variant="subtitle1">
<b> Your order is public, wait for a taker. </b>
<b> Your order is public. Wait for a taker. </b>
</Typography>
</Grid>
<Grid item xs={12} align="center">
@ -135,7 +135,12 @@ export default class TradeBox extends Component {
return to you (no action needed).</p>
</Typography>
</ListItem>
<Divider/>
<ListItem color="info" align="center">
<Typography color="primary" component="subtitle1" variant="subtitle1" align="center">
🔒 Your maker bond is safely locked
</Typography>
</ListItem>
{/* TODO API sends data for a more confortable wait */}
<Divider/>
<ListItem>
@ -186,7 +191,7 @@ export default class TradeBox extends Component {
<Grid container spacing={1}>
<Grid item xs={12} align="center">
<Typography component="subtitle1" variant="subtitle1">
<Typography color="primary" component="subtitle1" variant="subtitle1">
<b> Submit a LN invoice for {pn(this.props.data.invoiceAmount)} Sats </b>
</Typography>
</Grid>

View File

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