README.md 7.13 KiB
Newer Older
Gav Wood's avatar
Gav Wood committed
# parity-bitcoin
The Parity Bitcoin client
Marek Kotewicz's avatar
Marek Kotewicz committed

Evan's avatar
Evan committed
[![Build Status][travis-image]][travis-url] [![Snap Status](https://build.snapcraft.io/badge/paritytech/parity-bitcoin.svg)](https://build.snapcraft.io/user/paritytech/parity-bitcoin)
Nikolay Volf's avatar
Nikolay Volf committed

Nikolay Volf's avatar
Nikolay Volf committed
Gitter [![Gitter https://gitter.im/paritytech/parity-bitcoin](https://badges.gitter.im/paritytech/parity-bitcoin.svg)](https://gitter.im/paritytech/parity-bitcoin)
- [Installing from source](#installing-from-source)

- [Installing the snap](#installing-the-snap)
Marek Kotewicz's avatar
Marek Kotewicz committed

Marek Kotewicz's avatar
Marek Kotewicz committed
- [Running tests](#running-tests)
Marek Kotewicz's avatar
Marek Kotewicz committed

Marek Kotewicz's avatar
Marek Kotewicz committed
- [Going online](#going-online)

- [Importing bitcoind database](#importing-bitcoind-database)

- [Command line interface](#command-line-interface)

- [JSON-RPC](#json-rpc)

- [Logging](#logging)

Marek Kotewicz's avatar
Marek Kotewicz committed
- [Internal Documentation](#internal-documentation)
Marek Kotewicz's avatar
Marek Kotewicz committed

- [Project Graph][graph]

[graph]: ./tools/graph.svg
[travis-image]: https://travis-ci.com/paritytech/parity-bitcoin.svg?token=DMFvZu71iaTbUYx9UypX&branch=master
[travis-url]: https://travis-ci.com/paritytech/parity-bitcoin
[doc-url]: https://paritytech.github.io/parity-bitcoin/pbtc/index.html
Marek Kotewicz's avatar
Marek Kotewicz committed

## Installing from source
Marek Kotewicz's avatar
Marek Kotewicz committed

Installing `pbtc` from source requires `rustc` and `cargo`.
Marek Kotewicz's avatar
Marek Kotewicz committed

Minimal supported version is `rustc 1.16.0 (30cf806ef 2017-03-10)`
Marek Kotewicz's avatar
Marek Kotewicz committed

#### Install rustc and cargo

Both `rustc` and `cargo` are a part of rust toolchain.

An easy way to install the stable binaries for Linux and Mac is to run this in your shell:

```
curl -sSf https://static.rust-lang.org/rustup.sh | sh
```

Windows binaries can be downloaded from [rust-lang website](https://www.rust-lang.org/en-US/downloads.html).

#### Install C and C++ compilers

You will need the cc and gcc compilers to build some of the dependencies.

```
sudo apt-get update
sudo apt-get install build-essential
```

Marek Kotewicz's avatar
Marek Kotewicz committed
#### Clone and build pbtc

Now let's clone `pbtc` and enter it's directory:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
Nikolay Volf's avatar
Nikolay Volf committed
git clone https://github.com/paritytech/parity-bitcoin
Marek Kotewicz's avatar
Marek Kotewicz committed
cd parity-bitcoin
```

`pbtc` can be build in two modes. `--debug` and `--release`. Debug is the default.
Marek Kotewicz's avatar
Marek Kotewicz committed

```
# builds pbtc in debug mode
cargo build -p pbtc
```

```
# builds pbtc in release mode
cargo build -p pbtc --release
```

`pbtc` is now available at either `./target/debug/pbtc` or `./target/release/pbtc`.
Marek Kotewicz's avatar
Marek Kotewicz committed

## Installing the snap

In any of the [supported Linux distros](https://snapcraft.io/docs/core/install):

```
sudo snap install parity-bitcoin --edge
```

Marek Kotewicz's avatar
Marek Kotewicz committed
## Running tests

`pbtc` has internal unit tests and it conforms to external integration tests.
Marek Kotewicz's avatar
Marek Kotewicz committed

#### Running unit tests

Assuming that repo is already cloned, we can run unit tests with this command:

```
./tools/test.sh
```

#### Running external integration tests

Running integration tests is automated, as regtests repo is one of the submodules. Let's download it first:

```
git submodule update --init
```

Now we can run them:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
./tools/regtests.sh
```

It's also possible to run regtests manually:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
# let's start pbtc in regtest compatible mode
./target/release/pbtc --regtest

# now in second shell window
cd $HOME
git clone https://github.com/TheBlueMatt/test-scripts
cd test-scripts
java -jar pull-tests-f56eec3.jar

```

## Going online

By default parity connects to bitcoind seednodes. Full list is [here](./pbtc/seednodes.rs).
Marek Kotewicz's avatar
Marek Kotewicz committed

To start syncing the mainnet, just start the client:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
./target/release/pbtc
```

To start syncing the testnet:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
./target/release/pbtc --testnet
```

To not print any syncing progress add `--quiet` flag:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
./target/release/pbtc --quiet
Marek Kotewicz's avatar
Marek Kotewicz committed
```

## Importing bitcoind database

It it is possible to import existing bitcoind database:

```
# where $BITCOIND_DB is path to your bitcoind database, e.g., "/Users/user/Library/Application Support"
./target/release/pbtc import "$BITCOIND_DB/Bitcoin/blocks"
Marek Kotewicz's avatar
Marek Kotewicz committed
```

By default import verifies imported the blocks. You can disable this, by adding `--skip-verification flag.

```
./target/release/pbtc import "#BITCOIND_DB/Bitcoin/blocks" --skip-verification
Marek Kotewicz's avatar
Marek Kotewicz committed
```

## Command line interface

Full list of CLI options, which is available under `pbtc --help`:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
pbtc 0.1.0
5chdn's avatar
5chdn committed
Parity Technologies <[email protected]>
Parity Bitcoin client
Marek Kotewicz's avatar
Marek Kotewicz committed

USAGE:
    pbtc [FLAGS] [OPTIONS] [SUBCOMMAND]

FLAGS:
        --bitcoin-cash    Use Bitcoin Cash verification rules.
    -h, --help            Prints help information
        --no-jsonrpc      Disable the JSON-RPC API server.
    -q, --quiet           Do not show any synchronization information in the console.
        --regtest         Use a private network for regression tests.
        --segwit2x        Enable SegWit2x verification rules.
        --testnet         Use the test network (Testnet3).
    -V, --version         Prints version information
Marek Kotewicz's avatar
Marek Kotewicz committed

OPTIONS:
        --blocknotify <COMMAND>            Execute COMMAND when the best block changes (%s in COMMAND is replaced by the block hash).
5chdn's avatar
5chdn committed
    -c, --connect <IP>                     Connect only to the specified node.
    -d, --data-dir <PATH>                  Specify the database and configuration directory PATH.
        --db-cache <SIZE>                  Sets the database cache size.
        --jsonrpc-apis <APIS>              Specify the APIs available through the JSONRPC interface. APIS is a comma-delimited list of API names.
        --jsonrpc-cors <URL>               Specify CORS header for JSON-RPC API responses.
        --jsonrpc-hosts <HOSTS>            List of allowed Host header values.
        --jsonrpc-interface <INTERFACE>    The hostname portion of the JSONRPC API server.
        --jsonrpc-port <PORT>              Specify the PORT for the JSONRPC API server.
        --only-net <NET>                   Only connect to nodes in network version <NET> (ipv4 or ipv6).
        --port <PORT>                      Listen for connections on PORT.
    -s, --seednode <IP>                    Connect to a seed-node to retrieve peer addresses, and disconnect.
        --verification-edge <BLOCK>        Non-default verification-level is applied until a block with given hash is met.
        --verification-level <LEVEL>       Sets the Blocks verification level to full (default), header (scripts are not verified), or none (no verification at all).
Marek Kotewicz's avatar
Marek Kotewicz committed

SUBCOMMANDS:
5chdn's avatar
5chdn committed
    help        Prints this message or the help of the given subcommand(s)
    import      Import blocks from a Bitcoin Core database.
    rollback    Rollback the database to given canonical-chain block.
Marek Kotewicz's avatar
Marek Kotewicz committed
```

## JSON-RPC

TODO

## Logging

This is a section only for dev / power users.
Marek Kotewicz's avatar
Marek Kotewicz committed

You can enable detailed client logging by setting env variable `RUST_LOG`, e.g.,
Marek Kotewicz's avatar
Marek Kotewicz committed

```
RUST_LOG=verification=info ./target/release/pbtc --quiet
Marek Kotewicz's avatar
Marek Kotewicz committed
```

`pbtc` started with this env variable will print all logs comming from `verification` module with verbosity `info` or higher. Available log levels are:
Marek Kotewicz's avatar
Marek Kotewicz committed

- `error`
- `warn`
- `info`
- `debug`
- `trace`

It's also possible to start logging from multiple modules in the same time:
Marek Kotewicz's avatar
Marek Kotewicz committed

```
RUST_LOG=sync=trace,p2p=trace,verification=trace,db=trace ./target/release/pbtc --quiet
Marek Kotewicz's avatar
Marek Kotewicz committed
```

**Note:** `RUST_LOG` does only work together with command line option `--quiet` which will surpress the default `sync=info` logging.
Marek Kotewicz's avatar
Marek Kotewicz committed

## Internal documentation

Once released, `pbtc` documentation will be available [here][doc-url]. Meanwhile it's only possible to build it locally:

```
cd parity-bitcoin
./tools/doc.sh
Marek Kotewicz's avatar
Marek Kotewicz committed
open target/doc/pbtc/index.html
```