mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-17 19:03:42 +01:00
ac6d9b34cc
We read a JSON message from the buffer, after converting it from raw bytes to UTF-8, and returning the remainder of the byte array back to the caller. However the return value of `raw_decode` refers to symbols in the UTF-8 decoded string, not the raw bytes underlying byte-array, which means that if we have multi-byte encoded UTF-8 symbols in the byte-array we end up with a misaligned offset and will return part of the message as remainder. This would then end up being interpreted as the result of the next call. This could not be exploited currently since we use a socket only for a single JSON-RPC call and will close the connection afterwards, but since we want to eventually recycle connections for multiple calls, this could have been very dangerous. Signed-off-by: Christian Decker <decker.christian@gmail.com> Reported-by: Corné Plooy <@bitonic-cjp> |
||
---|---|---|
.. | ||
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>