docs: update python grpc examples to use python 3 syntax
This commit is contained in:
1 parent
55e882c058
commit
5ef0d4c8b9
1 file changed
+4
-4
+4
-4
@@ -55,7 +55,7 @@ import os
|
|||||||
|
|
||||||
# Lnd cert is at ~/.lnd/tls.cert on Linux and
|
# Lnd cert is at ~/.lnd/tls.cert on Linux and
|
||||||
# ~/Library/Application Support/Lnd/tls.cert on Mac
|
# ~/Library/Application Support/Lnd/tls.cert on Mac
|
||||||
cert = open(os.path.expanduser('~/.lnd/tls.cert')).read()
|
cert = open(os.path.expanduser('~/.lnd/tls.cert'), 'rb').read()
|
||||||
creds = grpc.ssl_channel_credentials(cert)
|
creds = grpc.ssl_channel_credentials(cert)
|
||||||
channel = grpc.secure_channel('localhost:10009', creds)
|
channel = grpc.secure_channel('localhost:10009', creds)
|
||||||
stub = lnrpc.LightningStub(channel)
|
stub = lnrpc.LightningStub(channel)
|
||||||
@@ -72,7 +72,7 @@ is at the default `localhost:10009`, with an open channel between the two nodes.
|
|||||||
```python
|
```python
|
||||||
# Retrieve and display the wallet balance
|
# Retrieve and display the wallet balance
|
||||||
response = stub.WalletBalance(ln.WalletBalanceRequest(witness_only=True))
|
response = stub.WalletBalance(ln.WalletBalanceRequest(witness_only=True))
|
||||||
print response.total_balance
|
print(response.total_balance)
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Response-streaming RPC
|
#### Response-streaming RPC
|
||||||
@@ -80,7 +80,7 @@ print response.total_balance
|
|||||||
```python
|
```python
|
||||||
request = ln.InvoiceSubscription()
|
request = ln.InvoiceSubscription()
|
||||||
for invoice in stub.SubscribeInvoices(request):
|
for invoice in stub.SubscribeInvoices(request):
|
||||||
print invoice
|
print(invoice)
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, create an invoice for your node at `localhost:10009`and send a payment to
|
Now, create an invoice for your node at `localhost:10009`and send a payment to
|
||||||
@@ -124,7 +124,7 @@ dest_bytes = codecs.decode(dest_hex, 'hex')
|
|||||||
request_iterable = request_generator(dest=dest_bytes, amt=100)
|
request_iterable = request_generator(dest=dest_bytes, amt=100)
|
||||||
|
|
||||||
for payment in stub.SendPayment(request_iterable):
|
for payment in stub.SendPayment(request_iterable):
|
||||||
print payment
|
print(payment)
|
||||||
```
|
```
|
||||||
This example will send a payment of 100 satoshis every 2 seconds.
|
This example will send a payment of 100 satoshis every 2 seconds.
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user