docs: encode macaroon in python grpc example

Previously `decode` was used incorrectly.
This commit is contained in:
Adrien Emery 2018-03-22 22:28:11 -07:00
parent daf542cf89
commit 9bf4bbb642

@ -138,11 +138,13 @@ This example will send a payment of 100 satoshis every 2 seconds.
To authenticate using macaroons you need to include the macaroon in the metadata of the request.
```python
import codecs
# Lnd admin macaroon is at ~/.lnd/admin.macaroon on Linux and
# ~/Library/Application Support/Lnd/admin.macaroon on Mac
with open('~/.lnd/admin.macaroon', 'rb') as f:
with open(os.path.expanduser('~/.lnd/admin.macaroon'), 'rb') as f:
macaroon_bytes = f.read()
macaroon = codecs.decode(macaroon_bytes, 'hex')
macaroon = codecs.encode(macaroon_bytes, 'hex')
```
The simplest approach to use the macaroon is to include the metadata in each request as shown below.
@ -156,7 +158,7 @@ However, this can get tiresome to do for each request, so to avoid explicitly in
```python
def metadata_callback(context, callback):
# for more info see grpc docs
callback([('macaroon', self.macaroon)], None)
callback([('macaroon', macaroon)], None)
# build ssl credentials using the cert the same as before