pool-grpc-client
A python grpc client for Lightning Pool (Lightning Network Daemon) ⚡⚡⚡
This is a wrapper around the default grpc interface that handles setting up credentials (including macaroons.
Dependencies
- Python 3.6+
- Working LND lightning node, take note of its ip address.
- Copy your pool.macaroon and tls.cert files from
~/.pool/mainnetto a directoy on your machine.
Installation
# NOT ON PYPI YET
pip install pool-grpc-client
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().
from pathlib import Path
import json
from poolgrpc.client import PoolClient
credential_path = Path("/home/skorn/.pool/mainnet/")
mac = str(credential_path.joinpath("pool.macaroon").absolute())
tls = str(credential_path.joinpath("tls.cert").absolute())
pool = PoolClient(
macaroon_filepath=mac,
cert_filepath=tls
)
pool.get_info()
pool.get_lsat_tokens()
Specifying Macaroon/Cert files
By default the client will attempt to lookup the readonly.macaron and tls.cert files in the mainnet directory.
However if you want to specify a different macaroon or different path you can pass in the filepath explicitly.
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
# python -m grpc_tools.protoc --proto_path=googleapis:. --python_out=. --grpc_python_out=. rpc.proto
from pathlib import Path
import shutil
import sh
for proto in list(Path("../lnd/lnrpc").rglob("*.proto")):
shutil.copy(proto, Path.cwd())
protos = list(Path(".").glob("*.proto"))
for protofile in protos:
try:
sh.python("-m", "grpc_tools.protoc", "--proto_path=.", "--python_out=.", "--grpc_python_out=.", str(protofile))
protos.remove(protofile)
except Exception as e:
print(f"Error in proto: {protofile}")
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 pool-lnd-grpc 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pool_lnd_grpc-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for pool_lnd_grpc-0.0.3-py3-none-any.whl |
Release files / pool_lnd_grpc-0.0.3-py3-none-any.whl
| Download URL | pool_lnd_grpc-0.0.3-py3-none-any.whl |
|---|---|
| Size | 67.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ed952f67f36ad40f4e58c8c90dcc49b1a8be77d526eae03d4da8acecfa15b88e
|
|
BLAKE2b-256 checksum How to use checksums |
9fde0229132183b28450305a54d4ad179707626af6d3f72d25272153e181beaa
|
| 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.25.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.10
|
Security for pool-lnd-grpc 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.