Skip to content

Instantly share code, notes, and snippets.

@fiatjaf
Created May 24, 2021 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiatjaf/ffb76387d5bcf6e8e13d4314d26e8f4a to your computer and use it in GitHub Desktop.
Save fiatjaf/ffb76387d5bcf6e8e13d4314d26e8f4a to your computer and use it in GitHub Desktop.
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