mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-03 20:44:54 +01:00
e0621fa8f7
If the `request` or `plugin` parameter that are injected by the framework where before or inbetween positional arguments we'd be injecting them incorrectly, i.e., we'd be providing them both as `args` (and mismapping another argument) as well as `kwargs`. This is a better way to map arguments, which takes advantage of the fact that JSON-RPC calls are either all positional or named arguments. I also included a test for various scenarios, that hopefull cover the most common cases. Reported-by: Rene Pickhardt <@renepickhardt> Signed-off-by: Christian Decker <decker.christian@gmail.com> |
||
---|---|---|
.. | ||
lightning | ||
tests | ||
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
Examples
"""
Generate invoice on one daemon and pay it on the other
"""
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']))
Also see the included lightning-pay script, which uses the client library to pay invoices
lightning-pay <bolt11 invoice>
# or explicitly with
lightning-pay <destination_id> <amount in millisatoshi> <payment_hash> <min_final_cltv_expiry>