Skip to main content

impgrpc

A python grpc client for Impervious Network ⚡⚡⚡

This is a wrapper around the default grpc interface that handles setting up credentials (including macaroons). An async client is also available to do fun async stuff like listening for invoices in the background.

Dependencies

  • Python 3.6+
  • Working LND lightning node, take note of its ip address.
  • Copy your admin.macaroon and tls.cert files from your node to a directoy on your machine.

Installation

pip install imp-grpc-client

Environment Variables

These environment variables are only used when testing node connectivity and/or correct module installation from the command line. This library is primarily used through Python scripting.

export CRED_PATH=/path/to/macaroon/and/tls/cert
export LND_NODE_IP=192.168.1.xx

Basic Usage

The api mirrors the underlying lnd grpc api (http://api.lightning.community/) but methods will be in pep8 style. ie. .GetInfo() becomes .get_info().

</code></pre>
<h3 id="user-content-specifying-macarooncert-files">Specifying Macaroon/Cert files<a href="#user-content-specifying-macarooncert-files" aria-label="Link to heading 'Specifying Macaroon/Cert files'" data-heading-content="Specifying Macaroon/Cert files" class="anchor"></a></h3>
<p>By default the client will attempt to lookup the <code>readonly.macaron</code> and <code>tls.cert</code> files in the mainnet directory.
However if you want to specify a different macaroon or different path you can pass in the filepath explicitly.</p>
<pre><code class="language-python">lnd = LNDClient(
    macaroon_filepath='~/.lnd/invoice.macaroon', 
    cert_filepath='path/to/tls.cert'
)

Generating LND Proto Files

virtualenv lnd
source lnd/bin/activate
pip install grpcio grpcio-tools googleapis-common-protos sh
git clone https://github.com/lightningnetwork/lnd.git
mkdir genprotos
git clone https://github.com/googleapis/googleapis.git
from pathlib import Path
import shutil
import sh

for proto in list(Path("../imp-releases/proto").rglob("*.proto")):
    shutil.copy(proto, Path.cwd().joinpath("impgrpc/compiled"))

protos = list(Path(".").joinpath("impgrpc/compiled").glob("**/*.proto"))

args = [
    "-m",
    "grpc_tools.protoc",
    # "--proto_path=../imp-releases/proto/:.",
    # "--proto_path=../imp-releases/proto/google/api:.",
    # "--proto_path=../imp-releases/proto/protoc-gen-openapiv2/options:.",
    # "--proto_path=impgrpc/compiled/:.",
    # "--proto_path=impgrpc/compiled/protoc-gen-openapiv2/:.",
    "--proto_path=impgrpc/compiled/",
    # "--proto_path=.:.",
    "--python_out=impgrpc/compiled",
    "--grpc_python_out=impgrpc/compiled",
]

for protofile in protos:
        args.append(str(protofile) )

# Generate the compiled protofiles
sh.python(args)

Last Step: In File: verrpc_pb2_grpc.py Change: import verrpc_pb2 as verrpc__pb2 To: from lndgrpc import verrpc_pb2 as verrpc__pb2

Deploy to Test-PyPi

poetry build
twine check dist/*
twine upload --repository-url https://test.pypi.org/legacy/ dist/*

Metadata

Release files for imp-grpc-client 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for imp-grpc-client 0.0.2
File Interpreter ABI Platform
imp_grpc_client-0.0.2-py3-none-any.whl Python 3 none any Details

Release files / imp_grpc_client-0.0.2-py3-none-any.whl

Download URL imp_grpc_client-0.0.2-py3-none-any.whl
Size 64.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d90f15381ae59bc1de67d9ea215480bd7e4e0bbcf360f4367a20bd24bfc1f9e
BLAKE2b-256 checksum
How to use checksums
fb6cb9b1b53d954976434025a721d03626a5e321e6c2a971567780ad3bedbce4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.0 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page