parity-zcash/README.md

367 lines
12 KiB
Markdown
Raw Normal View History

2017-08-29 06:52:21 -07:00
# The Parity Bitcoin client.
2016-09-19 07:36:53 -07:00
2017-07-15 21:58:55 -07:00
[![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)
2017-04-28 05:14:32 -07:00
2017-04-28 05:52:46 -07:00
Gitter [![Gitter https://gitter.im/paritytech/parity-bitcoin](https://badges.gitter.im/paritytech/parity-bitcoin.svg)](https://gitter.im/paritytech/parity-bitcoin)
2016-10-17 04:52:06 -07:00
- [Installing from source](#installing-from-source)
- [Installing the snap](#installing-the-snap)
2016-10-17 04:48:22 -07:00
2016-12-14 05:36:31 -08:00
- [Running tests](#running-tests)
2016-09-19 07:36:53 -07:00
2016-12-14 05:36:31 -08:00
- [Going online](#going-online)
- [Importing bitcoind database](#importing-bitcoind-database)
- [Command line interface](#command-line-interface)
- [JSON-RPC](#json-rpc)
- [Logging](#logging)
2016-12-14 05:43:55 -08:00
- [Internal Documentation](#internal-documentation)
2016-12-14 05:36:31 -08:00
- [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
2016-12-14 05:36:31 -08:00
## Installing from source
2016-12-14 05:36:31 -08:00
Installing `pbtc` from source requires `rustc` and `cargo`.
2016-12-14 05:36:31 -08:00
Minimal supported version is `rustc 1.23.0 (766bd11c8 2018-01-01)`
2016-12-14 05:36:31 -08:00
#### Install rustc and cargo
2017-08-29 06:52:21 -07:00
Both `rustc` and `cargo` are a part of rust tool-chain.
2016-12-14 05:36:31 -08:00
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
```
2016-12-14 05:36:31 -08:00
#### Clone and build pbtc
Now let's clone `pbtc` and enter it's directory:
2016-12-14 05:36:31 -08:00
```
2017-04-27 17:40:53 -07:00
git clone https://github.com/paritytech/parity-bitcoin
2016-12-14 05:36:31 -08:00
cd parity-bitcoin
```
`pbtc` can be build in two modes. `--debug` and `--release`. Debug is the default.
2016-12-14 05:36:31 -08:00
```
# 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`.
2016-12-14 05:36:31 -08:00
## Installing the snap
In any of the [supported Linux distros](https://snapcraft.io/docs/core/install):
```
sudo snap install parity-bitcoin --edge
```
2016-12-14 05:36:31 -08:00
## Running tests
`pbtc` has internal unit tests and it conforms to external integration tests.
2016-12-14 05:36:31 -08:00
#### Running unit tests
2017-08-29 06:52:21 -07:00
Assuming that repository is already cloned, we can run unit tests with this command:
2016-12-14 05:36:31 -08:00
```
./tools/test.sh
```
#### Running external integration tests
2017-08-29 06:52:21 -07:00
Running integration tests is automated, as the regtests repository is one of the submodules. Let's download it first:
2016-12-14 05:36:31 -08:00
```
git submodule update --init
```
Now we can run them:
2016-12-14 05:36:31 -08:00
```
./tools/regtests.sh
```
It's also possible to run regtests manually:
2016-12-14 05:36:31 -08:00
```
# let's start pbtc in regtest compatible mode
2017-09-03 22:36:31 -07:00
./target/release/pbtc --segwit --regtest
2016-12-14 05:36:31 -08:00
# 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
2017-08-29 06:52:21 -07:00
By default parity connects to bitcoind-seednodes. Full list is [here](./pbtc/seednodes.rs).
2016-12-14 05:36:31 -08:00
2017-12-26 22:52:57 -08:00
Before starting synchronization, you must decide - which fork to follow - SegWit (`--segwit` flag) or Bitcoin Cash (`--bitcoin-cash` flag). On next start, passing the same flag is optional, as the database is already bound to selected fork and won't be synchronized using other verification rules.
2017-09-03 22:36:31 -07:00
To start syncing the main network, just start the client, passing selected fork flag. For example:
2016-12-14 05:36:31 -08:00
```
2017-09-03 22:36:31 -07:00
./target/release/pbtc --segwit
2016-12-14 05:36:31 -08:00
```
To start syncing the testnet:
2016-12-14 05:36:31 -08:00
```
2017-09-03 22:36:31 -07:00
./target/release/pbtc --segwit --testnet
2016-12-14 05:36:31 -08:00
```
To not print any syncing progress add `--quiet` flag:
2016-12-14 05:36:31 -08:00
```
2017-09-03 22:36:31 -07:00
./target/release/pbtc --segwit --quiet
2016-12-14 05:36:31 -08:00
```
## Importing bitcoind database
2017-08-29 06:52:21 -07:00
It it is possible to import existing `bitcoind` database:
2016-12-14 05:36:31 -08:00
```
# where $BITCOIND_DB is path to your bitcoind database, e.g., "/Users/user/Library/Application Support"
./target/release/pbtc import "$BITCOIND_DB/Bitcoin/blocks"
2016-12-14 05:36:31 -08:00
```
2017-09-03 22:36:31 -07:00
By default import verifies imported the blocks. You can disable this, by adding `--verification-level==none` flag.
2016-12-14 05:36:31 -08:00
```
2017-09-03 22:36:31 -07:00
./target/release/pbtc import "#BITCOIND_DB/Bitcoin/blocks" --segwit --skip-verification
2016-12-14 05:36:31 -08:00
```
## Command line interface
Full list of CLI options, which is available under `pbtc --help`:
2016-12-14 05:36:31 -08:00
```
pbtc 0.1.0
2017-08-29 06:25:30 -07:00
Parity Technologies <info@parity.io>
Parity Bitcoin client
2016-12-14 05:36:31 -08:00
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.
2017-09-03 22:36:31 -07:00
--segwit Enable SegWit verification rules.
--testnet Use the test network (Testnet3).
-V, --version Prints version information
2016-12-14 05:36:31 -08:00
OPTIONS:
--blocknotify <COMMAND> Execute COMMAND when the best block changes (%s in COMMAND is replaced by the block hash).
2017-08-29 06:25:30 -07:00
-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).
2016-12-14 05:36:31 -08:00
SUBCOMMANDS:
2017-08-29 06:25:30 -07:00
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.
2016-12-14 05:36:31 -08:00
```
## JSON-RPC
#### Network
The Parity-bitcoin `network` interface.
##### addnode
Add the node.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "addnode", "params": ["127.0.0.1:8888", "add"], "id":1 }' localhost:8332
Remove the node.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "addnode", "params": ["127.0.0.1:8888", "remove"], "id":1 }' localhost:8332
Connect to the node.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "addnode", "params": ["127.0.0.1:8888", "onetry"], "id":1 }' localhost:8332
##### getaddednodeinfo
Query info for all added nodes.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "id":"1", "method": "getaddednodeinfo", "params": [true] }' localhost:8332
Query info for the specified node.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "id":"1", "method": "getaddednodeinfo", "params": [true, "192.168.0.201"] }' localhost:8332
##### getconnectioncount
Get the peer count.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "id":"1", "method": "getconnectioncount", "params": [] }' localhost:8332
#### Blockchain
The Parity-bitcoin `blockchain` data interface.
##### getbestblockhash
Get hash of best block.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getbestblockhash", "params": [], "id":1 }' localhost:8332
##### getblockcount
Get height of best block.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getblockcount", "params": [], "id":1 }' localhost:8332
##### getblockhash
Get hash of block at given height.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getblockhash", "params": [0], "id":1 }' localhost:8332
##### getdifficulty
Get proof-of-work difficulty as a multiple of the minimum difficulty
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getdifficulty", "params": [], "id":1 }' localhost:8332
##### getblock
Get information on given block.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getblock", "params": ["000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"], "id":1 }' localhost:8332
##### gettxout
Get details about an unspent transaction output.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "gettxout", "params": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", 0], "id":1 }' localhost:8332
##### gettxoutsetinfo
Get statistics about the unspent transaction output set.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "gettxoutsetinfo", "params": [], "id":1 }' localhost:8332
#### Miner
The Parity-bitcoin `miner` data interface.
##### getblocktemplate
Get block template for mining.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}], "id":1 }' localhost:8332
#### Raw
The Parity-bitcoin `raw` data interface.
##### getrawtransaction
Return the raw transaction data.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "getrawtransaction", "params": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"], "id":1 }' localhost:8332
##### decoderawtransaction
Return an object representing the serialized, hex-encoded transaction.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "decoderawtransaction", "params": ["01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"], "id":1 }' localhost:8332
##### createrawtransaction
Create a transaction spending the given inputs and creating new outputs.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "createrawtransaction", "params": [[{"txid":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b","vout":0}],{"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}], "id":1 }' localhost:8332
##### sendrawtransaction
Adds transaction to the memory pool && relays it to the peers.
curl -H 'content-type: application/json' --data-binary '{"jsonrpc": "2.0", "method": "sendrawtransaction", "params": ["01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"], "id":1 }' localhost:8332
2016-12-14 05:36:31 -08:00
## Logging
2017-08-29 06:52:21 -07:00
This is a section only for developers and power users.
2016-12-14 05:36:31 -08:00
2017-08-29 06:52:21 -07:00
You can enable detailed client logging by setting the environment variable `RUST_LOG`, e.g.,
2016-12-14 05:36:31 -08:00
```
2017-09-03 22:36:31 -07:00
RUST_LOG=verification=info ./target/release/pbtc --segwit
2016-12-14 05:36:31 -08:00
```
2017-08-29 06:52:21 -07:00
`pbtc` started with this environment variable will print all logs coming from `verification` module with verbosity `info` or higher. Available log levels are:
2016-12-14 05:36:31 -08:00
- `error`
- `warn`
- `info`
- `debug`
- `trace`
It's also possible to start logging from multiple modules in the same time:
2016-12-14 05:36:31 -08:00
```
2017-09-03 22:36:31 -07:00
RUST_LOG=sync=trace,p2p=trace,verification=trace,db=trace ./target/release/pbtc --segwit
2016-12-14 05:36:31 -08:00
```
2016-12-14 05:43:55 -08:00
## Internal documentation
Once released, `pbtc` documentation will be available [here][doc-url]. Meanwhile it's only possible to build it locally:
```
cd parity-bitcoin
2016-12-15 07:04:54 -08:00
./tools/doc.sh
2016-12-14 05:43:55 -08:00
open target/doc/pbtc/index.html
```