From 9bf4bbb64238b45c23f1b6a24183a7828caa468f Mon Sep 17 00:00:00 2001 From: Adrien Emery Date: Thu, 22 Mar 2018 22:28:11 -0700 Subject: [PATCH] docs: encode macaroon in python grpc example Previously `decode` was used incorrectly. --- docs/grpc/python.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/grpc/python.md b/docs/grpc/python.md index 86718334..3728c5ca 100644 --- a/docs/grpc/python.md +++ b/docs/grpc/python.md @@ -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