Tutorial · Regtest

Start a Regtest Node

Run a Divi node on a chain that only you control, make its first 100 blocks in under a second, and send yourself a payment. Everything here runs on one computer and costs nothing.

About 10 minutes · Checked 2026-10-21
New to regtest?

Read what regtest is first. In short: regtest is a private Divi network with no other nodes, where blocks appear only when you ask for them. Coins made on it are not worth anything and never leave your computer.

1What you need

You do not need coins, a wallet file, an account or an internet connection once the software is downloaded. The node makes its own coins.

IronDivi users

IronDivi, the Rust node, can run on regtest but cannot make regtest blocks yet: its setgenerate answers setgenerate is not yet implemented. Use C++ Divi for this page. The next tutorial adds IronDivi as a second node that follows this one.

2Make a folder and a settings file

Give the regtest node its own data folder, so it never touches a mainnet or testnet wallet you may have. Inside it, a file called divi.conf tells the node which network to run and how to accept commands.

# a folder of your own for this node
mkdir -p ~/divi-regtest

# the settings file
cat > ~/divi-regtest/divi.conf <<'EOF'
regtest=1
server=1
rpcuser=regtest
rpcpassword=choose-a-long-random-password
staking=0
EOF

What each line does:

LineMeaning
regtest=1Run the regtest network. The node then uses the regtest/ subfolder, peer port 51476 and RPC port 51475, and makes blocks on demand.
server=1Accept commands from divi-cli (and from your own programs) over RPC.
rpcuser, rpcpasswordThe name and password those commands must present. divi-cli reads them from this same file, so you never type them. Pick anything long; only programs on this computer can reach the node.
staking=0Do not try to stake. On regtest you make blocks by hand, and this keeps the node from trying to make its own once your coins have matured.
Change the password line

Replace choose-a-long-random-password with something random before you start the node. Nothing on this page needs you to type it again. Keep divi.conf out of any folder you share or commit to git.

3Start the node

Start divid as a background process, pointing it at your folder. Every later command uses the same -datadir, so the command tool finds the settings file and knows it is talking to a regtest node.

divid -datadir=~/divi-regtest -daemon
DIVI server starting

# give it a few seconds, then:
divi-cli -datadir=~/divi-regtest getblockchaininfo

For the first few seconds the node answers with Loading wallet... or Connecting best block... and an error code of -28. That is not a fault: it is still starting. Try again a moment later and you get the chain:

{
    "chain" : "regtest",
    "blocks" : 0,
    "headers" : 0,
    "bestblockhash" : "0000000b3f9980dcf71f5f52d69e30d3b02f807e0a77b91b6091701e4ae51a6f",
    ...
}

"chain" : "regtest" is the line to check. blocks is 0 because the chain so far is only the built-in first block (the genesis block), and the bestblockhash above is that block's hash. It is the same on every regtest node in the world, because it is written into the software. Every block after it will be yours alone.

Look inside your folder and you will see what the node made:

ls ~/divi-regtest ~/divi-regtest/regtest
~/divi-regtest:
divi.conf  regtest

~/divi-regtest/regtest:
blocks  chainstate  database  db.log  debug.log  divid.pid  sporks  wallet.dat

Everything about this chain lives in the regtest/ subfolder: the blocks, the wallet (wallet.dat) and the log (debug.log). Your divi.conf stays one level up.

Block hashes on this page will not match yours

From block 1 on, every regtest chain is different: the time and your wallet's keys go into each block. The genesis hash and the balances will match; the other hashes and the transaction ids will not. The output shown here was captured on a shared test machine, where the node ran on ports 53830 and 53831 instead of the defaults so it would not collide with other nodes; on your own computer, leave the ports alone.

4Make your first block

On regtest, setgenerate with a number makes that many blocks at once and pays their rewards to your node's wallet. Make one:

divi-cli -datadir=~/divi-regtest setgenerate 1
[
    "528abf28d341837fad7645f3b5c00bd0546c4f681f494e126c50254a99cce10a"
]

divi-cli -datadir=~/divi-regtest getwalletinfo
{
    "balance" : 0.00000000,
    "immature_balance" : 1250.00000000,
    "spendable_balance" : 0.00000000,
    "txcount" : 1,
    ...
}

The answer is the hash of the block you just made. The wallet now shows 1,250 DIVI, but as immature: a block reward cannot be spent until 20 more blocks sit on top of it. That rule is the same on mainnet, where 20 blocks take 20 minutes. Here it takes one command.

DIVI per block, for the first 100 blocks
1,250
blocks before a reward can be spent
20
to make 80 blocks on a small server
0.3 s

5Make 100 more

Make 20 blocks and the first reward matures; make another 80 and you have a chain of 101 blocks with 100,000 DIVI to spend:

divi-cli -datadir=~/divi-regtest setgenerate 20 > /dev/null
divi-cli -datadir=~/divi-regtest getwalletinfo
{
    "balance" : 1250.00000000,
    "immature_balance" : 25000.00000000,
    "spendable_balance" : 1250.00000000,
    "txcount" : 21,
    ...
}

divi-cli -datadir=~/divi-regtest setgenerate 80 > /dev/null
divi-cli -datadir=~/divi-regtest getwalletinfo
{
    "balance" : 100000.00000000,
    "spendable_balance" : 100000.00000000,
    "txcount" : 101,
    ...
}

divi-cli -datadir=~/divi-regtest getblockcount
101

The > /dev/null only hides the long list of block hashes. The arithmetic: at height 21 one reward (block 1) has 20 blocks on top of it, so 1,250 is spendable and the other 20 rewards are still maturing. At height 101, blocks 1 to 81 have matured, which is 81 rewards. Block 101 is the first staked block: it locked one matured 1,250 coin back up inside its own reward, so 80 × 1,250 = 100,000 DIVI is spendable.

Why 101 is the usual starting point

Regtest switches from "proof of work" blocks to staked blocks after block 100, the way the real chain once did, and from height 101 the lottery and treasury payments start. A chain of 101 blocks with 100,000 DIVI spendable is the normal starting state for every other regtest tutorial here, and a script can rebuild it in seconds. What happens to the rewards after block 100 is the subject of give yourself coins.

6Send yourself a payment

A payment on regtest goes through the same three stages as on mainnet: it is made, it waits in the mempool, and it is confirmed by a block. The difference is that you make the block.

# a fresh address in the same wallet
divi-cli -datadir=~/divi-regtest getnewaddress
yDyxj2EtxpX9VLMUPye6vYyYARwdMbNu2E

divi-cli -datadir=~/divi-regtest sendtoaddress yDyxj2EtxpX9VLMUPye6vYyYARwdMbNu2E 123.45
356d2e19b07f76b2299183e24cef0ef0efc93026359f2c12c61447670a870d33

# waiting for a block
divi-cli -datadir=~/divi-regtest getrawmempool
[
    "356d2e19b07f76b2299183e24cef0ef0efc93026359f2c12c61447670a870d33"
]

# make the block that confirms it
divi-cli -datadir=~/divi-regtest setgenerate 1
divi-cli -datadir=~/divi-regtest gettransaction 356d2e19b07f76b2299183e24cef0ef0efc93026359f2c12c61447670a870d33
{
    "amount" : -0.00002260,
    "fee" : 0.00002260,
    "confirmations" : 1,
    "blockhash" : "163c205553891647aad42619e4069d1dd1356a4d62556f5227e9e4ca4bb8ccb7",
    ...
}

Regtest addresses start with x or y, like testnet ones. The payment went from your wallet to your wallet, so the only change in the balance is the fee, about 0.00002 DIVI. Until you ran setgenerate 1 the payment had zero confirmations and would have stayed that way forever: nobody else is making blocks.

7Stop, restart, start over

# stop the node cleanly
divi-cli -datadir=~/divi-regtest stop
DIVI server stopping

# start it again later: the chain and the wallet are still there
divid -datadir=~/divi-regtest -daemon
divi-cli -datadir=~/divi-regtest getblockcount
102

To throw the chain away and begin from block 0, stop the node, delete the regtest/ subfolder and start again. Your divi.conf is outside that folder, so it survives:

divi-cli -datadir=~/divi-regtest stop
rm -rf ~/divi-regtest/regtest
divid -datadir=~/divi-regtest -daemon
Check the path before you delete

That rm -rf deletes the regtest wallet too, which is fine: regtest coins are worthless and the next setgenerate makes more. Make sure the path really is your regtest folder and not a mainnet data folder, which holds a wallet you cannot replace.

8What next

If something goes wrong

You seeWhat it meansDo this
error: couldn't connect to serverdivi-cli is looking for a node on a different port, usually because -datadir was left off and it tried the mainnet port.Add -datadir=~/divi-regtest to the command, and check the node is running with pgrep divid.
{"code":-28,"message":"Loading wallet..."} or Connecting best block...The node is still starting.Wait a few seconds and run the command again.
Method disabled: invalid networks setting (regtest only)You ran setgenerate against a node that is not on regtest.Check regtest=1 is in the divi.conf of the folder you passed as -datadir, then restart the node.
setgenerate is not yet implementedYou are talking to IronDivi, which cannot make regtest blocks.Make the blocks with C++ Divi; IronDivi can follow it (next tutorial).
"chain" : "test" or "main" in getblockchaininfoThe node started on the wrong network.Stop it, check divi.conf says regtest=1 and nothing says testnet=1, and start again.
Balance stays 0 after setgenerateRewards sit in immature_balance for 20 blocks.Run getwalletinfo and look at immature_balance, or make 20 more blocks.
Port already in use when startingAnother node (testnet uses the same RPC port 51475) or another regtest node is running.Stop the other node, or add port= and rpcport= lines with free numbers to divi.conf.

Still stuck? Ask the Divi chatbot, or see all tutorials.