docs: State example gRPC assumptions, add TLS grpc instructions

This commit is contained in:
Max Fang
2017-08-08 22:30:51 -07:00
committed by Olaoluwa Osuntokun
parent 96a5fdd3ec
commit 9cd1168ebe
3 changed files with 58 additions and 22 deletions

View File

@@ -44,7 +44,7 @@ Python gRPC.
#### Imports and Client
Everytime you use Python gRPC, you will have to import the generated rpc modeuls
Everytime you use Python gRPC, you will have to import the generated rpc modules
and set up a channel and stub to your connect to your `lnd` node:
```python
@@ -52,13 +52,19 @@ import rpc_pb2 as ln
import rpc_pb2_grpc as lnrpc
import grpc
channel = grpc.insecure_channel('localhost:10009')
# Lnd cert is at ~/.lnd/tls.cert on Linux and
# ~/Library/Application Support/Lnd/tls.cert on Mac
cert = open('~/.lnd/tls.cert').read()
creds = grpc.ssl_channel_credentials(cert)
channel = grpc.secure_channel('localhost:10009', creds)
stub = lnrpc.LightningStub(channel)
```
### Examples
Let's walk through some examples of Python gRPC clients.
Let's walk through some examples of Python gRPC clients. These examples assume
that you have at least two `lnd` nodes running, the RPC location of one of which
is at the default `localhost:10009`, with an open channel between the two nodes.
#### Simple RPC
@@ -75,8 +81,19 @@ request = ln.InvoiceSubscription()
for invoice in stub.SubscribeInvoices(request);
print invoice
```
Now, create an invoice for your node at `localhost:10009` and send a payment to
it. Your Python console should display the details of the recently satisfied
Now, create an invoice for your node at `localhost:10009`and send a payment to
it from another node.
```bash
$ lncli addinvoice --value=100
{
"r_hash": <R_HASH>,
"pay_req": <PAY_REQ>
}
$ lncli sendpayment --pay_req=<PAY_REQ>
```
Your Python console should now display the details of the recently satisfied
invoice.
#### Bidirectional-streaming RPC