From bfaf8ef9890f653fcdc74f228aae3f6afcedf40a Mon Sep 17 00:00:00 2001 From: Davidson Souza Date: Fri, 2 Aug 2024 20:40:50 -0300 Subject: [PATCH] improve readme (#210) * improve readme * rpc-client: fix docs --- README.md | 237 ++++++++++++++++++++++++++++++++ crates/floresta-cli/README.md | 216 +++++++++++++++++++++-------- crates/floresta-cli/src/lib.rs | 10 -- crates/floresta-cli/src/main.rs | 6 - readme.md | 160 --------------------- 5 files changed, 395 insertions(+), 234 deletions(-) create mode 100644 README.md delete mode 100644 readme.md diff --git a/README.md b/README.md new file mode 100644 index 00000000..426e96e8 --- /dev/null +++ b/README.md @@ -0,0 +1,237 @@ +[![Docker Publish](https://github.com/Davidson-Souza/Floresta/actions/workflows/docker.yml/badge.svg)](https://github.com/Davidson-Souza/Floresta/actions/workflows/docker.yml) +[![Docker Publish](https://github.com/Davidson-Souza/Floresta/actions/workflows/docker.yml/badge.svg)](https://github.com/Davidson-Souza/Floresta/actions/workflows/docker.yml) +[![functional](https://github.com/Davidson-Souza/Floresta/actions/workflows/functional.yml/badge.svg)](https://github.com/Davidson-Souza/Floresta/actions/workflows/functional.yml) + +### Floresta + +Welcome to Floresta, a lightweight Bitcoin full node implementation written in Rust, powered by [Utreexo](https://eprint.iacr.org/2019/611) a novel dynamic accumulator designed for the Bitcoin UTXO set. + +This project is composed of two parts, `libfloresta` and `florestad`. `libfloresta` is +a set of reusable components that can be used to build Bitcoin applications. `florestad` is built on top of `libfloresta` to provide a full node implementation, including a watch-only wallet and an Electrum server. If you just want to run a full node, you can use `florestad` directly, either by building it from source or by downloading a pre-built binary from the [releases](https://github.com/Davidson-Souza/Floresta/releases/tag/v0.4.0). + +If you want to use `libfloresta` to build your own Bitcoin application, you can find the documentation [here](https://docs.getfloresta.sh/floresta/). + +### ToC + +- [Community](#community) +- [Building](#building) + - [Building with nix](#building-with-nix) +- [Running](#running) + - [Assume Utreexo](#assume-utreexo) + - [Compact Filters](#compact-filters) + - [Getting help](#getting-help) + - [Wallet](#wallet) +- [Running the tests](#running-the-tests) +- [Contributing](#contributing) +- [Using Nix](#using-nix) +- [License](#license) +- [Acknowledgments](#acknowledgments) +- [Consensus implementation](#consensus-implementation) + +### Community + +If you want to discuss this project, you can join our Discord server [here](https://discord.gg/5Wj8fjjS93). If you want to disclose +a security vulnerability, please email `Davidson Souza at me AT dlsouza DOT lol`, using the PGP key [`2C8E0F 836FD7D BBBB9E 9B2EF899 64EC3AB 22B2E3`](https://blog.dlsouza.lol/assets/pgp.asc). + +## Building + +You'll need Rust and Cargo, refer to [this](https://www.rust-lang.org/) for more details. Minimum support version is rustc 1.74 and newer. + +Once you have Cargo, clone the repository with: + +```bash +git clone https://github.com/Davidson-Souza/Floresta.git +``` + +go to the Floresta directory + +```bash +cd Floresta/ +``` + +and build with cargo build + +```bash +cargo build --release +# Optionally, you can add florestad to the path with +cargo install --path ./florestad +``` + +### Building with nix + +If you're using Nix, you can add Florestad to your system with its overlay. + +```nix +{ + #Here you declare the import for your flake + inputs.florestad = { + url = "github:Davidson-Souza/Floresta"; + inputs = { + nixpkgs.follows = "nixpkgs"; + flake-parts.follows = "flake-parts"; + }; + }; + + outputs = inputs @ { self, ... }: + { + imports = [ + { + nixpkgs.overlays = [ + # Here you use the floresta overlay with your others + inputs.florestad.overlays.default + ]; + } + ]; + }; +``` +then Florestad will be available just like any other package with + +```nix +pkgs.florestad +``` + + +But if you just want to test it or quickly run a instance you can do +```bash +$ nix run github:Davidson-Souza/Floresta +``` + +### Running + +After building, florestad and floresta-cli will be available in the target directory. You can run the full node with +```bash +./target/release/florestad +# or, if you installed it with cargo install +florestad +``` + +This will start the full node, and you can connect to it with an Electrum wallet or with the `floresta-cli` tool. + +```bash +floresta-cli getblockchaininfo +``` + +For more information on how to use the `floresta-cli` tool, you can check the [api documentation](https://github.com/Davidson-Souza/Floresta/blob/master/crates/floresta-cli/README.md). + +#### Assume Utreexo +If you want to skip the IBD process, you can use the `--assumeutreexo` flag. This flag will start the node at a given height, with the state +provided by this implementation. Therefore, you're trusting that we are giving you the correct state. Everything after that height will be +verified by the node just like any other node. + +```bash +florestad --assumeutreexo +``` + +#### Compact Filters + +Floresta supports compact block filters, which can be used to scan for transactions in a block without downloading the entire block. You can start the node with the `--cfilters` flag to download the filters for the blocks that you're interested in. You can also use the `--filters-start-height` flag to specify the block height that you want to start downloading the filters from. This is useful if you want to download only the filters for a specific range of blocks. + +```bash +florestad --cfilters --filters-start-height 800000 +``` + +#### Getting help + +You can get a list of all the available commands by running + +```bash +floresta-cli help +``` + +and you can get the cli parameters by running +```bash +floresta-cli help +``` + +#### Wallet + +Floresta comes with a watch-only wallet that you can use to track your transactions. You just need to provide the wallet +information, either as a configuration file or as a command line argument. See the [sample configuration file](florestad/config.toml) for an example config. Floresta supports SLIP-132 extended public keys (xpubs) and output descriptors. You can add new wallets to follow at any time, just +call the `rescan` rpc after adding the wallet. + +You can add new descriptors to the wallet with the `importdescriptor` rpc. + +```bash +floresta-cli importdescriptor "wpkh(xpub6CFy3kRXorC3NMTt8qrsY9ucUfxVLXyFQ49JSLm3iEG5gfAmWewYFzjNYFgRiCjoB9WWEuJQiyYGCdZvUTwPEUPL9pPabT8bkbiD9Po47XG/<0;1>/*)" +``` + +The rescan assumes that you have compact block filters for the blocks that you're scanning. You can either download all the filters +(about 11GB on mainnet) or, if you know the block range that you're interested in, you can download only the filters for that range +using the `--filters-start-height` option. Let's you know that none of your wallets are older than block 800,000. Just start the node with. + +```bash +./target/release/florestad --cfilters --filters-start-height 800000 +``` + +if you add a wallet and want to rescan the blocks from 800,000 to the current height, you can use the `rescan` rpc. + +```bash +floresta-cli rescan 800000 +``` + +Once you have a transaction cached in your watch-only, you can use either the rpc or integrated electrum server to retrieve information about your wallet. You can use wallets like Electrum or Sparrow to connect to your node and retrieve information about your wallet. Just connect with the server running at `127.0.0.1:50001:t`. On electrum you may want to use the `--oneserver` flag to connect to a single server, for better privacy. + +### Running the tests + +#### Requirements + +```bash +cargo build +``` + +There's a set of unit tests that you can run with +```bash +cargo test +``` + +There's also a set of functional tests that you can run with + +```bash +pip3 install -r tests/requirements.txt +python tests/run_tests.py +``` + +### Contributing +Contributions are welcome, feel free to open an issue or a pull request. + +If you want to contribute but don't know where to start, take a look at the issues, there's a few of them marked as `good first issue`. + +Here's some Guidelines: +- Has to compile. +- Has to run. +- Use [pre-commit](https://pre-commit.com/) for the language that you're using (if possible 👍). + +You can accomplish that using our flake.nix for development. + +### Using Nix + +If you already have [Nix](https://nixos.org/) you just need to do: + +```Bash +$ nix develop +``` + +and use our flake for development which include + +- nix(fmt) and rust(fmt) pre-commit. +- Rust Msrv(1.74.0). +- Clippy and some libs so rust can compile. +- Typos for good spelling. + +If you do not have Nix +[Check their guide](https://nixos.org/download/). + +### License +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details + +### Acknowledgments +* [Utreexo](https://eprint.iacr.org/2019/611) +* [Bitcoin Core](https://github.com/bitcoin/bitcoin) +* [Rust Bitcoin](https://github.com/rust-bitcoin/rust-bitcoin) +* [Rust Miniscript](https://github.com/rust-bitcoin/rust-miniscript) + +### Consensus implementation + +One of the most challenging parts of working with Bitcoin is keeping up with the consensus rules. Given it's nature as a consensus protocol, it's very important to make sure that the implementation is correct. Instead of reimplementing a Script interpreter, we use [`rust-bitcoinconsensus`](https://github.com/rust-bitcoin/rust-bitcoinconsensus/) to verify transactions. This is a bind around a shared library that is part of Bitcoin Core. This way, we can be sure that the consensus rules are the same as Bitcoin Core, at least for scripts. + +Although tx validation is arguably the hardest part in this process. This integration can be further improved by using `libbitcoinkernel`, that will increase the scope of `libbitcoinconsensus` to outside scripts, but this is still a work in progress. diff --git a/crates/floresta-cli/README.md b/crates/floresta-cli/README.md index bb09e999..cb89d816 100644 --- a/crates/floresta-cli/README.md +++ b/crates/floresta-cli/README.md @@ -1,6 +1,7 @@ ## Command line utility This is a simple cli utility to interact with your node. To run it, just call + ```bash $ floresta-cli [] ``` @@ -17,8 +18,10 @@ Available commands: - [getblockheader](#getblockheader) - [loaddescriptor](#loaddescriptor) - [getroots](#getroots) + - [stop](#stop) + - [addnode](#addnode) -### getblockchaininfo +## getblockchaininfo This command takes no params and returns some useful data about the current active network @@ -27,22 +30,35 @@ This command takes no params and returns some useful data about the current acti **Return** `best_block`: The best block we have headers for + `chain`: The name of the current active network(eg: bitcoin, testnet, regtest) + `difficulty`: Current network difficulty + `height`: The height of the best block we have headers for + `ibd`: Whether we are currently in initial block download + `latest_block_time`: The time in which the latest block was mined + `latest_work`: The work of the latest block (e.g the amount of hashes needed to mine it, on average) + `leaf_count`: The amount of leaves in our current forest state + `progress`: The percentage of blocks we have validated so far + `root_count`: The amount of roots in our current forest state + `root_hashes`: The hashes of the roots in our current forest state + `validated`: The amount of blocks we have validated so far + `verification_progress`: The percentage of blocks we have verified so far -### getblockhash +## getblockhash Returns the block hash associated with a given height + **Args** `height`: A numerical identifier for a block @@ -52,21 +68,23 @@ Returns the block hash associated with a given height `block_hash`: A string containing a hex-encoded block hash -### gettxout +## gettxout Returns a cached transaction output. The output itself doesn't have to be ours. But the transaction containing it should be cached by our internal wallet. + **Args** `tx_id`: A transaction id + `vout`: A index for the desired output **Returns** -`value`: The amount of satoshis in this output, -`spk`: The redeem script for this output +`value`: The amount of satoshis in this output +`spk`: The redeem script for this output -### getrawtransaction +## getrawtransaction Returns a transaction data, given its id. The transaction itself doesn't have to be ours. But it should be cached by our internal wallet or in the mempool. @@ -76,54 +94,82 @@ Returns a transaction data, given its id. The transaction itself doesn't have to **Returns** - `blockhash`: The hash of the block containing this transaction, if it is in a block - `blocktime`: Time when the block containing this transaction was mined, if it is in a block - `confirmations`: The amount of confirmations this transaction has, if it is in a block - `hash`: The hash of this transaction, a.k.a wtxid - `hex`: The hex-encoded transaction - `in_active_chain`: Whether this transaction is in the active chain - `locktime`: The locktime value of this transaction. - `size`: The size of this transaction in bytes. - `time`: The time when this transaction was mined, if it is in a block - `txid`: The id of this transaction. Only for witness transactions, this is `different` from the wtxid - `version`: The version of this transaction - `vin`: A vector of inputs - `script_sig`: The script signature for this input - `asm`: The disassembled script signature - `hex`: Raw hex-encoded script signature - `sequence`: The nSequence value for this input - `txid`: The id of the transaction containing the output we are spending - `vout`: The index of the output we are spending - `witness`: A vector of witness data - `vout`: A vector of outputs - `n`: The index of this output - `script_pub_key`: The script pubkey for this output - `address`: The address this output pays to, if it's a standard output - `asm`: The disassembled script pubkey - `hex`: Raw hex-encoded script pubkey - `req_sigs`: The amount of signatures required to spend this output (Deprecated) - `type`: The type of this output (e.g pubkeyhash, scripthash, etc) - `value`: The amount of satoshis in this output - `vsize`: The size of this transaction, in virtual bytes - `weight`: The weight of this transaction - -### rescan - -Tells our node to rescan blocks. This will make our node download all blocks all over again, which may be network intensive. -This rpc is useful if you add another address, descriptor or xpub to our wallet, and you know it have historical transactions that are not indexed yet. +`blockhash`: The hash of the block containing this transaction, if it is in a block -**Args** +`blocktime`: Time when the block containing this transaction was mined, if it is in a block + +`confirmations`: The amount of confirmations this transaction has, if it is in a block + +`hash`: The hash of this transaction, a.k.a wtxid + +`hex`: The hex-encoded transaction -`height`: The height we should start +`in_active_chain`: Whether this transaction is in the active chain + +`locktime`: The locktime value of this transaction. + +`size`: The size of this transaction in bytes. + +`time`: The time when this transaction was mined, if it is in a block + +`txid`: The id of this transaction. Only for witness transactions, this is `different` from the wtxid + +`version`: The version of this transaction + +`vin`: A vector of inputs + + `script_sig`: The script signature for this input + + `asm`: The disassembled script signature + + `hex`: Raw hex-encoded script signature + + `sequence`: The nSequence value for this input + + `txid`: The id of the transaction containing the output we are spending + + `vout`: The index of the output we are spending + + `witness`: A vector of witness data + +`vout`: A vector of outputs + + `n`: The index of this output + + `script_pub_key`: The script pubkey for this output + + `address`: The address this output pays to, if it's a standard output + + `asm`: The disassembled script pubkey + + `hex`: Raw hex-encoded script pubkey + + `req_sigs`: The amount of signatures required to spend this output (Deprecated) + + `type`: The type of this output (e.g pubkeyhash, scripthash, etc) + + `value`: The amount of satoshis in this output + +`vsize`: The size of this transaction, in virtual bytes + +`weight`: The weight of this transaction + +## rescan + +Tells our node to rescan blocks. This rpc will only work if the node is not in IBD and it was started with the `--cfilters` flag. +This will rescan for all scripts in our internal wallet within the range of blocks you've downloaded filters for (which can be set +with the `--filters-start-height` flag). If we don't see any error in early stages, the rescan will continue in the background, and +you'll get a `true` as a response. Once the process is finished, you'll see a log message in the node's log saying that the rescan is done. + +**Args**: None **Return** `success`: Whether we successfully started rescanning +## sendrawtransaction -### sendrawtransaction - -Submits a transaction to the network +Submits a transaction to the network. This will broadcast the transaction to our peers, and if it's valid, it will be included in a block. **Args** @@ -133,8 +179,7 @@ Submits a transaction to the network `tx_id`: The transaction id if we succeed - -### getblockheader +## getblockheader Returns the header of a block, giving its hash @@ -145,68 +190,123 @@ Returns the header of a block, giving its hash **Return**: `bits`: A compact representation of the block target + `merkle_root`: The root of a tree formed by all transactions in this block + `nonce`: The nonce used to mine this block + `prev_blockhash`: The hash of this block's ancestor + `time`: The time in which this block was created + `version`: This block's version -### loaddescriptor +## loaddescriptor -Tells our wallet to follow this new descriptor. Optionally, whether we should rescan the blockchain if there's any historical transaction associated with this descriptor. +Tells our wallet to follow this new descriptor. This method will also make our wallet rescan the blockchain for transactions that match this descriptor. Due to that, you can only use this method when the node is not in IBD and if it was started with the `--cfilters` flag. **Args** -`descriptor`: A output descriptor +`descriptor`: An output descriptor **Return** `status`: Whether we succeed loading this descriptor -### getroots +## getroots Returns the roots of our current forest state **Args**: None + **Return** `roots`: A vec of hashes -### getblock +## getblock -Returns a full block, given its hash. Notice that this rpc will cause a actual network request to our node, so it may be slow, and if used too often, may cause more network usage. +Returns a full block, given its hash. Notice that this rpc will cause a actual network request to our node, so it may be slow, and if used too often, may cause more network usage. The returns for this rpc are identical to bitcoin core's `getblock` rpc as of version 27.0 **Args** +`block_hash`: The hash of the block you need to get + +**Return** + `block_hash`: The hash of a block + `bits`: A compact representation of the block target + `chainwork`: The combined work of all blocks in this blockchain + `confirmations`: The amount of confirmations this block has + `difficulty`: This block's difficulty + `hash`: This block's hash + `height`: This block's height + `mediantime`: The median of the timestamps of the last 11 blocks + `merkleroot`: The root of a tree formed by all transactions in this block + `n_tx`: The amount of transactions in this block + `nextblockhash`": The hash of the next block, if any + `nonce`: The nonce used to mine this block + `previousblockhash`": The hash of this block's ancestor + `size`: The size of this block in bytes + `strippedsize`: The size of this block in bytes, excluding witness data + `time`: The time in which this block was created + `tx`: A txid vector of transactions in this block + `version`: This block's version + `versionHex`: This block's version, in hex + `weight`: The weight of this block -### getpeerinfo +## getpeerinfo Returns a list of peers connected to our node, and some useful information about them. **Args**: None **Returns** + `peers`: A vector of peers connected to our node - `address`: This peer's network address - `services`: The services this peer announces as supported - `user_agent`: A string representing this peer's software \ No newline at end of file + + `address`: This peer's network address + + `services`: The services this peer announces as supported + + `user_agent`: A string representing this peer's software + +## stop + +Gracefully stops the node + +**Args**: None + +**Return** + +`success`: Whether we successfully stopped the node + +## addnode + +Adds a new node to our list of peers. This will make our node try to connect to this peer. + +**Args** + +`node`: A network address with the format `ip[:port]` + +**Return** + +`success`: Whether we successfully added this node to our list of peers diff --git a/crates/floresta-cli/src/lib.rs b/crates/floresta-cli/src/lib.rs index c93516ec..38de2456 100644 --- a/crates/floresta-cli/src/lib.rs +++ b/crates/floresta-cli/src/lib.rs @@ -164,16 +164,6 @@ mod tests { assert_eq!(block_header.block_hash(), blockhash); } - #[test] - fn test_get_block_filter() { - let (_proc, client) = start_florestad(); - - let block_filter = client.get_block_filter(0); - - // this should err, because there is no filter for genesis block - assert!(block_filter.is_err()); - } - #[test] fn test_get_height() { let (_proc, client) = start_florestad(); diff --git a/crates/floresta-cli/src/main.rs b/crates/floresta-cli/src/main.rs index d925d0eb..5caf9033 100644 --- a/crates/floresta-cli/src/main.rs +++ b/crates/floresta-cli/src/main.rs @@ -66,9 +66,6 @@ fn do_request(cmd: &Cli, client: ReqwestClient) -> anyhow::Result { Methods::GetPeerInfo => serde_json::to_string_pretty(&client.get_peer_info()?)?, Methods::Stop => serde_json::to_string_pretty(&client.stop()?)?, Methods::AddNode { node } => serde_json::to_string_pretty(&client.add_node(node)?)?, - Methods::GetFilters { height } => { - serde_json::to_string_pretty(&client.get_block_filter(height)?)? - } }) } @@ -150,7 +147,4 @@ pub enum Methods { /// Usage: addnode #[command(name = "addnode")] AddNode { node: String }, - /// Returns the filters for a given block - #[command(name = "getfilter")] - GetFilters { height: u32 }, } diff --git a/readme.md b/readme.md deleted file mode 100644 index 150337cf..00000000 --- a/readme.md +++ /dev/null @@ -1,160 +0,0 @@ -### Floresta - -Welcome to Floresta, a lightweight Bitcoin full node implementation written in Rust, powered by [Utreexo](https://eprint.iacr.org/2019/611) a novel dynamic accumulator designed for the Bitcoin UTXO set. - -This project is composed of two parts, `libfloresta` and `florestad`. `libfloresta` is -a set of reusable components that can be used to build Bitcoin applications. `florestad` is built on top of `libfloresta` to provide a full node implementation, including a watch-only wallet and an Electrum server. If you just want to run a full node, you can use `florestad` directly, either by building it from source or by downloading a pre-built binary from the [releases](https://github.com/Davidson-Souza/Floresta/releases/tag/v0.4.0). - -If you want to use `libfloresta` to build your own Bitcoin application, you can find the documentation [here](https://docs.getfloresta.sh/floresta/). - -### Community - -If you want to discuss this project, you can join our Discord server [here](https://discord.gg/5Wj8fjjS93). - -### Building - -You'll need Rust and Cargo, refer to [this](https://www.rust-lang.org/) for more details. Minimum support version is rustc 1.74 and newer. - -Once you have Cargo, clone the repository with: - -```bash -git clone https://github.com/Davidson-Souza/Floresta.git -``` - -go to the Floresta directory - -```bash -cd Floresta/ -``` - -and build with cargo build - -```bash -cargo build --release --bin florestad -# Optionally, you can add florestad to the path with -cargo install --path ./florestad -``` - -### Building with nix - -If you're using Nix, you can add Florestad to your system with its overlay. - -```nix -{ - #Here you declare the import for your flake - inputs.florestad = { - url = "github:Davidson-Souza/Floresta"; - inputs = { - nixpkgs.follows = "nixpkgs"; - flake-parts.follows = "flake-parts"; - }; - }; - - outputs = inputs @ { self, ... }: - { - imports = [ - { - nixpkgs.overlays = [ - # Here you use the floresta overlay with your others - inputs.florestad.overlays.default - ]; - } - ]; - }; -``` -then Florestad will be available just like any other package with - -```nix -pkgs.florestad -``` - - -But if you just want to test it or quickly run a instance you can do -```bash -$ nix run github:Davidson-Souza/Floresta -``` - -### Running -Right now, this project is working on signet only. Mainnet support is still a todo thing. You can get some signet coins [here](https://www.signetfaucet.com/) and just play around with it. -Copy `config.toml.sample` to `config.toml`, and fill up your xpubs and addresses that you intend to track, and then run with - -```bash -florestad -c config.toml --network signet run -``` - -or - -```bash -./target/release/florestad -c config.toml --network signet run -``` - -or - -```bash -cargo run --release -- -c config.toml --network signet run -``` - -### Running the tests - -#### Requirements - -```bash -cargo build -``` - -There's a set of unit tests that you can run with -```bash -cargo test -``` - -There's also a set of functional tests that you can run with - -```bash -pip3 install -r tests/requirements.txt -python tests/run_tests.py -``` - -### Contributing -Contributions are welcome, feel free to open an issue or a pull request. - -If you want to contribute but don't know where to start, take a look at the issues, there's a few of them marked as `good first issue`. - -Here's some Guidelines: -- Has to compile. -- Has to run. -- Use [pre-commit](https://pre-commit.com/) for the language that you're using (if possible 👍). - -You can accomplish that using our flake.nix for development. - -### Using Nix - -If you already have [Nix](https://nixos.org/) you just need to do: - -```Bash - $ nix develop -``` - -and use our flake for development with include - -- nix(fmt) and rust(fmt) pre-commit. -- Rust Msrv(1.74.0). -- Clippy and some libs so rust can compile. -- Typos for good spelling. - -If you do not have Nix -[Check their guide](https://nixos.org/download/). - -### License -This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details - -### Acknowledgments -* [Utreexo](https://eprint.iacr.org/2019/611) -* [Bitcoin Core](https://github.com/bitcoin/bitcoin) -* [Rust Bitcoin](https://github.com/rust-bitcoin/rust-bitcoin) -* [Rust Miniscript](https://github.com/rust-bitcoin/rust-miniscript) - -### Consensus implementation - -One of the most challenging parts of working with Bitcoin is keeping up with the consensus rules. Given it's nature as a consensus protocol, it's very important to make sure that the implementation is correct. Instead of reimplementing a Script interpreter, we use [`rust-bitcoinconsensus`](https://github.com/rust-bitcoin/rust-bitcoinconsensus/) to verify transactions. This is a bind around a shared library that is part of Bitcoin Core. This way, we can be sure that the consensus rules are the same as Bitcoin Core, at least for scripts. - -Although tx validation is arguably the hardest part in this process. This integration can be further improved by using `libbitcoinkernel`, that will increase the scope of `libbitcoinconsensus` to outside scripts, but this is still a work in progress.