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 # robosats
frontend/static/assets/avatars* frontend/static/assets/avatars*
api/lightning/lightning*
api/lightning/googleapis*

View File

@ -1,5 +1,6 @@
# import codecs, grpc, os import codecs, grpc, os
# import lightning_pb2 as lnrpc, lightning_pb2_grpc as lightningstub from . import lightning_pb2 as ln
from . import lightning_pb2_grpc as lnrpc
from datetime import timedelta from datetime import timedelta
from django.utils import timezone from django.utils import timezone

View File

@ -1,6 +1,6 @@
from datetime import timedelta from datetime import timedelta
from django.utils import timezone from django.utils import timezone
from .lightning import LNNode from .lightning.node import LNNode
from .models import Order, LNPayment, MarketTick, User from .models import Order, LNPayment, MarketTick, User
from decouple import config from decouple import config

View File

@ -22,6 +22,8 @@ from datetime import timedelta
from django.utils import timezone from django.utils import timezone
from decouple import config from decouple import config
import ring
EXP_MAKER_BOND_INVOICE = int(config('EXP_MAKER_BOND_INVOICE')) EXP_MAKER_BOND_INVOICE = int(config('EXP_MAKER_BOND_INVOICE'))
FEE = float(config('FEE')) FEE = float(config('FEE'))
@ -388,6 +390,9 @@ class BookView(ListAPIView):
class InfoView(ListAPIView): class InfoView(ListAPIView):
storage = {}
@ring.dict(storage, expire=60) # keeps in cache for 60 seconds
def get(self, request): def get(self, request):
context = {} context = {}

View File

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

View File

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

View File

@ -6,8 +6,6 @@
### Install virtual environments ### Install virtual environments
``` ```
pip install virtualenvwrapper pip install virtualenvwrapper
pip install python-decouple
pip install ring
``` ```
### Add to .bashrc ### Add to .bashrc
@ -45,9 +43,20 @@ python3 manage.py migrate
python3 manage.py runserver python3 manage.py runserver
``` ```
### Install python dependencies ### Install other python dependencies
``` ```
pip install robohash 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 ## React development environment