lnsocket ======== A simple C library for sending messages over the lightning network Work in progress! Thanks to Rusty and the clightning project for much of this code, I have adapted it to be more library friendly. I've removed references to tal, Rusty's hierarchical allocator. The library only allocates once and uses that chunk of memory for all operations. Motivation ---------- I wanted a way to send custom messages to my lightning node, such as RPC. Building this as a simple C library will allow you to speak the lightning network in native applications, like on mobile. I have not tested this on iOS yet but that is planned and is the motivating use case. Dependencies ------------ You'll need libtool/autoconf/automake for the libsodium/secp256k1 submodules, but otherwise there are no dependencies Building -------- make Examples -------- * See test.c for a ping/pong example * See rpc.c for an RPC example Contributing ------------ Send patches to [email protected]: $ git config format.subjectPrefix 'PATCH lnsocket' $ git config sendemail.to 'William Casarin
' $ git send-email --annotate HEAD^ See https://git-send-email.io/ for configuring your mailer
A simple C library for sending messages over the lightning network
Hey, I have tried connecting to my node in the browser via WebSocket and it refuses to connect for some reason. It works great via Node JS, but not in the browser.
I have also tried using lnlink and I get the same error. Is there anything special that needs to be done with port forwarding for the WS connection to work?
$ make js ... emcc --pre-js lnsocket_pre.js -s ENVIRONMENT=web -s MODULARIZE -flto -s 'EXPORTED_FUNCTIONS=["_malloc", "_free"]' -s EXPORTED_RUNTIME_METHODS=ccall,cwrap -Wall -Os -Ideps/secp256k1/include -Ideps/libsodium/src/libsodium/include -Ideps -Wl,-whole-archive target/js/libsecp256k1.a target/js/libsodium.a target/js/lnsocket.a -Wl,-no-whole-archive -o target/tmp/js/lnsocket.js emcc: error: setting `EXPORTED_RUNTIME_METHODS` expects `<class 'list'>` but got `<class 'str'>` make: *** [Makefile:203: target/tmp/js/lnsocket.js] Error 1
Add tor proxy support to connect on clightning node through onion endpoint.
For test with tor, pass tor socks5 istance on
if (!(ok = lnsocket_connect(ln, nodeid, host, "127.0.0.1:9050"))) goto done;
Use bindgen to add rust bindings at lnsocket C library.
Generate rust bindings and target library with:
rust/lib.rs, I open a demo socket connection to my experimental local node.
I am not a rust expert, so I open MR for feedbacks.
NOTE: on arm64 platform, the code failed to compile: it expects a
$ make ... cc test.o cc test.o -o test /usr/bin/ld: cannot open output file test: Is a directory collect2: error: ld returned 1 exit status make: *** [<builtin>: test] Error 1
ld test cc -Wall -Os -Ideps/secp256k1/include -Ideps/libsodium/src/libsodium/include -Ideps test.o sha256.o hkdf.o hmac.o sha512.o lnsocket.o error.o handshake.o crypto.o bigsize.o commando.o bech32.o libsecp256k1.a libsodium.a lnsocket.a -o test /usr/bin/ld: handshake.o: in function `lnsocket_act_two': handshake.c:(.text+0x3c3): undefined reference to `secp256k1_ecdh' /usr/bin/ld: handshake.c:(.text+0x53a): undefined reference to `secp256k1_ecdh' /usr/bin/ld: handshake.o: in function `act_one_initiator_prep': handshake.c:(.text+0x6dc): undefined reference to `secp256k1_ecdh' collect2: error: ld returned 1 exit status make: *** [Makefile:170: test] Error 1
Updates to build lnsocket library through cargo and archive it in a rust package.
Tested on https://github.com/lvaccaro/btctipserver/blob/62aaddac37b0a7ee4a18d6e90e7276e2f6351440/Cargo.toml#L31
@ShahanaFarooqui wrote a pure-js commando client here: https://github.com/ShahanaFarooqui/CLN-Commando-Client
I should just switch to that instead of using the C wasm build.
When sending multiple RPC requests at once I get the following errors:
When the requests are made separately waiting for each one to complete they all work perfectly, but when fired off at the same time the above error occurs.
I could just wait for each request to receive a response before sending the next one except in the case of long running requests such as
waitinvoicewhich would block other requests for long periods, so it would be nice to be able to send requests in parallel if possible.
Is it possible to have a static public key so that the remote node can limit the rune to that key? Or does a new key need to be created every time it is initialised with the