An rpc client for LND (lightning network deamon)
Project description
# lnd-grpc-client
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.
Because of async support this only works with python 3.5+.
## Installation
```bash
$ pip install lndgrpc
```
## How to use
The api mirrors the underlying lnd grpc api (http://api.lightning.community/) but methods will be in pep8 style. ie. `.GetInfo()` becomes `.get_info()`.
```python
from lndgrpc import LNDClient
# pass in the ip-address with RPC port
lnd = LNDClient("127.0.0.1:10009")
lnd.get_info()
print('Listening for invoices...')
for invoice in lnd.subscribe_invoices():
print(invoice)
```
### Async
```python
import asyncio
from lndgrpc import AsyncLNDClient
# pass in the ip-address with RPC port
async_lnd = AsyncLNDClient("127.0.0.1:10009")
async def subscribe_invoices():
print('Listening for invoices...')
async for invoice in async_lnd.subscribe_invoices():
print(invoice)
async def get_info():
while True:
info = await async_lnd.get_info()
print(info)
await asyncio.sleep(5)
async def run():
coros = [subscribe_invoices(), get_info()]
await asyncio.gather(*coros)
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```
### TODO
- [ ] improve docs
- [ ] add tests
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.
Because of async support this only works with python 3.5+.
## Installation
```bash
$ pip install lndgrpc
```
## How to use
The api mirrors the underlying lnd grpc api (http://api.lightning.community/) but methods will be in pep8 style. ie. `.GetInfo()` becomes `.get_info()`.
```python
from lndgrpc import LNDClient
# pass in the ip-address with RPC port
lnd = LNDClient("127.0.0.1:10009")
lnd.get_info()
print('Listening for invoices...')
for invoice in lnd.subscribe_invoices():
print(invoice)
```
### Async
```python
import asyncio
from lndgrpc import AsyncLNDClient
# pass in the ip-address with RPC port
async_lnd = AsyncLNDClient("127.0.0.1:10009")
async def subscribe_invoices():
print('Listening for invoices...')
async for invoice in async_lnd.subscribe_invoices():
print(invoice)
async def get_info():
while True:
info = await async_lnd.get_info()
print(info)
await asyncio.sleep(5)
async def run():
coros = [subscribe_invoices(), get_info()]
await asyncio.gather(*coros)
loop = asyncio.get_event_loop()
loop.run_until_complete(run())
```
### TODO
- [ ] improve docs
- [ ] add tests
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.1.2.tar.gz
(34.0 kB
view details)
Built Distributions
lndgrpc-0.1.2-py3-none-any.whl
(37.2 kB
view details)
lndgrpc-0.1.2-py2-none-any.whl
(37.1 kB
view details)
File details
Details for the file lndgrpc-0.1.2.tar.gz
.
File metadata
- Download URL: lndgrpc-0.1.2.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95d8916b1d15944f012ce92b6a26da8d1c8133aab092ad7bbdc2a6c9c520f6cc |
|
MD5 | 99aa3c093ad42f51bc851042370dd080 |
|
BLAKE2b-256 | ac5839849b80578e49b18e6f392bde29ef9c9a73de59025901197d03ae358166 |
File details
Details for the file lndgrpc-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: lndgrpc-0.1.2-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 841fbb8afbc866d994ed2f3bda140cef39633e2729290bcaae2af292aaaf8478 |
|
MD5 | 0e00d3ea49736ac9b2c07c5c440a884d |
|
BLAKE2b-256 | 5170f356ec69c1d8f4da5b59bc42c2aba5ce62cda6db8c00491833c44e07461f |
File details
Details for the file lndgrpc-0.1.2-py2-none-any.whl
.
File metadata
- Download URL: lndgrpc-0.1.2-py2-none-any.whl
- Upload date:
- Size: 37.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f68e5176fadc7382096b4463cff058ee3241c091d57d248082cbbe7666744f09 |
|
MD5 | 6504b53e426fe3209f32d572e3a061fd |
|
BLAKE2b-256 | 391c5075178998ff836e28dacb07952ada8bf906293785825ed07fda1b07f83f |