Crates.io | ln-types |
lib.rs | ln-types |
version | 0.2.1 |
source | src |
created_at | 2021-11-12 15:31:47.0047 |
updated_at | 2024-08-19 19:07:18.061375 |
description | Common types related to Lightning Network |
homepage | |
repository | https://github.com/LNP-BP/ln-types |
max_upload_size | |
id | 480966 |
size | 101,352 |
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.
The most important types currently available:
Amount
- similar to bitcoin::Amount
but with millisatoshi precisionP2PAddress
- 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.
This crate is no_std
and no-alloc however limitations apply:
P2PAddress
requires nightly Rust because of ip_in_core
- activate this explicitly using the nightly
feature.alloc
(on nightly), P2PAddress
can not parse/store hostnames. Attempts to do so will return errors.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 typesserde
- serialization and deserialization of typespostgres-types
- storing and retrieving from SQLparse_arg
- parsing arguments into types in this cratesecp256k1
- provides NodePubkey
slog
- provides slog::Value
and (where relevant) slog::KV
implementations for the typesFeel 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.
The minimum supported Rust version is 1.56 and will be increased to 1.63 soon.
Generally, the intention is to support at least the latest Debian stable.
However, if the Rust version is lower than 1.77 the P2PAddress
is not available without std
.
Note that external libraries may have higher MSRV - this is not considered a breakage.
MITNFA