Guides / Bitcoin regtest
Bitcoin regtest, your private testnet
regtest is a local chain you fully control, where you mine blocks on demand and confirmations happen instantly, ideal for automated tests and fast iteration.
On this page
What regtest is
regtest (regression test mode) is a private Bitcoin chain that runs entirely on your own machine. You are the only miner, blocks get made only when you ask for them, and nothing ever touches the internet. That means no waiting for a block, no competing for coins, and no shared state with anyone else.
The coins on regtest are even more worthless than public testnet coins, because they never leave your computer. You mine them yourself in a fresh chain that starts from block zero, and you can throw the whole thing away and start over whenever you like.
Public testnet is a shared network with real timing: blocks arrive roughly every few minutes, other people are using it, and you claim coins from a faucet. regtest is the opposite. It is solo, and time moves only when you say so. Use public testnet when you want realistic conditions, and regtest when you want speed and full control.
Start it
You need Bitcoin Core installed (the same bitcoind and bitcoin-cli you would use for a Bitcoin testnet node). Launch the daemon in regtest mode, then check that it is running:
bitcoind -regtest -daemon
bitcoin-cli -regtest getblockchaininfoThe getblockchaininfo output shows "chain": "regtest" and a block height of 0 on a fresh chain. Every command below passes -regtest so it talks to this private chain and not to mainnet or testnet.
Make a wallet and address
Create a wallet, then generate an address to mine to and receive with:
bitcoin-cli -regtest createwallet "dev"
ADDR=$(bitcoin-cli -regtest getnewaddress)The $ADDR shell variable now holds a fresh regtest address you can reuse in the next commands. This is throwaway, but the habit still holds: never put a real seed phrase or a real private key anywhere near any testnet or regtest wallet.
Mine some blocks
Here is the one rule that trips people up. When you mine a block, its reward (the coinbase) is not spendable right away. Bitcoin makes coinbase coins wait for 100 more blocks to mature before you can spend them. This is the coinbase maturity rule, and regtest enforces it just like mainnet.
So to end up with spendable coins, mine 101 blocks. The reward from block 1 matures once block 101 exists:
bitcoin-cli -regtest generatetoaddress 101 "$ADDR"
bitcoin-cli -regtest getbalancegeneratetoaddress mines the requested number of blocks instantly and sends each reward to $ADDR. After 101 blocks, getbalance reports a spendable balance (the first block's reward, now mature). Mine more any time you want more coins.
Send and confirm instantly
Sending works exactly like it does on any Bitcoin chain, except you produce the confirmation. Send the coins, then mine a single block to confirm the transaction:
bitcoin-cli -regtest sendtoaddress <dest> 1.0
bitcoin-cli -regtest generatetoaddress 1 "$ADDR"Replace <dest> with any regtest address. After sendtoaddress, the transaction sits in your mempool with zero confirmations. The moment you mine one block it lands on the chain with one confirmation. No waiting, no fee guessing, no stuck transactions. That instant, on-demand confirmation is what makes regtest ideal for automated tests: your test controls precisely when a transaction confirms.
When to use it
regtest and public testnet solve different problems. Reach for regtest when you want speed and repeatability, and for public testnet when you want realistic timing or something other people can see.
| regtest | Public testnet | |
|---|---|---|
| Timing | Instant, blocks on demand | Realistic, blocks every few minutes |
| Participants | Solo, only you | Shared with everyone |
| Getting coins | Mine your own | Claim from a faucet |
| Best for | Automated tests, fast iteration | Sharing, demos, realistic conditions |
| Explorer | Local only | TestnetScan |
A common workflow is to build and test against regtest first, then run the same code against public testnet before you ever touch mainnet. If you want a public, shared network instead of a private one, spin up a node: the walkthrough in run a Litecoin testnet node applies to bitcoind -testnet4 too. For a wider look at building, read Bitcoin testnet and mining. The companion code examples repo has a full regtest walkthrough you can copy and run: testnet-examples.
Testnet coins are fake money
- They have no market value, so never buy or sell them.
- Never use a real seed phrase or import a real wallet on testnet.
- Never send mainnet BTC, LTC, or XMR to a testnet address.