Skip to content

Instantly share code, notes, and snippets.

Created May 24, 2021
What would you like to do?
establish a lightning connection to some node and get an `init` message back
# just copy and paste this somewhere changing the target node id, ip and address.
# you must have python3 and virtualenv, which can be installed with 'sudo apt install python3-virtualenv' on ubuntu
# it will download the pyln.proto library to a virtualenv and run the script below passed as a string
python3 -m venv venv
./venv/bin/pip install pyln.proto
./venv/bin/python -c '
import sys
from pyln.proto.wire import connect, PrivateKey, PublicKey
from binascii import unhexlify
ls_privkey = PrivateKey(
remote_pubkey = PublicKey(
unhexlify(b"NODE ID HERE")
lc = connect(ls_privkey, remote_pubkey, "NODE IP HERE", "NODE PORT HERE")
print("connected to", remote_pubkey)
print("sent init messsage")
while True:
message = lc.read_message()
if message[0] == 0 and message[1] == 16:
print("got init message")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment