Bitcoin Regtest

A local test chain where you can generate blocks instantly, used for automated wallet and contract tests.

Basically

Bitcoin regtest is a private Bitcoin test network on your own computer. Developers can create blocks whenever they want, so they can run automatic tests without waiting.

Key Takeaways

  • Bitcoin regtest, short for regression test mode, is a private local blockchain that gives you complete control over block generation. You can confirm transactions instantly without mining delays or external dependencies.
  • Regtest is the standard environment for automated testing, including CI/CD pipelines, unit tests and integration tests, because its behaviour is deterministic. Unlike testnet or signet, it needs neither an internet connection nor peer nodes.
  • Tools like Polar provide a graphical interface for setting up regtest-based Lightning networks. You can test channel operations, routing and payment flows locally.

What Is Bitcoin Regtest?

Bitcoin regtest, short for "regression test", is a local private blockchain mode built into Bitcoin Core. It creates a brand-new blockchain from scratch on your machine and follows the same consensus rules as mainnet, but you decide when blocks are created. There is no proof-of-work mining, no network peers and no waiting for confirmations.

Regtest works as a personal sandbox where you control the nodes, blocks, transactions and timing. You can test Bitcoin applications in a reproducible environment. If something goes wrong, you can wipe the chain and start over in seconds.

Regtest exists alongside two other test networks: testnet, a public network with real proof-of-work mining, and signet, a public network where authorised parties sign blocks. Each network serves a different purpose. Regtest is the go-to choice for local development and automated testing because of its speed and isolation.

How It Works

A regtest node starts with a single command. Bitcoin Core includes regtest as a built-in network mode that you can access with the -regtest flag.

Bitcoin Core generates a fresh genesis block when you first launch a regtest node. Its hash is 0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206. This genesis block is unique to regtest and differs from the mainnet genesis block.

Mining Blocks on Demand

On-demand block generation is the core feature of regtest. You do not need to wait for miners to find valid blocks, which takes roughly 10 minutes on mainnet. You can generate blocks instantly with a single RPC call.

Bitcoin's coinbase maturity rule explains why tests often use 101 blocks. Coinbase rewards require 100 confirmations before they become spendable. Mining 101 blocks gives the reward from block 1 exactly 100 confirmations, making it available to spend in tests.

Transaction Testing

Spendable coins let you build and test complete transaction workflows. You can run each workflow locally from start to finish.

The send, mine and verify cycle runs in under a second on regtest. The same workflow on mainnet would take at least 10 minutes for a single confirmation. The recommended 6 confirmations would take roughly an hour.

Network Parameters

Regtest uses distinct network parameters to avoid confusion with mainnet or testnet. These parameters keep regtest separate from the other networks.

All soft forks, including SegWit and Taproot, are active from block height 1 on regtest. You can test any modern Bitcoin feature immediately without waiting for activation.

Unit and Integration Testing

Regtest is the foundation of Bitcoin Core's own test suite. The test/functional/ directory in the Bitcoin Core repository contains hundreds of Python-based tests that spin up regtest nodes, execute transactions and verify behaviour. Any project building on Bitcoin follows the same pattern.

Typical test scenarios include UTXO management and coin selection, multisig and PSBT signing workflows, and replace-by-fee transaction handling. Other scenarios cover script validation and spending conditions, and wallet backup and recovery procedures.

CI/CD Pipelines

Regtest has zero external dependencies, so it integrates cleanly into continuous integration environments. A common pattern uses Docker to run a regtest node alongside the application under test.

Tests run against a fresh chain every time, ensuring deterministic results. There are no faucet rate limits, no network latency and no reliance on public infrastructure that might be down.

Lightning Network Development

Local regtest is the standard backend for Lightning development. Developers run multiple Bitcoin nodes and Lightning nodes, including LND, Core Lightning or Eclair, on regtest to test channel operations, payment routing and failure scenarios.

Polar simplifies this workflow significantly as a free, open-source desktop application with a visual interface for managing regtest-based Lightning networks. You can drag and drop to create nodes, open channels and send payments without writing a single CLI command. Under the hood, Polar manages Docker containers running Bitcoin Core in regtest mode alongside your chosen Lightning implementation.

Polar supports LND, Core Lightning and Eclair, letting developers test interoperability across implementations. It is particularly useful for testing channel capacity management, multi-path payment routing and force-close recovery scenarios.

Application Prototyping

Any application that interacts with Bitcoin benefits from regtest during development. Wallet developers use it to test address generation, transaction building and fee estimation logic, while payment processors use it to verify invoice creation and settlement flows. Layer 2 protocols like Spark rely on regtest to validate on-chain anchoring and exit transactions before deploying to production.

Regtest vs Other Test Networks

Bitcoin offers three test environments. Each one suits a different stage of development.

Regtest is the right choice for local development and automated testing where speed and determinism matter. Testnet and signet are better suited for testing with real network conditions, including peer discovery, block propagation delays and interaction with other participants. Most projects use regtest during development and CI, then move to signet or testnet for pre-production validation.

Why It Matters

Regtest is the backbone of Bitcoin development infrastructure. Without it, testing a simple transaction flow would require waiting for real blocks on a public network, acquiring test coins from faucets and dealing with network instability. Regtest removes all of these friction points.

Regtest is especially valuable for developers building on Bitcoin Layer 2 protocols because testing Lightning channels, HTLCs and on-chain settlement transactions requires precise control over block timing. A force-close test, for example, needs to simulate timelock expiration by mining a specific number of blocks, something only regtest can do reliably. Projects like Spark use regtest extensively during development to test on-chain anchoring, cooperative exits and UTXO management before deploying to live networks.

Not a Production Substitute

Regtest cannot replicate real-world network conditions. There is no mempool congestion, no competing transactions, no reorganisations from competing miners and no latency from block propagation. Code that works perfectly on regtest may behave differently when confronted with these conditions on mainnet.

No Peer Testing

Regtest is local by default, so it does not test peer-to-peer networking behaviour. Applications that depend on peer discovery, transaction relay or block announcement propagation need a public test network such as signet or testnet to validate those code paths.

Consensus Divergence

Regtest activates all soft forks at block height 1, unlike mainnet, where features activate at specific heights after miner signalling. Applications that depend on activation timing or need to handle pre-activation blocks will not encounter those edge cases on regtest. The halving interval of 150 blocks also means regtest reaches zero-reward blocks quickly, something that will not happen on mainnet until approximately the year 2140.

State Management

Regtest state persists in the regtest subdirectory of your Bitcoin data folder. Failing to reset state between test runs can lead to flaky tests that depend on leftover transactions or block heights. Best practice is to start each test suite with a clean chain by deleting the regtest directory and restarting the node.

The Bitcoin node implementation comparison explains how Bitcoin nodes work across different network modes. You can use it for a deeper look at those modes.

The glossary entry is for informational purposes only and does not constitute financial or investment advice. You should always do your own research before using any protocol or technology.

0

← All 1876 glossary terms