Common Rust Lightning Network types

Overview

Common Rust Lightning Network types

Warning: while in a good state, this is still considered a preview version! There are some planned changes.

This library aims to provide Rust-idiomatic, ergonomic, and reasonably performant implementation of primitives used in applications interacting with Lightning Network. That means, they are not just types used to implement LN itself, they are supposed to be useful to any application that e.g. communicates with an LN implementation. Of course, they should still be useful for an LN implementation itself.

Important types

The most important types currently available:

  • Amount - similar to bitcoin::Amount but with millisatoshi precision
  • P2PAddress - address of a node usually represented in text as node_id_hex@host:port
  • NodeId - the byte representation of node's public key (no crypto operations)
  • NodePubkey - newtype around secp256k1::PublicKey to distinguish node public key from other keys. Requires secp256k1 feature.

Note: invoice is not here and isn't planned because it already exists in a separate crate.

Integrations

The crate aims to be interoperable with other crates via optional dependencies. Currently available integrations (activate using features of the same name):

  • bitcoin - converting between types
  • serde - serialization and deserialization of types
  • postgres-types - storing and retrieving from SQL
  • parse_arg - parsing arguments into types in this crate
  • secp256k1 - provides NodePubkey
  • slog - provides slog::Value and (where relevant) slog::KV implementations for the types

Feel free to contribute your own!

Disclaimer: Inclusion of any crate here is neither endorsment nor guarantee of it being secure, honest, non-backdoored or functioning! You're required to do your own review of any external crate.

The rules around adding a new integration are lax: the dependency must be optional, must not be obviously broken or surprising, and must not interact with other implementations in surprising ways.

MSRV

The minimum supported Rust version is 1.48 but it's possible that it'll be decreased further. Generally, the intention is to support at least the latest Debian stable.

Note that external libraries may have higher MSRV - this is not considered a breakage.

License

MITNFA

You might also like...
Reliable p2p network connections in Rust with NAT traversal
Reliable p2p network connections in Rust with NAT traversal

Reliable p2p network connections in Rust with NAT traversal. One of the most needed libraries for any server-less, decentralised project.

The netns-rs crate provides an ultra-simple interface for handling network namespaces in Rust.

netns-rs The netns-rs crate provides an ultra-simple interface for handling network namespaces in Rust. Changing namespaces requires elevated privileg

A private network system that uses WireGuard under the hood.

innernet A private network system that uses WireGuard under the hood. See the announcement blog post for a longer-winded explanation. innernet is simi

A Curve-like AMM for Secret Network

A Curve-like AMM for Secret Network. Supports a varibale number of tokens with the same underlying value.

A multi-protocol network relay

A multi-protocol network relay

Computational Component of Polkadot Network
Computational Component of Polkadot Network

Gear is a new Polkadot/Kusama parachain and most advanced L2 smart-contract engine allowing anyone to launch any dApp for networks with untrusted code.

Fullstack development framework for UTXO-based dapps on Nervos Network

Trampoline-rs The framework for building powerful dApps on the number one UTXO chain, Nervos Network CKB. This is an early-stage, currently very incom

Official Implementation of Findora Network.

Findora Platform Wiki Contribution Guide Licensing The primary license for Platform is the Business Source License 1.1 (BUSL-1.1), see LICENSE. Except

Simple in-network file transfer with barely any overhead.

fftp fftp is the "Fast File Transport Protocol". It transfers files quickly between computers on a network with low overhead. Motivation FTP uses two

Comments
  • Moving to GitHub LNP-WG org

    Moving to GitHub LNP-WG org

    Copy of my message to the common group:

    I think I have to multiply entities 🙁

    The problem is that in rust world you have to maintain small libraries (called “crates”) to have a modular design.

    But rust crate not necessarily equals to a git repo. Today at LNP/BP Association we have >50 of rust crates to maintain, and it will be a crazy overload to have each one as a standalone repo. So for me, until now, Git repo was a unit of code access rights (the needs of the level of peer review) and logical architecture - while rust crates was a way of actual code modularization. This was solved through rust “cargo workspaces”, which allow to maintain multiple crates inside a single repo in an efficient manner.

    Unfortunatelly, I came to a situation, when some rust logically-related crates (like lightning_encoding and lnp2p) stored in the same repo ( lnp-core ), become too distant in their rust dependency hierarchy, having crates from other repos inbetween themselves - which resulted in inabulity to have a single Cargo.lock file per repo. Thus, they have to be split into separate repositories for now - and we have to multiply the number of git repositories, which is very unfortunatelly.

    Another dimension to that problem is the fact that GitHub org can have only up to 6 pinned repos, grabbing attention of independent contributors. In LNP-BP GitHub org we have more than 6 already, especially if I will split lnp-core repo into multiple ones. We had to separate before other GitHub orgs from LNP-BP (for RGB, networking, storm etc); now it seems the time has come for LNP (lightning-related repos).

    So from today I will create a LNP-WG GitHub org and move all lightning-related crates to it, there splitting lnp-core into two repos, one for lightning_encoding and the other one for the rest of lnp-core. LNP Node will also be relocated to LNP-WG.

    I would like to propose to move also this repo to https://github.com/LNP-WG. What do you think?

    question 
    opened by dr-orlovsky 5
  • Initial `no_std` (and no alloc) support

    Initial `no_std` (and no alloc) support

    This removes the requirement to use std and alloc and provides them as features. However this is mainly intended as a way to add those features in a single breaking release and avoid breaking later.

    The support still has a few issues:

    • P2PAddress is not enabled without std, this is related to IP addresses being in std. See also https://github.com/rust-lang/rfcs/pull/2832
    • ~~This introduces incompatibility hazard: one crate could turn on std while another turns on serde - the error types will fail to compile. This could be fixed by the upcoming weak dependency features but MSRV issues. :(~~ Fixed in followup commit Thankfully the incompatibility is trivial to fix but not sure if it's still a good idea. At least we have a warning about it.
    • bitcoin integration is annoying because of that crates poor no_std implementation.

    I'm making this a PR and will keep it open for a bit in case people have ideas how to do this better.

    Closes #6

    enhancement API break 
    opened by Kixunil 1
  • Removed unused features

    Removed unused features

    After better analysis it was determined that these features don't help with forward compatibility and only slightly improve convenience. The noise is probably not worth it.

    bitcoin_* were somewhat more interesting because the bitcoin crate has sad no_std support but there's hope it'll be improved and even if not adding features is better than removing. (The features weren't released yet.)

    Closes #10

    opened by Kixunil 0
  • Consider adding `constants` module

    Consider adding `constants` module

    https://github.com/rust-bitcoin/rust-bitcoin/pull/878#issuecomment-1079909613

    There are probably other interesting constants. Note: we should focus on the interoperability constants - shared by multiple applications/crates, not protocol-only constants.

    enhancement help wanted good first issue 
    opened by Kixunil 0
Owner
Martin Habovštiak
Beside programming, I'm interested in security, cryptography, Bitcoin and freedom.
Martin Habovštiak
A Lightning-Fast DNS Resolver written in Rust 🦀

dnsresolver A Lightning-Fast DNS Resolver Table of Contents Installation Usage Basic Usage Resolving Hosts with Ports Virtual Host Enumeration Using U

zoidsec 47 Nov 8, 2023
Lightning Optimizing Opening Server

Lightning Optimizing Opening Server (loptoš ~ naughty boy/brat/hooligan/..., not to be confused with lopta == ball) WARNING: ULTRA-EXPERIMENTAL SOFTWA

Martin Habovštiak 16 Dec 7, 2022
Docker containers on a synthetic network. Run applications in a context that lets you manipulate their network conditions.

Synthetic Network Docker containers on a synthetic network. Run applications in a context that lets you manipulate their network conditions. Dependenc

Daily 58 Dec 15, 2022
An example of a common Wi-Fi set up scenario on ESP32 using Rust

UTC IoT fetcher This repo is an example of how to configure a Wi-Fi client on an ESP32-based IoT device using an external device connection to the int

Max Wase 4 Jan 19, 2023
Common vulnerability scanning on steroids ☄️

Hogg ?? An experimental passive website scanner. Hogg acts as a proxy between you and your DNS server and scans every website you visit for common vul

Yallxe 13 Jan 8, 2023
Network simulation in Rust

netsim - A Rust library for network simulation and testing (currently linux-only). netsim is a crate for simulating networks for the sake of testing n

Andrew Cann 115 Dec 15, 2022
A Rust library for parsing the SOME/IP network protocol (without payload interpretation).

someip_parse A Rust library for parsing the SOME/IP network protocol (without payload interpretation). Usage Add the following to your Cargo.toml: [de

Julian Schmid 18 Oct 31, 2022
Network Block Storage server, written in Rust. Supports pluggable and chainable underlying storage

nbd-rs Disclaimer DO NEVER USE THIS FOR PRODUCTION Do not use this for any data that you cannot afford to lose any moment. Expect data loss, corruptio

Rainlab Inc 10 Sep 30, 2022
A set of Rust crates for interacting with the Matrix chat network.

Ruma – Your home in Matrix. A set of Rust crates (libraries) for interacting with the Matrix chat network. website • chat • documentation (unstable) G

Ruma 441 Dec 26, 2022
Reliable p2p network connections in Rust with NAT traversal

Reliable p2p network connections in Rust with NAT traversal. One of the most needed libraries for any server-less / decentralised projects

MaidSafe-Archive 948 Dec 20, 2022