Skip to content

Latest commit

 

History

History
542 lines (387 loc) · 18.3 KB

minibolt-on-testnet.md

File metadata and controls

542 lines (387 loc) · 18.3 KB
layout
title description tableOfContents outline pagination
visible
true
visible
visible
true
visible
true
visible
true

MiniBolt on Testnet

You can run your MiniBolt node on Testnet4 to develop and experiment with new applications without risking real money. This bonus guide highlights all configuration changes compared to the main guide.

{% hint style="warning" %} Difficulty: Medium {% endhint %}

Introduction

Running a testnet node is a great way to get acquainted with the MiniBolt and the suite of Bitcoin-related software typical of these powerful setups. Moreover, testnet empowers users to tinker with the software and its many configurations without the threat of losing funds. Helping Bitcoiners run a full testnet setup is a goal worthy of the MiniBolt, and this page should provide you with the knowledge to get there.

The great news is that most of the MiniBolt guide can be used as-is. The small adjustments come in the form of changes to the config files and ports for testnet. You can follow the guide and replace the following configurations in the right places as you go.

{% hint style="info" %}

Advice:

For the moment, this guide will touch only the case of simultaneous mode situation for Bitcoin Core, in the future, we will study adding the case of configuration to enable the parallel/simultaneous mode (mainnet+testnet in the same device)

The services mentioned in this guide are those that have been tested using testnet configuration and these worked fine. Later, in the next versions of this guide, we will go to adding other process to adapt other services to the testnet mode {% endhint %}

Bitcoin

{% hint style="info" %} Mainnet + testnet simultaneous mode {% endhint %}

nano /home/bitcoin/.bitcoin/bitcoin-testnet4.conf
  • Stay tuned to replace and add the next lines on the bitcoin.conf file
## Replace the parameter
uacomment=MiniBolt Testnet4 node

## Add the parameter
testnet4=1

## Delete the parameter
bind=127.0.0.1

## Add the next 2 lines at the end of the file
[testnet4]
bind=127.0.0.1
  • When you finish the Run section, with the user admin provide read and execute permissions to the Bitcoin group for the testnet folder
sudo chmod g+rx /data/bitcoin/testnet4

{% hint style="warning" %} Attention: the step before is critical to allow the Bitcoin Core dependencies to access the .cookie file and startup without problems {% endhint %}

sudo nano /etc/systemd/system/bitcoind-testnet4.service
  • Include this content
# MiniBolt: systemd unit for bitcoind
# /etc/systemd/system/bitcoind-testnet4.service

[Unit]
Description=Bitcoin Core Daemon (Testnet4)
Requires=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/local/bin/bitcoind -pid=/run/bitcoind/bitcoind-testnet4.pid \
                                  -conf=/home/bitcoin/.bitcoin/bitcoin-testnet4.conf \
                                  -datadir=/home/bitcoin/.bitcoin \
                                  -startupnotify='systemd-notify --ready' \
                                  -shutdownnotify='systemd-notify --status="Stopping"'
# Process management
####################
Type=notify
NotifyAccess=all
PIDFile=/run/bitcoind/bitcoind-testnet4.pid

Restart=on-failure
TimeoutStartSec=infinity
TimeoutStopSec=600

# Directory creation and permissions
####################################
User=bitcoin
Group=bitcoin
RuntimeDirectory=bitcoind
RuntimeDirectoryMode=0710
UMask=0027

# Hardening measures
####################
PrivateTmp=true
ProtectSystem=full
NoNewPrivileges=true
PrivateDevices=true
MemoryDenyWriteExecute=true
SystemCallArchitectures=native

[Install]
WantedBy=multi-user.target
  • Enable autoboot (optional)
sudo systemctl enable bitcoind-testnet4
  • Prepare “bitcoind” monitoring by the systemd journal and check the logging output. You can exit monitoring at any time with Ctrl-C
journalctl -fu bitcoind-testnet4
  • When you arrive at the Run section, start the service with this
sudo systemctl start bitcoind-testnet4

{% hint style="info" %} Use the flag --testnet4 when you use the bitcoin-cli commands, e.g bitcoin-cli --testnet4 -netinfo {% endhint %}

{% hint style="success" %} The rest of the Bitcoin client guide is the same as the mainnet mode {% endhint %}

{% hint style="info" %} Only testnet mode {% endhint %}

Follow the complete Electrum server guide from the beginning, when you arrive at the "Configure Firewall" section:

Configure Firewall

  • Replace the next lines to 40001/40002 ports, to match with the Testnet mode
sudo ufw allow 40001/tcp comment 'allow Fulcrum Testnet4 TCP from anywhere'
sudo ufw allow 40002/tcp comment 'allow Fulcrum Testnet4 SSL from anywhere'
  • When you arrive at the "Data directory" section, on the..."Download the custom Fulcrum banner based on MiniBolt ..." step, d_ownload the Fulcrum testnet banner instead of the mainnet banner

{% code overflow="wrap" %}

wget https://raw.githubusercontent.com/minibolt-guide/minibolt/main/resources/fulcrum-banner-testnet4.txt

{% endcode %}

Configuration

  • In the next Configuration step, stay tuned to replace the next lines on the fulcrum.conf file, to match with the testnet mode
nano /data/fulcrum/fulcrum.conf
# Bitcoin Core settings
bitcoind = 127.0.0.1:48332
rpccookie = /data/bitcoin/testnet4/.cookie

# Fulcrum server general settings
ssl = 0.0.0.0:40002
tcp = 0.0.0.0:40001

# Banner
banner = /data/fulcrum/fulcrum-banner-testnet4.txt

Create systemd service

  • When you arrive at the Create systemd service section, stay tuned to replace the next lines on the fulcrum.service file, to match the Bitcoin Core on Testnet mode dependency. Save and exit
sudo nano +6 -l /etc/systemd/system/fulcrum.service
Requires=bitcoind-testnet4.service
After=bitcoind-testnet4.service

Remote access over Tor

sudo nano +63 -l /etc/tor/torrc
  • Replace ports to 40001/40002 to match with testnet mode
############### This section is just for location-hidden services ###
# Hidden Service Fulcrum Testnet4 TCP & SSL
HiddenServiceDir /var/lib/tor/hidden_service_fulcrum_testnet4_tcp_ssl/
HiddenServiceVersion 3
HiddenServicePoWDefensesEnabled 1
HiddenServicePort 40001 127.0.0.1:40001
HiddenServicePort 40002 127.0.0.1:40002
  • Reload the Tor configuration
sudo systemctl reload tor
  • Get your connection addresses
sudo cat /var/lib/tor/hidden_service_fulcrum_testnet4_tcp_ssl/hostname

Example of expected output:

abcdefg..............xyz.onion

{% hint style="info" %} You should now be able to connect to your Fulcrum server remotely via Tor using your hostname and port 40001 (TCP) or 40002 (SSL) {% endhint %}

{% hint style="success" %} The rest of the Fulcrum guide is the same as the mainnet mode {% endhint %}

{% hint style="danger" %}

Not Testnet4 compatible yet, the next steps are not valid!

{% endhint %}

  • Follow the complete guide from the beginning, when you arrive at the Configuration section, set the next lines with the next values instead of the existing ones for mainnet. Edit .env file
nano /home/btcrpcexplorer/btc-rpc-explorer/.env
BTCEXP_BITCOIND_PORT=18332
BTCEXP_BITCOIND_COOKIE=/data/bitcoin/testnet3/.cookie
BTCEXP_ELECTRUM_SERVERS=tcp://127.0.0.1:60001

{% hint style="success" %} The rest of the BTC RPC Explorer guide is the same as the mainnet mode {% endhint %}

Lightning

{% hint style="danger" %}

Not Testnet4 compatible yet, the next steps are not valid!

{% endhint %}

  • Follow the complete guide from the beginning, when you arrive at the Configuration section, edit lnd.conf
nano /data/lnd/lnd.conf
  • Replace the parameter bitcoin.mainnet=true with the bitcoin.testnet4=true to enable LND in testnet mode and add the location of the bitcoin-testnet4.conf in the [Bitcoind] section
[Bitcoin]
bitcoin.testnet4=true

[Bitcoind]
bitcoind.config=/data/bitcoin/bitcoin-testnet4.conf

{% hint style="info" %} If you use Ordirespector on testnet, add the next lines at the end of the file: {% endhint %}

[fee]
# Use external fee estimator
fee.url=https://nodes.lightning.computer/fees/v1/btctestnet4-fee-estimates.json
  • When you arrive at the Create systemd service section, edit the lnd.service file and replace ExecStop parameter to this
ExecStop=/usr/local/bin/lncli --network=testnet4 stop

{% hint style="info" %} When you arrive at the Watchtower client section, keep in mind that the Watchtower server suggested won't work with the LND testnet4, same with the LND mainnet peer suggested to open the channel and send a payment {% endhint %}

Interacting with the LND daemon

  • Note that when interacting with the LND daemon, you'll need to use the "--network=testnet4" flag. Example:
lncli --network=testnet4 --tlscertpath /data/lnd/tls.cert.tmp create

Allow user "admin" to work with LND

  • Note that when you arrive at this section, you need to replace the command: sudo chmod g+r /data/lnd/data/chain/bitcoin/mainnet/admin.macaroon to the next
sudo chmod g+r /data/lnd/data/chain/bitcoin/testnet4/admin.macaroon

{% hint style="info" %} It has a list of testnet aliases related to these commonly used commands to make it easier to introduce in the terminal. Follow the "Aliases bonus guide" to install it {% endhint %}

{% hint style="success" %} The rest of the Lightning Client guide is the same as the mainnet mode {% endhint %}

{% hint style="danger" %}

Not Testnet4 compatible yet, the next steps are not valid!

{% endhint %}

  • Follow the complete guide from the beginning, when you arrive at the "Create script" section, create the script
sudo nano /usr/local/bin/scb-backup --linenumbers
  • Replace the line 18 in the script to match with the testnet path
SCB_SOURCE_FILE="/data/lnd/data/chain/bitcoin/testnet/channel.backup"

{% hint style="info" %} If you have a mainnet node running on another device and you want to use the same GitHub account for the testnet channel backups:

  • Change this line on the script to this for example: REMOTE_BACKUP_DIR="/data/lnd/remote-lnd-testnet-backup"
  • When you arrive at the "Create a GitHub repository" section, change the name of the GitHub repo to for example: "remote-lnd-testnet-backup"
  • When you arrive at the "Clone the repository to your node" section, replace the command with: git clone git@github.com:<YourGitHubUsername>/remote-lnd-testnet-backup.git
  • When you arrive at the "GitHub test" section, replace the command to: cd remote-lnd-testnet-backup {% endhint %}

{% hint style="success" %} The rest of the Channel Backup guide is the same as the mainnet mode {% endhint %}

{% hint style="danger" %}

Not Testnet4 compatible, the next steps are not valid!

{% endhint %}

  • Follow the complete guide from the beginning, when you arrive at the Configuration section, replace the next parameter to match with the testnet mode on the .env.local file
MEMPOOL_URL='https://mempool.space/testnet'
  • And replace the next parameter on the thubConfig.yaml file
macaroonPath: /data/lnd/data/chain/bitcoin/testnet/admin.macaroon

{% hint style="success" %} The rest of the Web app: Thunderhub is the same as the mainnet mode {% endhint %}

{% hint style="danger" %}

Not Testnet4 compatible yet, the next steps are not valid!

{% endhint %}

  • Follow the complete guide from the beginning, when you arrive at the Create a lndconnect QR code section, modify the "lndconnect" command to match with the next

For example, to generate a QR code for a Wireguard VPN connection, enter this command:

{% code overflow="wrap" %}

lndconnect --host=10.0.1.1 --port=8080 --bitcoin.testnet --adminmacaroonpath=/home/admin/.lnd/data/chain/bitcoin/testnet/admin.macaroon --nocert

{% endcode %}

{% hint style="info" %} Be careful to add --nocert parameter only to the onion and Wireguard VPN network, the local network could be shared with more devices and you should use a valid certificate to encrypt the connection, so don't add that parameter in this case {% endhint %}

Bonus section

Bitcoin: Electrs

{% hint style="info" %} Only testnet mode {% endhint %}

Follow the complete guide from the beginning, when you arrive at the Reverse proxy & Firewall section, follow the next steps:

  • Create the electrs-reverse-proxy.conf file
sudo nano /etc/nginx/streams-enabled/electrs-reverse-proxy.conf
  • Replace the mainnet ports 50021/50022 with the 40021/40022 testnet4 ports
upstream electrs {
  server 127.0.0.1:40021;
}
server {
  listen 40022 ssl;
  proxy_pass electrs;
}
  • Test and reload Nginx configuration
sudo nginx -t
sudo systemctl reload nginx
  • Configure the Firewall to allow incoming requests
sudo ufw allow 40022/tcp comment 'allow Electrs Testnet4 SSL from anywhere'
sudo ufw allow 40021/tcp comment 'allow Electrs Testnet4 TCP from anywhere'

Configuration

  • When you arrive at the Configuration section, replace it with the next lines
nano /data/electrs/electrs.conf
# MiniBolt: electrs testnet4 configuration
# /data/electrs/electrs.conf

# Bitcoin Core settings
network = "testnet4"
cookie_file = "/data/bitcoin/testnet4/.cookie"

# Electrs settings
electrum_rpc_addr = "0.0.0.0:40021"
server_banner = "Welcome to electrs (Electrum Rust Server) running on a MiniBolt node Testnet4!"

Remote access over Tor

sudo nano +63 /etc/tor/torrc
  • Edit the torrc file and replace ports to 40021/40022 to match with the testnet4 mode
# Hidden Service Electrs Testnet4 TCP & SSL
HiddenServiceDir /var/lib/tor/hidden_service_electrs_testnet4_tcp_ssl/
HiddenServiceVersion 3
HiddenServicePoWDefensesEnabled 1
HiddenServicePort 40021 127.0.0.1:40021
HiddenServicePort 40022 127.0.0.1:40022
  • Reload the Tor configuration and get your connection addresses
sudo systemctl reload tor
sudo cat /var/lib/tor/hidden_service_electrs_testnet4_tcp_ssl/hostname

Example of expected output:

abcdefg..............xyz.onion

{% hint style="success" %} The rest of the Electrs guide is the same as the mainnet mode {% endhint %}

Port reference

Here we are going to describe only what ports differ from the mainnet mode:

PortProtocolUse
48333TCPP2P Testnet4 port
48334TCPP2P Testnet4 secondary port
48332TCPRPC Testnet4 port
40001TCPFulcrum Testnet4 port
40002SSLFulcrum server Testnet4 encrypted port
40021TCPElectrs Testnet4 port
40022SSLElectrs server Testnet4 encrypted port