Skip to main content

An rpc client for LND (lightning network deamon)

Project description

# lndgrpc
A python grpc client for LND (Lightning Network Daemon) ⚡⚡⚡

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 2.7, 3.4+
Note: the async client is only available for Python 3.5+

## Installation
$ pip install lndgrpc

## Basic Usage
The api mirrors the underlying lnd grpc api ( but methods will be in pep8 style. ie. `.GetInfo()` becomes `.get_info()`.

from lndgrpc import LNDClient

# pass in the ip-address with RPC port and network ('mainnet', 'testnet', 'simnet')
# the client defaults to and mainnet if no args provided
lnd = LNDClient("", network='simnet')


print('Listening for invoices...')
for invoice in lnd.subscribe_invoices():

### Async

import asyncio
from lndgrpc import AsyncLNDClient

async_lnd = AsyncLNDClient()

async def subscribe_invoices():
print('Listening for invoices...')
async for invoice in async_lnd.subscribe_invoices():

async def get_info():
while True:
info = await async_lnd.get_info()
await asyncio.sleep(5)

async def run():
coros = [subscribe_invoices(), get_info()]
await asyncio.gather(*coros)

loop = asyncio.get_event_loop()

### 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')

#### Admin macaroon
Use the admin macaroon to perform write actions (ie. creating invoices, creating new addresses)

lnd = LNDClient(admin=True)

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lndgrpc-0.2.0.tar.gz (41.1 kB view hashes)

Uploaded source

Built Distribution

lndgrpc-0.2.0-py3-none-any.whl (44.9 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page