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
Overview
Comments
-
Websockets not connecting
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?
-
Usage with node
Hey! Is this the right way to use with node.js? I can't seem to get it to work.
import LNSocket from 'lnsocket'; async function go() { try { const ln = await LNSocket(); ln.genkey(); await ln.connect_and_init('033292f0c69eea1b98243e0d11ea5891b828d6af75e73bc1392829f38116738880', 'localhost:9989'); console.log('here'); const rune = 'QRYFkn72bekGstvuETooJQvD9ouRfwG6WoW8IU0cV1I9MA=='; const res = await ln.rpc({ method: 'getinfo', rune }); ln.destroy(); console.log(res); return res; } catch (err) { console.log(err); } } go();
-
make js: emcc error
$ 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 onion endpoint
Add tor proxy support to connect on clightning node through onion endpoint.
For test with tor, pass tor socks5 istance on
lnrpc.c
:if (!(ok = lnsocket_connect(ln, nodeid, host, "127.0.0.1:9050"))) goto done;
-
Add rust bindings
Use bindgen to add rust bindings at lnsocket C library.
Generate rust bindings and target library with:
make rust
In
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
*mut u8
instead*mut i8
onCStr::from_ptr()
. -
cannot open output file test: Is a directory
$ 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
-
getting a build error running `make`
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
-
rust: fix library build inside cargo command
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
-
Pure JS client
@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.
-
Decrypt Error
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
waitinvoice
which would block other requests for long periods, so it would be nice to be able to send requests in parallel if possible. -
Static Key
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
gen_key
method? -
Node Push Data
Is it possible for this library to receive a message from the remote node it is connected to? My use case would be to have a plugin running on the coreln node that listens for events and would then push those events over the lnsocket. Is that possible?
Releases(v0.3.2)
-
v0.3.2(Jul 15, 2022)
0.3.2 - 2022-07-15
Added
Source code(tar.gz)- Added lnsocket_setkey for setting a specific node secret key
Source code(zip)
Realtime Client/Server app for Linux allowing joystick (and other HID) data to be transferred over a local network
netstick What is it? Netstick enables HID devices to be remotely connected between a "client" and "server" over a network connection. It allows the ke
A linux based file-transfer system in terminal. Share Files Over A Network
Introduction A linux based file-transfer system in terminal. Share Files Over A Network Note This Project Is Not Fully Completed Yet But You Are Free
To have platform independent network interfaces over usb which is working with Linux, Windows, Mac OS ect.
To have platform independent network interfaces over usb which is working with Linux, Windows, Mac OS ect. called RNDIS. This project is a RNDIS demo, which addtionally implements a http server. It runs out of the box on a stm32f411 BlackPill board. My RNDIS library with an empty template for the second interface (which can ba UART, CAN, ETH or like in this demo a tcp/ip stack) can be found under following link: https://github.com/RDMsmartnetworks/STM32_HAL_RNDIS
(Test assignment) Transfer files over the network using a homegrown UDP protocol
Требования Linux x86_64 gcc >= 4.9 (C++11) Сборка $ make Запуск $ make run -j5 -j5 позволяет серверу и четырём клиентам запуститься одновременно. В
A modern C++ network library for developing high performance network services in TCP/UDP/HTTP protocols.
evpp Introduction 中文说明 evpp is a modern C++ network library for developing high performance network services using TCP/UDP/HTTP protocols. evpp provid
Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD
NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file
Netif - Header-only C++14 library for getting network addresses associated with network interface without name lookups on Windows, macOS, Linux, and FreeBSD
NetIF Get addresses associated with network interfaces on a system without using name lookups. Header-only, requires C++14. Usage Add the header file
XMap is a fast network scanner designed for performing Internet-wide IPv6 & IPv4 network research scanning.
XMap is reimplemented and improved thoroughly from ZMap and is fully compatible with ZMap, armed with the "5 minutes" probing speed and novel scanning techniques. XMap is capable of scanning the 32-bits address space in under 45 minutes.
A simple network library powered by epoll and proactor pattern.
spinet A simple network library powered by epoll and proactor pattern. Installation Required cmake version 3.10 or above c++ standard 17 or above git
Warp speed Data Transfer (WDT) is an embeddedable library (and command line tool) aiming to transfer data between 2 systems as fast as possible over multiple TCP paths.
WDT Warp speed Data Transfer Design philosophy/Overview Goal: Lowest possible total transfer time - to be only hardware limited (disc or network bandw
Asynchronous, Header-only C++ HTTP-over-(TCP|UNIX Socket|STDIO) Library
CXXHTTP A C++ library implementing an asynchronous HTTP server and client. To clone this library, make sure you also clone the submodules. The --recur
A Simple CLI Network Packet Sniffer
packt packt is a simple CL(command line) network packet sniffer which can run on any unix-like OS including termux (Android). packt works by first ope
The C++ Network Library Project -- cross-platform, standards compliant networking library.
C++ Network Library Modern C++ network programming libraries. Join us on Slack: http://slack.cpp-netlib.org/ Subscribe to the mailing list: https://gr
QUIC, a multiplexed stream transport over UDP
QUIC, a multiplexed stream transport over UDP QUIC is an experimental protocol aimed at reducing web latency over that of TCP. On the surface, QUIC is
Husarnet is a Peer-to-Peer VPN to connect your laptops, servers and microcontrollers over the Internet with zero configuration.
Husarnet Client Husarnet is a Peer-to-Peer VPN to connect your laptops, servers and microcontrollers over the Internet with zero configuration. Key fe
Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC or RDP)
Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC)
Open hardware to measure EC and pH, drive pumps, and otherwise manage a mid-size hydroponic grow over Wi-Fi.
Hydromisc This is a single PCBA with all the necessary I/O to automate a typical small to mid-size hydroponic grow, controllable over Wi-Fi
DS Download Play-compatible (flashme/haxxstation) GBA cart dumper over Wi-Fi
gbaxxdumper DS Download Play-compatible (flashme/haxxstation) GBA cart dumper over Wi-Fi, made by vappster. Uses softmods only, no flashcart/dongle/GC
A DLL that serves OutputDebugString content over a TCP connection
RemoteDebugView A DLL that serves OutputDebugString content over a TCP connection Usage You will need to compile the DLL and then call the exported fu