Module 4: Using Regtest to Simulate Bitcoin
Learning Objectives
By the end of this module, you will:
Understand the purpose and power of Bitcoin Core's regtest mode
Set up a private, fully controlled Bitcoin network
Mine blocks and confirm transactions instantly
Use regtest for API testing, integration flows, and simulations
Why Regtest Matters
regtest stands for Regression Test mode. It is a fully offline, developer-first Bitcoin network that:
Has no network peers (your node is the entire network)
Lets you mine blocks instantly
Offers zero-fee, instant transaction confirmation
Works perfectly with automated testing, CI flows, and local wallets
For building real Bitcoin apps, is the the fastest and safest sandbox.
Setting Up a Fully Isolated Bitcoin Environment
Start your node in regtest mode:
This creates:
~/.bitcoin/regtest/ as your data directory
A zero-block chain, ready to mine
No connections to testnet, mainnet, or the internet
You can confirm the mode using:
Look for "chain": "regtest"
Mining Blocks Instantly
Regtest allows manual block generation.
First, create a wallet and get a new address:
Now mine 101 blocks (to unlock coinbase rewards):
This gives you spendable BTC for testing.
You can generate 1 block at a time to simulate confirmation behavior.
Sending Transactions Instantly
With freshly mined coins, you can now send BTC:
Check mempool:
Confirm instantly by mining a block:
Now check the recipient’s balance:
GUI Alternative: Polar
Polar is a desktop app that sets up a regtest Bitcoin + Lightning network for you using Docker.
Why use it?
No terminal needed
Visual interface for nodes, wallets, payments
Supports Bitcoin Core + LND + Core Lightning
🖥️ If you prefer a GUI for testing, Polar is highly recommended. It is especially useful for team demos, education, and debugging.
Install it via:
macOS: brew install --cask polar
Linux: .AppImage from GitHub
Windows: .exe installer
You can still inspect logs, addresses, and transactions under the hood.
Activity
Set up a regtest sandbox from scratch:
Start bitcoind in regtest mode.
Create a wallet, generate 101 blocks (replace <your_address> with an address from the new wallet).
Send 2 test transactions (replace <destination_1>, <destination_2> with valid addresses).
Mine 1 block to confirm (use the same <your_address> as before or another address in activity_wallet).
Use listtransactions to view history.
Wallets that understand UTXOs deeply will control fees, preserve privacy, and scale cleanly over time.