Skip to content

Instantly share code, notes, and snippets.

@timothyylim
Created November 11, 2021 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothyylim/34dfab97aaba82bae77b7820676e6f98 to your computer and use it in GitHub Desktop.
Save timothyylim/34dfab97aaba82bae77b7820676e6f98 to your computer and use it in GitHub Desktop.
import lightning_pb2 as ln
import lightning_pb2_grpc as lnrpc
import codecs
import grpc
import os
# Due to updated ECDSA generated tls.cert we need to let gprc know that
# we need to use that cipher suite otherwise there will be a handhsake
# error when we communicate with the lnd rpc server.
os.environ["GRPC_SSL_CIPHER_SUITES"] = 'HIGH+ECDSA'
macaroon = codecs.encode(open('./admin.macaroon', 'rb').read(), 'hex')
print(macaroon)
cert = open(os.path.expanduser('./tls.cert'), 'rb').read()
creds = grpc.ssl_channel_credentials(cert)
print(creds)
channel = grpc.secure_channel('promisebot-node-1.t.voltageapp.io', creds)
stub = lnrpc.LightningStub(channel)
request = ln.Invoice(value=1000)
response = stub.AddInvoice(request, metadata=[('macaroon', macaroon)])
print(response)
@timothyylim
Copy link
Author

Returns the error:

Traceback (most recent call last):
  File "/Users/timothylim/repos/promisebot-server/lnode.py", line 22, in <module>
    response = stub.AddInvoice(request, metadata=[('macaroon', macaroon)])
  File "/Users/timothylim/repos/promisebot-server/lnd/lib/python3.9/site-packages/grpc/_channel.py", line 946, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/Users/timothylim/repos/promisebot-server/lnd/lib/python3.9/site-packages/grpc/_channel.py", line 849, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
	status = StatusCode.UNIMPLEMENTED
	details = "Received http2 header with status: 404"
	debug_error_string = "{"created":"@1636639822.983026000","description":"Received http2 :status header with non-200 OK status","file":"src/core/ext/filters/http/client/http_client_filter.cc","file_line":134,"grpc_message":"Received http2 header with status: 404","grpc_status":12,"value":"404"}"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment