Skip to content

Instantly share code, notes, and snippets.

@fiatjaf
Created May 24, 2021
Embed
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(
unhexlify(b"1111111111111111111111111111111111111111111111111111111111111111")
)
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)
lc.send_message(b"\x00\x10\x00\x00\x00\x01\xaa")
print("sent init messsage")
while True:
message = lc.read_message()
if message[0] == 0 and message[1] == 16:
print("got init message")
sys.exit(0)
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment