This guide will walk you through the process of setting up a Bitcoin regtest network and Fulcrum Electrum server.
the library bitcoin-core.js
uses local bitcoin and electrum node for testing.
- Prerequisites
- Setting up Bitcoin Core in Regtest Mode
- Configuring Bitcoin Core
- Starting Bitcoin Core in Regtest Mode
- Generating Initial Blocks
- Setting up Fulcrum
- Configuring Fulcrum
- Starting Fulcrum
- Testing the Setup
- Bitcoin Core
- Fulcrum (latest version)
- Basic knowledge of command-line operations
Learn about (Bitcoin Regtest)[https://developer.bitcoin.org/examples/testing.html]
-
Download and install Bitcoin Core from the official website: https://bitcoincore.org/en/download/
-
Create a directory for your regtest data:
mkdir ~/bitcoin-regtest
Create a configuration file for Bitcoin Core:
vim ~/.bitcoin/bitcoin.conf
Add the following lines to the configuration file:
server=1
rpcuser=user
rpcpassword=password
regtest=1
zmqpubrawblock=tcp://0.0.0.0:28334
zmqpubrawtx=tcp://0.0.0.0:28335
zmqpubhashblock=tcp://0.0.0.0:28336
datadir=./bitcoin-regtest
txindex=1
dnsseed=0
upnp=0
[regtest]
rpcbind=0.0.0.0
rpcallowip=0.0.0.0/0
rpcport=18443
listenonion=0
fallbackfee=0.0003
connect=localhost
Save and close the file.
Start Bitcoin Core in regtest mode:
bitcoind --regtest -conf=<path to config file>
Create a new internal regtest wallet
bitcoin-cli -regtest createwallet main
These are some common commands for the cli:
# Get new address
bitcoin-cli -regtest getnewaddress
# Mine some bitcoin blocks
bitcoin-cli -regtest generatetoaddress 1 <bitcoin address>
### send some bitcoin
bitcoin-cli -regtest sendtoaddress 1.1 <bitcoin address>
-
Download and compile Fulcrum from the official repository: https://github.com/cculianu/Fulcrum
-
Follow the compilation instructions in the Fulcrum README.
Create a configuration file for Fulcrum:
vim ~/fulcrum.conf
Add the following lines to the configuration file:
datadir = /path/to/fulcrum/data
bitcoind = 127.0.0.1:18443
rpcuser = your_rpc_username
rpcpassword = your_rpc_password
tcp = 127.0.0.1:50001
Adjust the paths and credentials as needed.
Start Fulcrum:
./Fulcrum ~/fulcrum.conf
- Ensure Bitcoin Core is running in regtest mode.
- Ensure Fulcrum is running and connected to your Bitcoin Core regtest node.
- Use a compatible wallet (e.g., Electrum) to connect to your Fulcrum server (usually at 127.0.0.1:50001).
You should now have a working Bitcoin regtest network with Fulcrum as Electrum server.
Remember to stop both Bitcoin Core and Fulcrum when you're done testing:
bitcoin-cli -regtest stop
./Fulcrum --stop
This setup allows you to experiment with Bitcoin transactions and smart contracts in a controlled environment without using real Bitcoin or connecting to the main network.