Exercise: Set Up a Regtest Node

And now, the moment we've all been waiting for: let's actually run Bitcoin! We've learned enough, and we're ready! In this exercise, we'll download, install, configure, and run the Bitcoin core implementation.

We'll walk through instructions for linux(Ubuntu) machines in this document, but you can find instructions for other operating systems in this link: https://bitcoin.org/en/full-node.

There are a variety of ways to install Bitcoin, but for simplicity here, let's download it from https://bitcoincore.org/en/download/.

Note: Were we downloading this with the intention of running a mainnet node, we would also want to verify the release signature. You can find those instructions here, https://bitcoin.org/en/full-node#linux-instructions

Move the file to your home directory, or wherever you'd like the bitcoin data to live and extract the file being careful to update these commands to find the version that you have downloaded.

$ tar xzf bitcoin-0.21.1-x86_64-linux-gnu.tar.gz

 

For Ubuntu or similar systems you'll want to install the contents of bitcoin's bin subdirectory into the /usr/local/bin directory using the install command. You can adjust the below command to suit the needs of your system.

$ sudo install -m 0755 -o root -g root -t /usr/local/bin bitcoin-0.21.1/bin/*

 

Now the Bitcoin daemon, bitcoind, is ready to run. But before we start it up, we need to let it know that we don't want to connect to the mainnet, or the testnet, but instead, want to run our own local network via regtest. So let's create a configuration file and add some values.

Create a hidden bitcoin directory.

$ mkdir .bitcoin

 

Create the configuration file inside that directory.

$ touch .bitcoin/bitcoin.conf
$ vim bitcoin.conf

 

While the only instructions we really need to give bitcoind right now is to run on a regtest network, let's get in a bit of practice configuring bitcoind by walking through some common configuration options. Let's add the below options…

# Run Bitcoin as in daemon mode without an interactive shell
daemon=1

 

# Tell Bitcoin where to put blockchain data
datadir=/path/to/my/blockchain/data/.bitcoin/data

 

# Tell Bitcoin to run on a regtest network
regtest=1

 

Below are settings that we can skip for now, but that you'll want to be familiar with.

Remote Procedure Call, or RPC, https://en.wikipedia.org/wiki/Remote_procedure_call, is the way in which bitcoind interacts with other programs. To enable this interaction you'll need to set a password and turn on the RPC server.

# Set the RPC password
rpcauth=mysupersecurepassword

 

# Turn on the RPC server
server=1

 

ZeroMQ, or ZMQ, https://zeromq.org/, provides a method for bitcoind to share block and transaction information.

# Turn on ZMQ publishing
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

 

Once we get our configuration in place, let's start up bitcoind and check that it's working

$ bitcoind

 

We'll use the Bitcoin command line interface just as we did in the last exercise to talk to our Bitcoin regtest node.

$ bitcoin-cli -getinfo

 

If you get a response that looks like the below, then your regtest node is up and running and we'll try out some more commands in the next exercise!

 

{
"version": 210100,
"blocks": 0,
"headers": 0,
"verificationprogress": 1,
"timeoffset": 0,
"connections": {
		"in": 0,
	"out": 0,
	"total": 0
},
"proxy": "",
"difficulty": 4.656542373906925e-10,
"chain": "regtest",
"relayfee": 0.00001000,
"warnings": ""
}

Source: Saylor Academy
Creative Commons License This work is licensed under a Creative Commons Attribution 4.0 License.

Last modified: Tuesday, October 5, 2021, 4:31 PM