Post
Topic
Board Bitcoin Technical Support
Merits 2 from 2 users
Re: How run multiple nodes in regtest/testnet mode on a single machine?
by
AdolfinWolf
on 24/10/2018, 15:39:34 UTC
⭐ Merited by seoincorporation (1) ,Cryddit (1)
OS:Windows 10
Bitcoin Core Version:0.16.0

How run multiple nodes in regtest/testnet mode on a single machine?
I want to test.

You mean something like this? https://olivermouse.wordpress.com/2018/01/13/connecting-multiple-bitcoin-core-nodes-regtest/

This might be a better answer. https://bitcoin.stackexchange.com/a/39168

Quote from: https://bitcoin.stackexchange.com/a/39168 By Jonas Schnelli
You probably want to run multiple bitcoind instances in regtest to simulate multiple nodes. Thats pretty easy. You can run a second instance by starting bitcoind with a clean data directory and a different RPC and P2P port.

For that, you could create a 2nd data directory (example: /tmp/datadir2). Create /tmp/datadir2/bitcoin.conf.

Use something similar than
Code:
regtest=1
rpcuser=rt
rpcuser=rt
port=12340
rpcport=10340
discover=0
Now you need to connect your first node with your 2nd node by sending a addnode over the RPC interface.
Code:
bitcoin-cli addnode 127.0.0.1:10340 onetry

You can than distinct between both nodes with the -datadir argument while calling bitcoin-cli.
Code:
bitcoin-cli -datadir=/tmp/datadir2/ getinfo

Some examples:

generate coins in first node (50 BTC available)

Code:
bitcoin-cli generate 101

get address from 2nd node

Code:
bitcoin-cli -datadir=/tmp/datadir2/ getnewaddress

send coins to 2nd node

Code:
bitcoin-cli sendtoaddress
10.0



I'm pretty sure you can add as many nodes as you want. Simply add another dir for each of them.