How To Run Multiple Bitcoin Blockchain Networks On The Same Computer

Raphael Osaze Eyerin
4 min readJul 7, 2022
My Bitcoin node running on the Signet network

I felt the need to write on this when someone asked me how he could run multiple Bitcoin networks on the same computer, I gave him the answers he needed but I also believe an article will help other people in the future, who may want to do the same.

Why have multiple networks on your machine

Before moving to the Bitcoin mainnet network other networks are recommended for testing to get a feel of what really happens on the mainnet network without so much cost.

To work on the mainnet network you need actual bitcoins which will cost you some money, so you may want to use another network that won’t cost you more than your internet bandwidth for testing your applications, It will become stressful to manage both networks if you have to run them on different computers if you choose to install your Bitcoin node on your computer and not any other type of device where you can install a Bitcoin node.

Usage of a specialist test network (e.g. Signet or Regtest) can permit faster iteration during testing, rather than having to wait an unpredictable time between blocks.

Setting up your bitcoin node

To install the Bitcoin node on your computer clone the Bitcoin implementation from its repository to your desired folder (Bitcoin core is Bitcoin’s reference implementation, but there are other available implementations).

git clone https://github.com/bitcoin/bitcoin.git

To build Bitcoin core view Install.md to see the build process for your computer, also check the required dependencies needed to build successfully this will be found in dependencies.md.

After building a bitcoin directory will be added to your Application Support folder (for Mac users, it may be different for Windows users).

// My Bitcoin core path on my Mac operating system/Users/apple/Library/Application Support/Bitcoin

Note: You can also install a Bitcoin node by downloading the executable file for your operating system, but there is a popular phrase in the Bitcoin community “Don’t trust, verify”. If you trust the website the Bitcoin executable is being downloaded from you can choose this method of installation.

By default, your Bitcoin node will run on the mainnet network if you want to change this create a bitcoin.conf file in your Bitcoin install directory and change the Bitcoin network

bitcoin.conf file

# Daemon Optionsserver=1
daemon=1
fallbackfee=0.00072
txconfirmtarget=6
# Network Options
signet=1
# RPC Options
[signet]
rpcport=18443
rpcuser=test
rpcpassword=test
# ZMQ Options
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333
zmqpubhashtx=tcp://127.0.0.1:28332
zmqpubhashblock=tcp://127.0.0.1:28332

This bitcoin.conf file will make my Bitcoin node run on the Signet network.

Note: You have to add the network in square brackets [] [signet], to enable your Bitcoin to pick up the port, and authentication configurations.

Bitcoin network types

Mainnet

Bitcoin mainnet blockchain network is the actual Bitcoin blockchain where your bitcoins are actually valuable.

To run the Bitcoin mainnet on your device, you need to have 450GB of disk space, RAM, and also internet bandwidth.

Testnet

The basic difference between the mainnet network and testnet is that testnet coins are worthless, and mining difficulty on the testnet network is lower than that of mainnet, this can lead to unexpected behavior sometimes: thousands of blocks arriving suddenly, and then perhaps no blocks for long periods of time

Testnet is also used as a testing ground for new bitcoin improvements before they go live on the mainnet network.

Signet

Signet is a test network that allows developers to create their own networks for testing.

Regtest

Regtest (Regression Testing) is a local/private testing environment for Bitcoin Core functionalities.

Bash profile aliases to the rescue

Without using bash aliases, you have to edit the bitcoin.conf file in the root directory of your Bitcoin installation to the network of your choice, the network should be set to 1 e.g regtest=1, but with aliases, you can specify a different data directory for each network and also a different bitcoin.conf files so you wouldn't have to update your root bitcoin.conf file every time you need a change of network.

#regtest=1
signet=1
#testnet=1

To use aliases create a new directory with a name of your choice, I prefer using the network name for mine e.g signet, then create a bitcoin.conf file in the newly created directory

touch bitcoin.conf

bitcoin.conf file for my regtest directory

regtest=1
daemon=1
fallbackfee=0
rpcuser=user
rpcpassword=password
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

After creating your bitcoin.conf file, open your bash profile and add an alias that points to the newly-created directory.

nano ~/.bash_profile

This is the command I use on mac os, it should be different on other operating systems, then add new aliases and point the data directory (-datadir) to your newly created directory

alias regtest-cli="bitcoin-cli -datadir=$HOME/regtest/bitcoin"
alias regtestd="bitcoind -datadir=$HOME/regtest/bitcoin"

When done with updating your .bash_profile, open a new terminal or refresh your system environments, then you can start your bitcoind using the alias command.

regtestd
regtest-cli

Conclusion

If you are comfortable with editing your bitcoin.conf file in your Bitcoin installation directory every now and then when you need to change your Bitcoin blockchain network you can choose not to use .bash_profile aliases.

Creating different directories for each network and using .bash_profile aliases comes in handy when you also need to work with Bitcoin layer 2 solutions that are dependent on Bitcoin to run successfully e.g Lightning Network, you can also add your Lightning config file e.g (lnd.conf) in the directory created and also use aliases to point to it.

alias lncli1="lncli --lnddir=$HOME/regtest/lnd1 --network=regtest"

Using .bash_profile aliases makes switching between Bitcoin networks on your computer seamless.

If you are an African developer and you are interested in transitioning into Bitcoin development, the Qala program is perfect for you, consider registering for the next Qala cohort.

Thank you.

--

--