For example, very often in the lightning documentation for their grpc api, you will see the following boilerplate python code:

>>> import codecs, grpc, os
>>> import rpc_pb2 as ln, rpc_pb2_grpc as lnrpc
>>> macaroon = codecs.encode(open('LND_DIR/data/chain/bitcoin/simnet/admin.macaroon', 'rb').read(), 'hex')
>>> cert = open('LND_DIR/tls.cert', 'rb').read()
>>> ssl_creds = grpc.ssl_channel_credentials(cert)
>>> channel = grpc.secure_channel('localhost:10009', ssl_creds)
>>> stub = lnrpc.LightningStub(channel)

I am curious, what is an LightningStub? Looking a bit deeper into rpc_pb2_grpc, which seems to be a generated file you'll find the following ( lacking ) bit of documentation:

class LightningStub(object):
  # missing associated documentation comment in .proto file

1 Answer 1


It turns out, it is grpc nomenclature. According to the documentation at grpc.io:

gRPC users typically call these APIs on the client side and implement the corresponding API on the server side.


On the client side, the client has a local object known as stub (for some languages, the preferred term is client) that implements the same methods as the service.

Which pretty much means using grpc on the client side looks like you're interacting with an object that performs the operations locally - when in reality that object ( known as a stub ) is making calls to the server asking it to perform certain actions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.