• Stars
    star
    726
  • Rank 60,172 (Top 2 %)
  • Language
    Rust
  • License
    GNU General Publi...
  • Created over 7 years ago
  • Updated 11 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The Parity Bitcoin client

The Parity Bitcoin client.

THIS IS UNMAINTAINED HISTORICAL SOFTWARE

Build Status Snap Status

Gitter Gitter https://gitter.im/paritytech/parity-bitcoin

Installing from source

Installing pbtc from source requires rustc and cargo.

Minimal supported version is rustc 1.23.0 (766bd11c8 2018-01-01)

Install rustc and cargo

Both rustc and cargo are a part of rust tool-chain.

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.

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

Clone and build pbtc

Now let's clone pbtc and enter it's directory:

git clone https://github.com/paritytech/parity-bitcoin
cd parity-bitcoin

pbtc can be build in two modes. --debug and --release. Debug is the default.

# 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.

Installing the snap

In any of the supported Linux distros:

sudo snap install parity-bitcoin --edge

Running tests

pbtc has internal unit tests and it conforms to external integration tests.

Running unit tests

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

cargo test --all

Running external integration tests

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

git submodule update --init

Now we can run them using the command:

./tools/regtests.sh

It is also possible to run regtests manually:

# let's start pbtc in regtest compatible mode
./target/release/pbtc --btc --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 available here.

Before starting synchronization, you must decide - which fork to follow - Bitcoin Core (--btc flag) or Bitcoin Cash (--bch 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.

To start syncing the main network, just start the client, passing selected fork flag. For example:

./target/release/pbtc --btc

To start syncing the testnet:

./target/release/pbtc --btc --testnet

To not print any syncing progress add --quiet flag:

./target/release/pbtc --btc --quiet

Importing bitcoind database

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"

By default import verifies imported the blocks. You can disable this, by adding --verification-level=none flag.

./target/release/pbtc --btc --verification-level=none import "$BITCOIND_DB/Bitcoin/blocks"

Command line interface

Full list of CLI options, which is available under pbtc --help:

pbtc 0.1.0
Parity Technologies <[email protected]>
Parity Bitcoin client

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

FLAGS:
        --bch             Use Bitcoin Cash verification rules (BCH).
        --btc             Use Bitcoin Core verification rules (BTC).
    -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.
        --testnet         Use the test network (Testnet3).
    -V, --version         Prints version information

OPTIONS:
        --blocknotify <COMMAND>            Execute COMMAND when the best block changes (%s in COMMAND is replaced by the block hash).
    -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).

SUBCOMMANDS:
    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.

JSON-RPC

The JSON-RPC interface is served on port :8332 for mainnet and :18332 for testnet unless you specified otherwise. So if you are using testnet, you will need to change the port in the sample curl requests shown below.

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

Logging

This is a section only for developers and power users.

You can enable detailed client logging by setting the environment variable RUST_LOG, e.g.,

RUST_LOG=verification=info ./target/release/pbtc --btc

pbtc started with this environment variable will print all logs coming from verification module with verbosity info or higher. Available log levels are:

  • error
  • warn
  • info
  • debug
  • trace

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

RUST_LOG=sync=trace,p2p=trace,verification=trace,db=trace ./target/release/pbtc --btc

Internal documentation

Once released, pbtc documentation will be available here. Meanwhile it's only possible to build it locally:

cd parity-bitcoin
./tools/doc.sh
open target/doc/pbtc/index.html

More Repositories

1

substrate

Substrate: The platform for blockchain innovators
Rust
8,212
star
2

polkadot

Polkadot Node Implementation
Rust
6,865
star
3

ink

Parity's ink! to write smart contracts.
Rust
1,316
star
4

wasmi

WebAssembly (Wasm) interpreter.
Rust
1,269
star
5

polkadot-sdk

The Parity Polkadot Blockchain SDK
Rust
979
star
6

jsonrpc

Rust JSON-RPC implementation
Rust
752
star
7

cumulus

Write Parachains on Substrate
Rust
618
star
8

parity-signer

Air-gapped crypto wallet.
Rust
539
star
9

frontier

Ethereum compatibility layer for Substrate.
Rust
496
star
10

polkadot-launch

Simple CLI tool to launch a local Polkadot test network
TypeScript
458
star
11

jsonrpsee

Rust JSON-RPC library on top of async/await
Rust
457
star
12

parity-wasm

WebAssembly serialization/deserialization in rust
Rust
395
star
13

subxt

Submit extrinsics (transactions) to a substrate node via RPC
Rust
317
star
14

parity-bridge

Rust
317
star
15

smoldot

Alternative client for Substrate-based chains.
Rust
286
star
16

parity-common

Collection of crates used in Parity projects
Rust
274
star
17

substrate-telemetry

Polkadot Telemetry service
Rust
268
star
18

parity-bridges-common

Collection of Useful Bridge Building Tools 🏗️
Rust
265
star
19

banana_split

Shamir's Secret Sharing for people with friends
TypeScript
259
star
20

parity-db

Experimental blockchain database
Rust
245
star
21

parity-scale-codec

Lightweight, efficient, binary serialization and deserialization codec
Rust
238
star
22

cargo-contract

Setup and deployment tool for developing Wasm based smart contracts via ink!
Rust
226
star
23

substrate-api-sidecar

REST service that makes it easy to interact with blockchain nodes built using Substrate's FRAME framework.
TypeScript
226
star
24

substrate-connect

Run Wasm Light Clients of any Substrate based chain directly in your browser.
TypeScript
217
star
25

trie

Base-16 Modified Patricia Merkle Tree (aka Trie)
Rust
201
star
26

substrate-archive

Blockchain Indexing Engine
Rust
197
star
27

shasper

Parity Shasper beacon chain implementation using the Substrate framework.
Rust
196
star
28

parity-zcash

Rust implementation of Zcash protocol
Rust
183
star
29

cachepot

cachepot is `sccache` with extra sec, which in turn is `ccache` with cloud storage
Rust
174
star
30

libsecp256k1

Pure Rust Implementation of secp256k1.
Rust
166
star
31

homebrew-paritytech

Homebrew tap for ethcore
Ruby
160
star
32

zombienet

A cli tool to easily spawn ephemeral Polkadot/Substrate networks and perform tests against them.
TypeScript
150
star
33

polkadot-staking-dashboard

A dashboard for Polkadot staking, nomination pools, and everything around it.
TypeScript
146
star
34

xcm-format

Polkadot Cross Consensus-system Message format.
143
star
35

finality-grandpa

finality gadget for blockchains using common prefix agreement
Rust
139
star
36

substrate-contracts-node

Minimal Substrate node configured for smart contracts via pallet-contracts.
Rust
116
star
37

capi

[WIP] A framework for crafting interactions with Substrate chains
TypeScript
105
star
38

grandpa-bridge-gadget

A Bridge Gadget to Grandpa Finality.
Rust
99
star
39

substrate-debug-kit

A collection of debug tools, scripts and libraries on top of substrate.
Rust
95
star
40

ink-examples

A set of examples for ink! smart contract language. Happy hacking!
Rust
89
star
41

wasm-utils

Rust
82
star
42

subport

Parity Substrate(-based) chains usage and development support
Rust
81
star
43

trappist

Rust
80
star
44

substrate-playground

Start hacking your substrate runtime in a web based VSCode like IDE
TypeScript
74
star
45

scale-info

Info about SCALE encodable Rust types
Rust
73
star
46

parity-tokio-ipc

Parity tokio-ipc
Rust
73
star
47

substrate-light-ui

Minimal, WASM-light-client-bundled Substrate wallet for balance transfers
TypeScript
72
star
48

substrate-ui

Bondy Polkadot UI
JavaScript
72
star
49

statemint

Statemint Node Implementation
Rust
72
star
50

txwrapper-core

Tools for FRAME chain builders to publish chain specific offline transaction generation libraries.
TypeScript
71
star
51

canvas

Node implementation for Canvas ‒ a Substrate parachain for smart contracts.
Rust
69
star
52

substrate-up

Scripts for working with new Substrate projects
Shell
66
star
53

useink

A React hooks library for ink!
TypeScript
62
star
54

stateless-blockchain

Stateless Blockchain on Substrate using RSA Accumulators
Rust
60
star
55

txwrapper

Helper funtions for offline transaction generation.
TypeScript
59
star
56

contracts-ui

Web application for deploying wasm smart contracts on Substrate chains that include the FRAME contracts pallet
TypeScript
58
star
57

awesome-ink

A curated list of awesome projects related to Parity's ink!.
56
star
58

srtool

A fork of chevdor's srtool
Shell
56
star
59

ss58-registry

Registry for SS58 account types
Rust
55
star
60

cargo-unleash

cargo release automatisation tooling for massiv mono-repos
Rust
55
star
61

oo7

The Bonds framework along with associated modules.
JavaScript
53
star
62

diener

Diener - dependency diener is a tool for easily changing https://github.com/paritytech/substrate or https://github.com/paritytech/polkadot dependency versions
Rust
52
star
63

lunarity

Lunarity - a Solidity parser in Rust
Rust
50
star
64

nohash-hasher

An implementation of `std :: hash :: Hasher` which does not hash at all.
Rust
49
star
65

arkworks-extensions

Library to integrate arkworks-rs/algebra into Substrate
Rust
44
star
66

wasm-instrument

Instrument and transform wasm modules.
Rust
44
star
67

fleetwood

Testbed repo for trying out ideas of what a smart contract API in Rust would look like
Rust
41
star
68

scripts

Collection of Dockerfiles, scripts and related resources
Dockerfile
41
star
69

trappist-extra

Dart
38
star
70

parity-extension

Parity Chrome Extension
JavaScript
37
star
71

rhododendron

Asynchronously safe BFT consensus, implementation in Rust
Rust
36
star
72

desub

Decode Substrate with Backwards-Compatible Metadata
Rust
36
star
73

ethkey

Ethereum key generator
Rust
35
star
74

asset-transfer-api

Typescript API aiming to provide clear, and simple to use tools for transferring assets across common good parachains.
TypeScript
35
star
75

substrate-bip39

Rust
34
star
76

primitives

Rust
34
star
77

parity-config-generator

Parity Config Generator
JavaScript
34
star
78

polkadot-introspector

A collection of tools focused on debugging and monitoring the relay chain and parachain progress from a 🐦-view
Rust
34
star
79

substrate-open-working-groups

The Susbstrate Open Working Groups (SOWG) are community-based mechanisms to develop standards, specifications, implementations, guidelines or general initiatives in regards to the Substrate framework. It could, but not restricted to, lead to new Polkadot Standards Proposals. SOWG is meant as a place to find and track ongoing efforts and enable everybody with similar interests to join and contribute.
34
star
80

Nomidot

Staking Portal for Polkadot and Kusama
TypeScript
32
star
81

subdb

Experimental domain-specific database for Substrate
Rust
32
star
82

polkadot-api

TypeScript
31
star
83

polkassembly

Polkassembly now has a new home:
TypeScript
30
star
84

pallet-contracts-waterfall

Collection of simple Substrate smart contract examples written in Rust, AssemblyScript, Solang and the smart contract language ink! to test substrates pallet-contracts module
TypeScript
30
star
85

vscode-substrate

Substrate Marketplace VSCode Plugin
TypeScript
28
star
86

oo7-bare

The Bond API.
JavaScript
27
star
87

metadata-portal

Metadata portal for Parity Signer
TypeScript
27
star
88

bigint

Rust
27
star
89

sub-flood

Flooding substrate node with transactions
TypeScript
26
star
90

polkadot-scripts

Collection of random scripts and utilities written for Polkadot
TypeScript
26
star
91

polkadot-cloud

[BETA] A library and automated platform for developing and publishing assets for Polkadot dapps.
TypeScript
25
star
92

ink-playground

Browser Based Playground for editing, sharing & compiling ink! Smart Contracts
Rust
25
star
93

sms-verification

SMS verification for Parity.
JavaScript
25
star
94

link

Unstoppable URL shortener built with the ink! smart contract language.
TypeScript
25
star
95

extended-parachain-template

Node template to build parachains with all the required pallets. Slightly opinionated based on what majority of parachain teams are using.
Rust
25
star
96

parachains-integration-tests

Tool to make Parachains integrations tests development easier and faster
TypeScript
25
star
97

orchestra

A partial actor pattern with a global orchestrator.
Rust
25
star
98

zombienet-sdk

ZombieNet SDK
Rust
25
star
99

polkadot-onboard

A wallet integration SDK to facilitate adding different type of wallets (extension, WC, Ledger) to Dapps.
TypeScript
24
star
100

frame-metadata

A set of tools to parse FRAME metadata retrieved from Substrate-based nodes.
Rust
24
star