<p>You probably want to run multiple <code>bitcoind</code> instances in <code>regtest</code> 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.</p>

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

<p>Use something similar than:</p>

<pre><code>regtest=1
rpcuser=rt
rpcuser=rt
port=12340
rpcport=10340
discover=0
</code></pre>

<p>Now you need to connect your first node with your 2nd node by sending a <code>addnode</code> over the RPC interface.</p>

<pre><code>bitcoin-cli addnode 127.0.0.1:10340 onetry
</code></pre>

<p>You can than distinct between both nodes with the <code>-datadir</code> argument while calling <code>bitcoin-cli</code>.</p>

<pre><code>bitcoin-cli -datadir=/tmp/datadir2/ getinfo
</code></pre>

<h2>Some examples:</h2>

<p><strong>generate coins in first node (50 BTC available)</strong></p>

<pre><code>bitcoin-cli generate 101
</code></pre>

<p><strong>get address from 2nd node</strong></p>

<pre><code>bitcoin-cli -datadir=/tmp/datadir2/ getnewaddress
</code></pre>

<p><strong>send coins to 2nd node</strong></p>

<pre><code>bitcoin-cli sendtoaddress &lt;address&gt; 10.0
</code></pre>

CC BY-SA 3.0
2015-08-20T09:28:48.183Z
Thanks for the reply.  I had done the exact same thing and got it running. I was setting the datadir on my  host system to a separate directory when starting bitcoin-qt. This was somehow preventing my app from talking with bitcoin-qt.
plbit
CC BY-SA 4.0
2018-08-06T18:38:47.743Z
After doing the above, when I do `getmempoolinfo` for the node that receives the transaction, it still shows 0. How do I send the transaction over.
thenakulchawla
CC BY-SA 4.0
2018-08-09T10:39:25.400Z
Maybe the received funds are not yet confirmed,... call a generate(1) again or try to list unconfirmed balance
Jonas Schnelli
CC BY-SA 4.0
2019-01-10T12:37:22.820Z
I am trying to use the same above script but its adding the following error to the log

2019-01-10T12:35:51Z Binding RPC on address ::1 port 18443 failed.
2019-01-10T12:35:51Z Binding RPC on address 127.0.0.1 port 18443 failed.
2019-01-10T12:35:51Z Unable to bind any endpoint for RPC server
2019-01-10T12:35:51Z Error: Unable to start HTTP server. See debug log for details.
2019-01-10T12:35:51Z Shutdown: In progress...
Pankaj Kumar
CC BY-SA 4.0
2019-04-06T18:22:05.220Z
For the record, starting at 0.18 the command `generate` is deprecated and in 0.19 it will be completely removed. Use `generatetoaddress` instead.
thalisk
CC BY-SA 3.0
2015-08-20T08:32:16.560Z
2015-08-20T08:40:27.773Z
2015-08-20T08:40:27.773Z
Jonas Schnelli
<p>I am working on a app in which my project communicates with the bitcoin server to get the details of a transaction with transaction id as the parameter. I have bitcoind, bitcoin-cli and bitcoin-qt installed on my system. When I run the bitcoin-qt in regtest mode, I am able to create test transactions in which I can send money to an address and get the transaction id for the same. I use this transaction id in my app, I am able to get the transaction details from bitcoin-qt. The problem is, now my testing is limited to only outward transactions wherein I transfer bitcoins to another account. How can I create some test transactions wherein bitcoins are credited to my wallet?</p>

<bitcoind><testnet><regtest>
Receive money in regtest mode
plbit
# Receive money in regtest mode

(Asked by: username_0 on 2015-08-19)

I am working on a app in which my project communicates with the bitcoin server to get the details of a transaction with transaction id as the parameter. I have bitcoind, bitcoin-cli and bitcoin-qt installed on my system. When I run the bitcoin-qt in regtest mode, I am able to create test transactions in which I can send money to an address and get the transaction id for the same. I use this transaction id in my app, I am able to get the transaction details from bitcoin-qt. The problem is, now my testing is limited to only outward transactions wherein I transfer bitcoins to another account. How can I create some test transactions wherein bitcoins are credited to my wallet?

**Tags:** bitcoind, testnet, regtest


---

## 1 answers

### Answer by username_1 on 2015-08-20. Score: 9 | Accepted answer

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:
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.
bitcoin-cli addnode 127.0.0.1:10340 onetry

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

Some examples:
generate coins in first node (50 BTC available)
bitcoin-cli generate 101

get address from 2nd node
bitcoin-cli -datadir=/tmp/datadir2/ getnewaddress

send coins to 2nd node
bitcoin-cli sendtoaddress  10.0

> **Comments:**
> **username_0**: Thanks for the reply.  I had done the exact same thing and got it running. I was setting the datadir on my  host system to a separate directory when starting bitcoin-qt. This was somehow preventing my app from talking with bitcoin-qt.  
> **username_2**: After doing the above, when I do `getmempoolinfo` for the node that receives the transaction, it still shows 0. How do I send the transaction over.  
> **username_1**: Maybe the received funds are not yet confirmed,... call a generate(1) again or try to list unconfirmed balance  
> **username_3**: I am trying to use the same above script but its adding the following error to the log  2019-01-10T12:35:51Z Binding RPC on address ::1 port 18443 failed. 2019-01-10T12:35:51Z Binding RPC on address 127.0.0.1 port 18443 failed. 2019-01-10T12:35:51Z Unable to bind any endpoint for RPC server 2019-01-10T12:35:51Z Error: Unable to start HTTP server. See debug log for details. 2019-01-10T12:35:51Z Shutdown: In progress...  
> **username_4**: For the record, starting at 0.18 the command `generate` is deprecated and in 0.19 it will be completely removed. Use `generatetoaddress` instead.  

---

