core-lightning/contrib/pylightning
2018-01-24 17:30:32 +01:00
..
lightning pylightning: Add and move example to README 2018-01-24 17:30:32 +01:00
README.md pylightning: Add and move example to README 2018-01-24 17:30:32 +01:00
setup.py pylightning: Bumped version to 0.0.2 2018-01-10 03:52:46 +00:00

pylightning: A python client library for lightningd

Installation

You need to have the futures python library installed to be able to use pylightning:

pip install futures

Example

from pylightning import LightningRpc
import random

# Create two instances of the LightningRpc object using two different c-lightning daemons on your computer
l1 = LightningRpc("/tmp/lightning1/lightning-rpc")
l5 = LightningRpc("/tmp/lightning5/lightning-rpc")

info5 = l5.getinfo()
print(info5)

# Create invoice for test payment
invoice = l5.invoice(100, "lbl{}".format(random.random()), "testpayment")
print(invoice)

# Get route to l1
route = l1.getroute(info5['id'], 100, 1)
print(route)

# Pay invoice
print(l1.sendpay(route['route'], invoice['payment_hash']))