Skip to content
/ bp-core Public

BP Core Lib: consensus data structures and client-side-validation library for bitcoin protocol

License

Notifications You must be signed in to change notification settings

BP-WG/bp-core

Repository files navigation

LNP/BP Core Library

TravisCI codecov

This is 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 such projects include:

  • RGB: Confidential smart contracts for Bitcoin & Lightning
  • LNP node: Experimental rust-based modular Lightning network node
  • BP node: Indexing service for bitcoin blockchain; more efficient & universal Electrum server replacement

The planned projects:

  • Spectrum: Decentralized exchange for Lightning Network
  • Storm: Incentivised trustless storage and messaging
  • 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.

Library functionality

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.

Project structure

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:

Install

Get the dependencies

On Debian, run

sudo apt-get install cargo

On Mac OS, run

brew cargo

Clone and compile library

git clone https://github.com/lnp-bp/rust-lnpbp
cd rust-lnpbp
cargo build --release

The library can be found in target/release directory.

You can run tests with:

cargo test

Please refer to the cargo documentation for more detailed instructions.

Use library in other projects

Include this line into your Cargo.toml file:

lnpbp = { git = "https://github.com/lnp-bp/rust-lnpbp.git", branch = "master" }

Use command-line tool for LNP/BP:

We have developed a command-line tool lbx which implements most of this library functionality, so it can be accessed and played with. Download it and build according to the instructions in https://github.com/lnp-bp/lbx

Contributing

Contribution guidelines can be found in a separate CONTRIBUTING file

External dependencies

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.

More information

Policy on Altcoins/Altchains

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.

Licensing

See LICENCE file.

About

BP Core Lib: consensus data structures and client-side-validation library for bitcoin protocol

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  
  •  

Packages

No packages published