What is a stub from the lightning grpc documentation? For example, very often in the lightning documentation for their grpc api, you will see the following boilerplate python code:

&gt;&gt;&gt; import codecs, grpc, os
&gt;&gt;&gt; import rpc_pb2 as ln, rpc_pb2_grpc as lnrpc
&gt;&gt;&gt; macaroon = codecs.encode(open('LND_DIR/data/chain/bitcoin/simnet/admin.macaroon', 'rb').read(), 'hex')
&gt;&gt;&gt; os.environ['GRPC_SSL_CIPHER_SUITES'] = 'HIGH+ECDSA'
&gt;&gt;&gt; cert = open('LND_DIR/tls.cert', 'rb').read()
&gt;&gt;&gt; ssl_creds = grpc.ssl_channel_credentials(cert)
&gt;&gt;&gt; channel = grpc.secure_channel('localhost:10009', ssl_creds)
&gt;&gt;&gt; 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
  pass
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.