mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-20 02:27:51 +01:00
b9b7411d88
This doesn't make a performance difference, but even better, it simplifies the code. We hacked test_multirpc to send 200x as many commands, and timed the pytest over 20 runs: Before: =================== 1 passed, 136 deselected in 8.550000-9.400000(9.0045+/-0.2) seconds =================== After: =================== 1 passed, 136 deselected in 8.540000-9.370000(8.97286+/-0.16) seconds =================== Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> |
||
---|---|---|
.. | ||
lightning | ||
lightning-pay | ||
README.md | ||
setup.py |
pylightning: A python client library for lightningd
Installation
Note: With Python 2 you need to have the futures python library installed to be able to use pylightning:
pip install futures
pylightning is available on pip
pip install pylightning
Example
from lightning 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']))