Skip to main content

Regtest | Bitcoin Glossary | Mapping Bitcoin

Regtest

Desenvolvimento

Also known as: regression test mode, regression testnet

Regression Testing mode, a local Bitcoin testing environment where blocks can be generated instantly on demand. Regtest runs a completely private blockchain, making it ideal for development, automated testing, and debugging without needing testnet coins.

Overview

Regtest (Regression Testing mode) is a private, local Bitcoin network that developers can use for testing and experimentation. Unlike testnet or signet, regtest does not connect to any external network. Blocks can be generated instantly via an RPC command, giving developers complete control over the testing environment without waiting for block times or acquiring test coins from faucets.

How Regtest Works

Bitcoin Network Comparison:

┌──────────┬────────────┬────────────┬────────────┐
│          │  Mainnet   │  Testnet   │  Regtest   │
├──────────┼────────────┼────────────┼────────────┤
│ Real BTC │    Yes     │    No      │    No      │
│ Public   │    Yes     │    Yes     │    No      │
│ Mining   │    PoW     │    PoW     │  Instant   │
│ Peers    │  Global    │  Global   │  Local     │
│ Coins    │    Buy     │  Faucet   │  Generate  │
│ Resets   │   Never    │  Rarely   │  Anytime   │
└──────────┴────────────┴────────────┴────────────┘

Getting Started with Regtest

Starting a Bitcoin Core node in regtest mode and generating blocks is straightforward:

# Start bitcoind in regtest mode
bitcoind -regtest -daemon

# Create a wallet
bitcoin-cli -regtest createwallet "test"

# Generate an address
bitcoin-cli -regtest getnewaddress

# Mine 101 blocks (100 to mature coinbase + 1)
bitcoin-cli -regtest generatetoaddress 101 <address>

# Now you have spendable bitcoin for testing

The generatetoaddress command instantly creates blocks without performing actual proof of work, making the test cycle extremely fast.

Use Cases

  • Unit and integration testing — Automated test suites can create transactions, mine blocks, and verify behavior without network delays
  • Lightning Network development — Developers can open and close payment channels, simulate routing, and test edge cases in a controlled environment
  • Script development — Test custom Bitcoin Script spending conditions without risking real funds
  • Wallet development — Verify address generation, transaction building, and fee estimation logic
  • Reorg simulation — Deliberately create chain reorganizations to test how software handles them

Advantages Over Testnet

Regtest offers several benefits compared to testnet: blocks are generated on demand (no waiting), the chain can be reset at any time, there is no competition for block space, no reliance on faucets for test coins, and no interference from other users. This makes regtest the preferred environment for local development and continuous integration pipelines.

Common Misconception

Regtest is not the same as testnet. Testnet is a public network with its own mining, block times, and shared state. Regtest is entirely local and private. Code that works on regtest should also be tested on testnet or signet before being deployed to mainnet, since those environments more closely simulate real-world network conditions.