This is LNP/BP Core Library: a rust library implementing LNP/BP specifications https://github.com/LNP-BP/LNPBPs. It can be used to simplify development of layer 2 & 3 solutions on top of Lightning Network and Bitcoin blockchain.
The current list of the projects based on the library include:
- RGB: Confidential smart contracts for Bitcoin & Lightning
- Generalized Lightning Network
and it's reference implementation named
LNP node enabling:
- RGB extensions
- DLC extensions
- Lightspeed payments
- Multi-peer channels
- Faster lightning experiments (quicker adoption of eltoo, Taproot etc)
- LNP: Networking protocol for privacy-keeping and censorship-resistant applications, operating in both P2P and RPC modes (currently used as a part of Lightning network, but our effort is to make it more generic and usable even outside of LN). All services, developed by LNP/BP Standards Association (see points below) are made with LNP.
- BP node: Indexing service for bitcoin blockchain; more efficient & universal Electrum server replacement. In perspective - validating Bitcoin network node (using libbitcoinconsus)
The planned projects:
- Decentralized exchange for Lightning Network
- Bifrost Node: P2P LNP/BP network infrastructural node running
- Decentralized exchange information workflows
- Watchtowers (RGB-enabled)
- DLC oracle provider
- Anonymous intermediate storage for client-validated data (like RGB consignments)
- Storm storage providers (see below)
- Storm: Incentivised trustless storage and messaging protocol
- Prometheus: Decentralized trustless computing
Potentially, with LNP/BP Core library you can simplify the development of
- Discreet log contracts
- Implement experimental lightning features
- Do complex multi-threaded or elastic/dockerized client-service microservice architectures
To learn more about the technologies enabled by the library please check:
The development of the library projects is supported by LNP/BP Standards Association.
The library provides the code for:
- Improvements & utilities for Bitcoin protocol
- Deterministic commitments that can be embedded into for Bitcoin transactions and public keys
- Single-use seals
- Client-side validation
- Lightning networking protocol (LNP)
- Generalized lightning network
This code supports both Bitcoin blockchain and Lightning network.
The library is built as a single Rust crate with the following top-level mods:
- common: traits, structures, functions and generics which are used by all parts of the project
- paradigms: generic paradigms (API best practices) which are not bitcoin-specific
- bp: Bitcoin protocol extensions external to Bitcoin Core functionality and existing BIPs. These may also cover those of LNPBP standards which are not specific for other layers.
- lnp: Lightning Network protocol extensions: networking, generalized lightning channels and better layerization of BOLT specifications
- rgb: smart contracts for Bitcoin and Lightning network based client-side validation, deterministic bitcoin commitments and single-use seals.
- lnpbps: other LNPBPs standard implementation which does not fit into any of the categories above
The library is based on other projects:
- rust-bitcoin and it's dependencies
- bitcoin_hashes
- rust-secp256k1
- rust-secp256k1-zkp for Pedersen commitments and Bulletproofs used in confidential state inside RGB protocols
- rust-lightning
On Debian, run
sudo apt-get install cargo libzmq3-dev
On Mac OS, run
brew cargo
git clone https://github.com/lnp-bp/rust-lnpbp
cd rust-lnpbp
cargo build --release --features vendored_openssl
The library can be found in target/release
directory.
You can run full test suite with:
./contrib/test.sh
Please refer to the cargo
documentation
for more detailed instructions.
Add these lines to your Cargo.toml
file at the very end of the [dependecies]
section:
lnpbp = { git = "https://github.com/lnp-bp/rust-lnpbp.git", branch = "master" }
# We need this b/c of breaking change in tagged hash type generation
bitcoin_hashes = { git = "https://github.com/LNP-BP/bitcoin_hashes", tag = "lnpbp-v0.1.0-rc1" }
bitcoin = { git = "https://github.com/LNP-BP/rust-bitcoin", tag = "lnpbp-v0.1.0-rc1" }
# We need custom branches here just to depend on the same bitcoin master and do
# not have secp256k1 version conflict
miniscript = { git = "https://github.com/LNP-BP/rust-miniscript", tag = "lnpbp-v0.1.0-rc1" }
NB: These patches MUST be applied in exactly same manner by any library which uses LNP/BP Core library as a dependency for now
Contribution guidelines can be found in a separate CONTRIBUTING file
This library depends on a number of external Rust libraries managed by different organizations and people within bitcoin community, including Blockstream, Chaincode Labs, Pandora Core companies. Some of the functionality required for LNP/BP development related to the base Bitcoin protocol and Lightning Network is contributed by LNP/BP Association directly into the underlying libraries; however sometimes the present library requires changes in them that can't or not yet accepted by the community. This brings necessity to maintain our own forks of the dependencies. This section presents guidelines for organizing Git workflow managing all dependencies, branching, forks etc.
LNP/BP Standards Association maintains a fork of the following external libraries:
- bitcoin_hashes
- rust-bitcoin
- rust-miniscript
- rust-lightning
- rust-lightning-invoice
- rust-secp256k1-zkp
Functionality, required for LNP/BP and not yet merged into the upstream master
branches is kept in staging
branch of each of these forks, which is defined as
a default branch in GitHub. Parties wanting to contribute to it must fork the
repo, create a branch per each feature (starting with feat/
prefix) or bugfix
(starting with fix/
prefix) and do a PR to the staging
branch.
Each commitment within a PR to the staging
must
- compile without errors;
- contain all necessary tests for the introduced functional;
- contain all docs.
Altcoins and "blockchains" other than Bitcoin blockchain/Bitcoin protocols are not supported and not planned to be supported; pull requests targeting them will be declined.
See LICENCE file.