f21410e47c
This adds a full-blown testing infrastructure in order to test consensus validation rules. It is built around the idea of dynamically generating full blocks that target specific rules linked together to form a block chain. In order to properly test the rules, each test instance starts with a valid block that is then modified in the specific way needed to test a specific rule. Blocks which exercise following rules have been added for this initial version. These tests were largely ported from the original Java-based 'official' block acceptance tests as well as some additional tests available in the Core python port. It is expected that further tests can be added over time as consensus rules change. * Enough valid blocks to have a stable base of mature coinbases to spend for futher tests * Basic forking and chain reorganization * Double spends on forks * Too much proof-of-work coinbase (extending main chain, in block that forces a reorg, and in a valid fork) * Max and too many signature operations via various combinations of OP_CHECKSIG, OP_MULTISIG, OP_CHECKSIGVERIFY, and OP_MULTISIGVERIFY * Too many and max signature operations with offending sigop after invalid data push * Max and too many signature operations via pay-to-script-hash redeem scripts * Attempt to spend tx created on a different fork * Attempt to spend immature coinbase (on main chain and fork) * Max size block and block that exceeds the max size * Children of rejected blocks are either orphans or rejected * Coinbase script too small and too large * Max length coinbase script * Attempt to spend tx in blocks that failed to connect * Valid non-coinbase tx in place of coinbase * Block with no transactions * Invalid proof-of-work * Block with a timestamp too far in the future * Invalid merkle root * Invalid proof-of-work limit (bits header field) * Negative proof-of-work limit (bits header field) * Two coinbase transactions * Duplicate transactions * Spend from transaction that does not exist * Timestamp exactly at and one second after the median time * Blocks with same hash via merkle root tricks * Spend from transaction index that is out of range * Transaction that spends more that its inputs provide * Transaction with same hash as an existing tx that has not been fully spent (BIP0030) * Non-final coinbase and non-coinbase txns * Max size block with canonical encoding which exceeds max size with non-canonical encoding * Spend from transaction earlier in same block * Spend from transaction later in same block * Double spend transaction from earlier in same block * Coinbase that pays more than subsidy + fees * Coinbase that includes subsidy + fees * Invalid opcode in dead execution path * Reorganization of txns with OP_RETURN outputs * Spend of an OP_RETURN output * Transaction with multiple OP_RETURN outputs * Large max-sized block reorganization test (disabled by default since it takes a long time and a lot of memory to run) Finally, the README.md files in the main and docs directories have been updated to reflect the use of the new testing framework. |
||
---|---|---|
.. | ||
code_contribution_guidelines.md | ||
configure_peer_server_listen_interfaces.md | ||
configure_rpc_server_listen_interfaces.md | ||
configuring_tor.md | ||
default_ports.md | ||
json_rpc_api.md | ||
README.md | ||
using_bootstrap_dat.md |
Table of Contents
### 1. About btcd is a full node bitcoin implementation written in [Go](http://golang.org), licensed under the [copyfree](http://www.copyfree.org) ISC License.This project is currently under active development and is in a Beta state. It is extremely stable and has been in production use since October 2013.
It properly downloads, validates, and serves the block chain using the exact rules (including consensus bugs) for block acceptance as Bitcoin Core. We have taken great care to avoid btcd causing a fork to the block chain. It includes a full block validation testing framework which contains all of the 'official' block acceptance tests (and some additional ones) that is run on every pull request to help ensure it properly follows consensus. Also, it passes all of the JSON test data in the Bitcoin Core code.
It also properly relays newly mined blocks, maintains a transaction pool, and relays individual transactions that have not yet made it into a block. It ensures all individual transactions admitted to the pool follow the rules required by the block chain and also includes more strict checks which filter transactions based on miner requirements ("standard" transactions).
One key difference between btcd and Bitcoin Core is that btcd does NOT include wallet functionality and this was a very intentional design decision. See the blog entry here for more details. This means you can't actually make or receive payments directly with btcd. That functionality is provided by the btcwallet and Paymetheus (Windows-only) projects which are both under active development.
### 2. Getting Started **2.1 Installation**The first step is to install btcd. See one of the following sections for details on how to install on the supported operating systems.
**2.1.1 Windows Installation**- Install the MSI available at: https://github.com/btcsuite/btcd/releases
- Launch btcd from the Start Menu
-
Install Go according to the installation instructions here: http://golang.org/doc/install
-
Ensure Go was installed properly and is a supported version:
$ go version
$ go env GOROOT GOPATH
NOTE: The GOROOT
and GOPATH
above must not be the same path. It is
recommended that GOPATH
is set to a directory in your home directory such as
~/goprojects
to avoid write permission issues. It is also recommended to add
$GOPATH/bin
to your PATH
at this point.
- Run the following commands to obtain btcd, all dependencies, and install it:
$ go get -u github.com/Masterminds/glide
$ git clone https://github.com/btcsuite/btcd $GOPATH/src/github.com/btcsuite/btcd
$ cd $GOPATH/src/github.com/btcsuite/btcd
$ glide install
$ go install . ./cmd/...
- btcd (and utilities) will now be installed in
$GOPATH/bin
. If you did not already add the bin directory to your system path during Go installation, we recommend you do so now.
Updating
- Run the following commands to update btcd, all dependencies, and install it:
$ cd $GOPATH/src/github.com/btcsuite/btcd
$ git pull && glide install
$ go install . ./cmd/...
**2.1.2.1 Gentoo Linux Installation**- Install Layman and enable the Bitcoin overlay.
- https://gitlab.com/bitcoin/gentoo
- Copy or symlink
/var/lib/layman/bitcoin/Documentation/package.keywords/btcd-live
to/etc/portage/package.keywords/
- Install btcd:
$ emerge net-p2p/btcd
btcd has a number of configuration
options, which can be viewed by running: $ btcd --help
.
btcctl is a command line utility that can be used to both control and query btcd via RPC. btcd does not enable its RPC server by default; You must configure at minimum both an RPC username and password or both an RPC limited username and password:
- btcd.conf configuration file
[Application Options]
rpcuser=myuser
rpcpass=SomeDecentp4ssw0rd
rpclimituser=mylimituser
rpclimitpass=Limitedp4ssw0rd
- btcctl.conf configuration file
[Application Options]
rpcuser=myuser
rpcpass=SomeDecentp4ssw0rd
OR
[Application Options]
rpclimituser=mylimituser
rpclimitpass=Limitedp4ssw0rd
For a list of available options, run: $ btcctl --help
btcd supports both the `getwork` and `getblocktemplate` RPCs although the `getwork` RPC is deprecated and will likely be removed in a future release. The limited user cannot access these RPCs.
1. Add the payment addresses with the miningaddr
option.
[Application Options]
rpcuser=myuser
rpcpass=SomeDecentp4ssw0rd
miningaddr=12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX
miningaddr=1M83ju3EChKYyysmM2FXtLNftbacagd8FR
2. Add btcd's RPC TLS certificate to system Certificate Authority list.
cgminer
uses curl to fetch data from the RPC server.
Since curl validates the certificate by default, we must install the btcd
RPC
certificate into the default system Certificate Authority list.
Ubuntu
- Copy rpc.cert to /usr/share/ca-certificates:
# cp /home/user/.btcd/rpc.cert /usr/share/ca-certificates/btcd.crt
- Add btcd.crt to /etc/ca-certificates.conf:
# echo btcd.crt >> /etc/ca-certificates.conf
- Update the CA certificate list:
# update-ca-certificates
3. Set your mining software url to use https.
$ cgminer -o https://127.0.0.1:8334 -u rpcuser -p rpcpassword
Typically btcd will run and start downloading the block chain with no extra
configuration necessary, however, there is an optional method to use a
bootstrap.dat
file that may speed up the initial block chain download process.
* [Using bootstrap.dat](https://github.com/btcsuite/btcd/tree/master/docs/using_bootstrap_dat.md) **3.1.2 Network Configuration**
* [What Ports Are Used by Default?](https://github.com/btcsuite/btcd/tree/master/docs/default_ports.md) * [How To Listen on Specific Interfaces](https://github.com/btcsuite/btcd/tree/master/docs/configure_peer_server_listen_interfaces.md) * [How To Configure RPC Server to Listen on Specific Interfaces](https://github.com/btcsuite/btcd/tree/master/docs/configure_rpc_server_listen_interfaces.md) * [Configuring btcd with Tor](https://github.com/btcsuite/btcd/tree/master/docs/configuring_tor.md) **3.1 Wallet**
btcd was intentionally developed without an integrated wallet for security reasons. Please see btcwallet for more information.
### 4. Contact **4.1 IRC*** [irc.freenode.net](irc://irc.freenode.net), channel #btcd **4.2 Mailing Lists**
* btcd: discussion of btcd and its packages. * btcd-commits: readonly mail-out of source code changes. ### 5. Developer Resources * [Code Contribution Guidelines](https://github.com/btcsuite/btcd/tree/master/docs/code_contribution_guidelines.md) * [JSON-RPC Reference](https://github.com/btcsuite/btcd/tree/master/docs/json_rpc_api.md) * [RPC Examples](https://github.com/btcsuite/btcd/tree/master/docs/json_rpc_api.md#ExampleCode) * The btcsuite Bitcoin-related Go Packages: * [btcrpcclient](https://github.com/btcsuite/btcrpcclient) - Implements a robust and easy to use Websocket-enabled Bitcoin JSON-RPC client * [btcjson](https://github.com/btcsuite/btcjson) - Provides an extensive API for the underlying JSON-RPC command and return values * [wire](https://github.com/btcsuite/btcd/tree/master/wire) - Implements the Bitcoin wire protocol * [peer](https://github.com/btcsuite/btcd/tree/master/peer) - Provides a common base for creating and managing Bitcoin network peers. * [blockchain](https://github.com/btcsuite/btcd/tree/master/blockchain) - Implements Bitcoin block handling and chain selection rules * [txscript](https://github.com/btcsuite/btcd/tree/master/txscript) - Implements the Bitcoin transaction scripting language * [btcec](https://github.com/btcsuite/btcd/tree/master/btcec) - Implements support for the elliptic curve cryptographic functions needed for the Bitcoin scripts * [database](https://github.com/btcsuite/btcd/tree/master/database) - Provides a database interface for the Bitcoin block chain * [btcutil](https://github.com/btcsuite/btcutil) - Provides Bitcoin-specific convenience functions and types * [chainhash](https://github.com/btcsuite/btcd/tree/master/chaincfg/chainhash) - Provides a generic hash type and associated functions that allows the specific hash algorithm to be abstracted.