Skip to content

Instantly share code, notes, and snippets.

@bnonni
Last active August 19, 2024 00:38
Show Gist options
  • Save bnonni/2a46b30fe171bfc8523edd4a835f8644 to your computer and use it in GitHub Desktop.
Save bnonni/2a46b30fe171bfc8523edd4a835f8644 to your computer and use it in GitHub Desktop.

DIY: Hybrid Lightning Node - Mainnet & Testnet

The goal of this gist is to provide the pleb community with an easy to follow guide for how to setup a lightning node that runs on both Mainnet and Testnet at the same time. This guide will also walk you through setting up your node in "hybrid mode" (i.e. clearnet + tor) and installing Tunnel SATS for your static clearnet IP.

Acknowledgments: Parts of this guide were taken from the Run-LND repo by Alex Bosworth.

Example commands are given from the perspective of running Ubuntu on a Raspberry Pi.

Table of Contents

Physical hardware

General Requirements:

  • Device: AWS EC2, Digital Ocean VPS, Google Cloud VM, old Laptop / Desktop / Home Server
  • MEMORY: 8GB+
  • DISK: 1TB (mainnet) or 25GB+ (testnet/signet) SSD (internal or external)
  • OS: Any 64-bit OS, Linux-based most popular, specifcally Ubuntu
  • IP: Static IP (if you don't have one or can't get one, don't fret! We will install TunnelSATs)
  • PORTS:
  • Bitcoind: 8333 (main), 18333 (test), 48333 (signet)
  • Bitcoind RPC: 8332 (main), 18332 (test), 48332 (signet)
  • Bitcoind REST: 8332 (main), 18332 (test)
  • ZMQ Block: 28332 (main), 38332 (test), 58332 (signet)
  • ZMQ Tx: 28333 (main), 38333 (test), 58333 (signet)
  • TOR: 9051, 9050 (all)
  • LND P2P: 9735 (main), 9734 (test): need to open these in firewall (see Firewall section below)
  • LND gRPC: 10009 (main), 10010 (test) (see Firewall section below)
  • LND REST: 8080 (main), 8081 (test) (see Firewall section below)

My Setup:

I used the following hardware, networking setup and software:

  • Raspberry Pi 4 Model B 8GB RAM
  • 1TB external SSD
  • External IP address vua TunnelSATs
  • Tor version 0.4.7.10
  • Go v1.19.2
  • SD card
  • Ubuntu 22.04.1 LTS

OS & External Disk

Update and upgrade your OS packages.

sudo apt update && sudo apt upgrade -y && sudo reboot

Next, if you're storing the blockchain data on an external SSD connected to your device, do the following:

# Use this command to list all storage volumes attached to your device
lsblk
# Should look something like this
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
loop1         7:1    0    59M  1 loop /snap/core20/1627
loop2         7:2    0  71.8M  1 loop /snap/lxd/22927
loop3         7:3    0   102M  1 loop /snap/lxd/23545
loop4         7:4    0  41.5M  1 loop /snap/snapd/17032
loop5         7:5    0  41.5M  1 loop /snap/snapd/17339
loop6         7:6    0    59M  1 loop /snap/core20/1638
sda           8:0    0 931.5G  0 disk 
└─sda1        8:1    0 931.5G  0 part /blockchain
mmcblk0     179:0    0  14.8G  0 disk 
├─mmcblk0p1 179:1    0   256M  0 part /boot/firmware
└─mmcblk0p2 179:2    0  14.6G  0 part /

Yours will look different, but if it does look similar to the above list, you want to use sda1 which is the attached SSD drive. Create a root level folder to mount the SSD to then mount and move into that folder:

sudo mkdir /blockchain
sudo mount /dev/sda1 /blockchain/
cd /blockchain

Automatically mount the partition using fstab config & backup the existing config first:

sudo cp /etc/fstab /etc/fstab.bak
sudo nano /etc/fstab

Add this line to the bottom of the file:

/dev/sda1 /blockchain ext4 defaults,nofail 0 0

Save and exit the file, then test setup, shouldn't see any error output:

sudo mount -a

Change ownership of the folder to your user:

sudo chown -R `whoami` /blockchain

Firewall

Check if UFW is installed

which ufw

If not installed:

sudo apt-get install -y ufw

If installed, enable and turn on logging:

sudo ufw enable
sudo ufw logging on

Allow access to various ports needed for bitcoind and lnd:

sudo ufw status

sudo ufw allow OpenSSH comment SSH
sudo ufw allow 443 comment TLS

sudo ufw allow 9050 comment 'TOR SOCKSPort'
sudo ufw allow 9051 comment 'TOR Control Port'

sudo ufw allow 8333 comment 'Bitcoind Mainnet'
sudo ufw allow 8332 comment 'Bitcoind RPC/REST Mainnet'

sudo ufw allow 18333 comment 'Bitcoind Testnet'
sudo ufw allow 18332 comment 'Bitcoind RPC/REST Testnet'

sudo ufw allow 48333 comment 'Bitcoind Signet'
sudo ufw allow 48332 comment 'Bitcoind RPC/REST Signet'

sudo ufw allow 28332 comment 'ZMQ Blocks Mainnet'
sudo ufw allow 28333 comment 'ZMQ Tx Mainnet'

sudo ufw allow 38332 comment 'ZMQ Blocks Testnet'
sudo ufw allow 38333 comment 'ZMQ Tx Testnet'

sudo ufw allow 58332 comment 'ZMQ Blocks Signet'
sudo ufw allow 58333 comment 'ZMQ Tx Signet'

sudo ufw allow 9735 comment 'LND Mainnet'
sudo ufw allow 10009 comment 'LND gRPC Mainnet'
sudo ufw allow 8080 comment 'LND REST Mainnet'

sudo ufw allow 9734 comment 'LND Testnet'
sudo ufw allow 10010 comment 'LND gRPC Testnet'
sudo ufw allow 8081 comment 'LND REST Testnet'

Setup network flood protection:

sudo iptables -N syn_flood
sudo iptables -A INPUT -p tcp --syn -j syn_flood
sudo iptables -A syn_flood -m limit --limit 1/s --limit-burst 3 -j RETURN
sudo iptables -A syn_flood -j DROP
sudo iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j ACCEPT
sudo iptables -A INPUT -p icmp -m limit --limit 1/s --limit-burst 1 -j LOG --log-prefix PING-DROP:
sudo iptables -A INPUT -p icmp -j DROP
sudo iptables -A OUTPUT -p icmp -j ACCEPT

Install & Setup Tor

Make sure that your architecture is supported: only amd64, arm64, or i386 are supported

dpkg --print-architecture

Install transport https package

sudo apt-get update && sudo apt install -y apt-transport-https

Determine which codename you have

lsb_release -c

Edit package sources for installation

sudo nano /etc/apt/sources.list.d/tor.list

Add the following lines to the file, replace with the codename, ie: focal or jammy

deb     [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main
deb-src [signed-by=/usr/share/keyrings/tor-archive-keyring.gpg] https://deb.torproject.org/torproject.org <DISTRIBUTION> main

Get the GPG key for Tor and add it to GPG

sudo wget -qO- https://deb.torproject.org/torproject.org/A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89.asc | gpg --dearmor | sudo tee /usr/share/keyrings/tor-archive-keyring.gpg >/dev/null

Install the Tor package

sudo apt update && sudo apt install -y tor deb.torproject.org-keyring

Add a user for Tor

sudo usermod -a -G debian-tor `whoami`

Open tor conf file and add these lines & restart tor:

sudo nano /etc/tor/torrc

ControlPort 9051
CookieAuthentication 1
CookieAuthFileGroupReadable 1
Log notice stdout
SOCKSPort 9050

sudo systemctl restart tor

Check if tor is running. Be patient, this sometimes takes a while to complete. It should print Congratulations:

curl --socks5 localhost:9050 --socks5-hostname localhost:9050 -s https://check.torproject.org/ | cat | grep -m 1 Congratulations | xargs

Install & Setup Bitcoind

Install dependencies

sudo apt install git build-essential libtool autotools-dev \
automake pkg-config libssl-dev libevent-dev \
bsdmainutils libboost-dev libminiupnpc-dev libnatpmp-dev \
libzmq3-dev libsqlite3-dev python3 systemtap-sdt-dev

Clone bitcoin core repo v25.0 branch and move into folder

cd ~
git clone -b v25.0 https://github.com/bitcoin/bitcoin.git
cd bitcoin/

Auto-configure bitcoind

./autogen.sh

Configure bitcoind with or without default wallet support (depends on preference)

With default wallet support

# Open shell profile
nano ~/.profile
 
# Add this line to .profile, replace <username> with your username
export BDB_PREFIX='/home/<username>/bitcoin/db4'

# Save and close .profile then run
source ~/.profile

# Do a gut check to ensure BDB_PREFIX has been set
# This should output the path you set above: /home/<username>/bitcoin/db4
echo $BDB_PREFIX

# Run the configure command with BDB flags
./configure \
  BDB_LIBS="-L${BDB_PREFIX}/lib -ldb_cxx-4.8" BDB_CFLAGS="-I${BDB_PREFIX}/include" \
  CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" \
  --enable-cxx --with-zmq --without-gui --disable-shared --with-pic \
  --disable-tests --disable-bench --enable-upnp-default

Without default wallet support

# Configure bitcoind without default wallet support
./configure \
  CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" \
  --enable-cxx --with-zmq --without-gui --disable-shared --with-pic \
  --disable-tests --disable-bench --enable-upnp-default --disable-wallet

Make & make install bitcoin

make -j "$(($(nproc)+1))"
sudo make install

Setup blockchain storage volume directories

mkdir -p /blockchain/.bitcoin

Use the Bitcoin Core auth script to generate credentials instead of using rpcuser & rpcpass

  • Be sure to replace Satoshi with an actual username of your choice
wget https://raw.githubusercontent.com/bitcoin/bitcoin/master/share/rpcauth/rpcauth.py
python ./rpcauth.py Satoshi
  • These commands will output authentication string and a password that look like this
rpcauth=Satoshi:b95od46uccbxiqvd5ef5avdbswawlc2z$b95od46uccbxiqvd5ef5avdbswawlc2z
Your password: B-0-y3ai_R7I4QKWONkU58qcG9tvnr7Y6K5-os2QJZf=
  • Save this info, you will need to add the rpcauth to your bitcoin.conf and the password to your lnd.conf Edit your bitcoin.conf
nano /blockchain/.bitcoin/bitcoin.conf

Assume Valid

Decide which assumevalid you plan to use

  • assumevalid=<BEST BLOCK HASH>
  • If <BEST BLOCK HASH> is in chain, bitcoind will assume that it and its ancestors (prior blocks) are valid and skip script verification
  • You have a couple options here:
  1. Remove assumevalid
  • without assumevalid, bitcoind will use the network defaults
  • mainnet default
    • best block: 768735
    • best block hash: 00000000000000000007cba60572b83b355a60f3df789b544bf6461852da5fe7
  • testnet default
    • best block: 2412645
    • best block hash: 0000000000000028e2d7d2e38bd0c40af27c5602cc2f018affc1586d7b89dd24
  • signet default
    • best block: 122578
    • best block hash: 000000c9bddca208d6454cde253761f3834adae0c82c7be3a2dee12fd3aaa6d2
  1. Set assumevalid=0
  • with assumevalid set to 0, bitcoind will verify all txs and blocks from genesis to current block
  • longest option as this is a full chain sync or IBD (initial blockchain download)
  • takes 2-3 days of constant runtime
  1. Set assumevalid=<DEFAULT BLOCK HASH>
  • mainnet: assumevalid=00000000000000000008a89e854d57e5667df88f1cdef6fde2fbca1de5b639ad
  • testnet: assumevalid=0000000000004ae2f3896ca8ecd41c460a35bf6184e145d91558cece1c688a76
  • signet: assumevalid=000000187d4440e5bff91488b700a140441e089a8aaea707414982460edbfe54
  • this is the default hash used by bitcoind if nothing is set
  • considered safe / best practice for all networks
  1. Set assumevalid=<bitcoin-cli getbestblockhash>
  • if you have access to another bitcoind node, run bitcoin-cli getbestblockhash
  • replace with the output of this command
  • this will return the most recently confirmed block
  • this is not considered best practice / safe if running on mainnet but is fine for testnet and signet
    % bitcoin-cli getbestblockhash     
    00000000000000000003667f3f2fbd0df01d73cce77e3370eb021f84a6d8d2ef
    
    • as of the time of this writing, the best block hash is:
      • best block: 768738
      • best block hash: 00000000000000000003667f3f2fbd0df01d73cce77e3370eb021f84a6d8d2ef

Add the following settings to your bitcoin.conf

bitcoin.conf
# Query for peer addresses via DNS lookup
dnsseed=1
dns=1
upnp=1

# Set 0 or the best block hash based on the decision made in step 9.
assumevalid=0

# Run as a daemon mode without an interactive shell
daemon=1

# Set the data directory to the storage directory
datadir=/blockchain/.bitcoin

# Set the number of megabytes of RAM to use, good rule-of-thumb is to set to <= ~50% of available RAM
# if on unix-based OS, use this command to get 50% of the available RAM in MBs: 
#   expr $(sysctl -n hw.memsize) / $((1024**2)) / 2
# Lower dbcache number will result in bitcoind caching data more often.
#   in the event of a kill or crash, you won't lose as much data
dbcache=2000

# Add visibility into mempool and RPC calls for potential LND debugging
debug=mempool
debug=rpc

# Don't bother listening for peers
listen=1

# Constrain the mempool to the number of megabytes needed:
maxmempool=100

# Limit uploading to peers
maxuploadtarget=1000

# turn off spv nodes
nopeerbloomfilters=1
peerbloomfilters=0

# Don't accept deprecated multi-sig style
permitbaremultisig=0

# Set the RPC auth
rpcauth=Satoshi:b95od46uccbxiqvd5ef5avdbswawlc2z$b95od46uccbxiqvd5ef5avdbswawlc2z

# Turn on the RPC server
server=1

# Turn on transaction lookup index
txindex=1

[main]
port=8333
rpcport=8332
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

# Set testnet details here so you can run mainnet and testnet on same node
[test]
port=18333
rpcport=18332
zmqpubrawblock=tcp://127.0.0.1:38332
zmqpubrawtx=tcp://127.0.0.1:38333

# Set signet details here so you can also run signet, not necessary but good for completeness
[signet]
port=48333
rpcport=48332
zmqpubrawblock=tcp://127.0.0.1:58332
zmqpubrawtx=tcp://127.0.0.1:58333

Setup bitcoind.service file

sudo nano /etc/systemd/system/bitcoind.service
  • Paste the follow into this file
bitcoind.service
[Unit]
Description=Bitcoind
Documentation=https://github.com/bitcoin/bitcoin/blob/master/doc/init.md

After=network-online.target
Wants=network-online.target

[Service]
Environment=HOME=/home/<USER>

ExecStart=/usr/local/bin/bitcoind -conf=/blockchain/.bitcoin/bitcoin.conf
ExecStop=/usr/local/bin/bitcoin-cli -conf=/blockchain/.bitcoin/bitcoin.conf stop

Restart=always
RestartSec=10

StandardOutput=/blockchain/.bitcoin/bitcoind.log
StandardError=/blockchain/.bitcoin/debug.log

SyslogIdentifier=bitcoind

User=<USER>
Group=<USER>

RuntimeDirectory=bitcoind
RuntimeDirectoryMode=0710

PIDFile=/blockchain/.bitcoin/bitcoind.pid

[Install]
WantedBy=multi-user.target

Setup bitcoind.testnet.service file

sudo nano /etc/systemd/system/bitcoind.testnet.service
  • Paste the follow into this file
bitcoind.testnet.service
[Unit]
Description=Bitcoind Testnet
Documentation=https://github.com/bitcoin/bitcoin/blob/master/doc/init.md

After=network-online.target
Wants=network-online.target

[Service]
Environment=HOME=/home/<USER>

ExecStart=/usr/local/bin/bitcoind -testnet -conf=/blockchain/.bitcoin/bitcoin.conf
ExecStop=/usr/local/bin/bitcoin-cli -testnet -conf=/blockchain/.bitcoin/bitcoin.conf stop

Restart=always
RestartSec=10

StandardOutput=/blockchain/.bitcoin/testnet3/bitcoind.log
StandardError=/blockchain/.bitcoin/testnet3/debug.log

SyslogIdentifier=bitcoind.testnet

User=<USER>
Group=<USER>

RuntimeDirectory=bitcoind
RuntimeDirectoryMode=0710

PIDFile=/blockchain/.bitcoin/testnet3/bitcoind.pid

[Install]
WantedBy=multi-user.target

Start bitcoind.service & bitcoind.testnet.service

sudo systemctl daemon-reload
sudo systemctl enable bitcoind && sudo systemctl enable bitcoind.testnet
sudo systemctl start bitcoind && sudo systemctl start bitcoind.testnet

Create symlinks between debug logs in /blockchain to your local home dir for easier access

# Mainnet:
ln -s /blockchain/.bitcoin/debug.log ~/bitcoind.log

# Testnet:
ln -s /blockchain/.bitcoin/testnet3/debug.log ~/bitcoind.testnet.log

Create bash aliases for ease (optional)

nano ~/.profile

Add these to the end of your .profile

export BITCOIN_DIR="/blockchain/.bitcoin"
export BITCOIN_CONF="$BITCOIN_DIR/bitcoin.conf"

alias btcd="/usr/local/bin/bitcoind -conf=$BITCOIN_CONF"
alias btcli="/usr/local/bin/bitcoin-cli -conf=$BITCOIN_CONF"
alias logbtcd="tail -f ~/bitcoind.log"

alias btcdt="/usr/local/bin/bitcoind -testnet -conf=$BITCOIN_CONF"
alias btclit="/usr/local/bin/bitcoin-cli -testnet -conf=$BITCOIN_CONF"
alias logbtcdt="tail -f ~/bitcoind.testnet.log"

Save the file then source it to shell

source ~/.profile

Check the debug logs to make sure bitcoind is by running

logbtcd
logbtcdt

You should see output like this for mainnet

mainnet output
2022-10-31T02:04:42Z Bitcoin Core version v24.0.0 (release build)
2022-10-31T02:04:42Z InitParameterInteraction: parameter interaction: -proxy set -> setting -natpmp=0
2022-10-31T02:04:42Z InitParameterInteraction: parameter interaction: -proxy set -> setting -discover=0
2022-10-31T02:04:42Z Validating signatures for all blocks.
2022-10-31T02:04:42Z Setting nMinimumChainWork=00000000000000000000000000000000000000001fa4663bbbe19f82de910280
2022-10-31T02:04:42Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2022-10-31T02:04:42Z Using RdSeed as additional entropy source
2022-10-31T02:04:42Z Using RdRand as an additional entropy source
2022-10-31T02:04:42Z Using data directory /blockchain/.bitcoin
2022-10-31T02:04:42Z Config file: /home/<USER>/.bitcoin/bitcoin.conf
2022-10-31T02:04:42Z Config file arg: assumevalid="0"
2022-10-31T02:04:42Z Config file arg: daemon="1"
2022-10-31T02:04:42Z Config file arg: datadir="/blockchain/.bitcoin"
2022-10-31T02:04:42Z Config file arg: dbcache="2000"
2022-10-31T02:04:42Z Config file arg: debug="mempool"
2022-10-31T02:04:42Z Config file arg: debug="rpc"
2022-10-31T02:04:42Z Config file arg: dnsseed="1"
2022-10-31T02:04:42Z Config file arg: listen="1"
2022-10-31T02:04:42Z Config file arg: maxmempool="100"
2022-10-31T02:04:42Z Config file arg: maxuploadtarget="1000"
2022-10-31T02:04:42Z Config file arg: peerbloomfilters=false
2022-10-31T02:04:42Z Config file arg: peerbloomfilters="0"
2022-10-31T02:04:42Z Config file arg: permitbaremultisig="0"
2022-10-31T02:04:42Z Config file arg: rpcauth=****
2022-10-31T02:04:42Z Config file arg: server="1"
2022-10-31T02:04:42Z Config file arg: txindex="1"
2022-10-31T02:04:42Z Config file arg: upnp="0"
2022-10-31T02:04:42Z Config file arg: [main] port="8333"
2022-10-31T02:04:42Z Config file arg: [main] proxy="127.0.0.1:9050"
2022-10-31T02:04:42Z Config file arg: [main] rpcport="8332"
2022-10-31T02:04:42Z Config file arg: [main] zmqpubrawblock="tcp://127.0.0.1:28332"
2022-10-31T02:04:42Z Config file arg: [main] zmqpubrawtx="tcp://127.0.0.1:28333"
2022-10-31T02:04:42Z Config file arg: [regtest] port="68333"
2022-10-31T02:04:42Z Config file arg: [regtest] rpcport="68332"
2022-10-31T02:04:42Z Config file arg: [regtest] zmqpubrawblock="tcp://127.0.0.1:78332"
2022-10-31T02:04:42Z Config file arg: [regtest] zmqpubrawtx="tcp://127.0.0.1:78333\\"
2022-10-31T02:04:42Z Config file arg: [signet] port="48333"
2022-10-31T02:04:42Z Config file arg: [signet] rpcport="48332"
2022-10-31T02:04:42Z Config file arg: [signet] zmqpubrawblock="tcp://127.0.0.1:58332"
2022-10-31T02:04:42Z Config file arg: [signet] zmqpubrawtx="tcp://127.0.0.1:58333"
2022-10-31T02:04:42Z Config file arg: [test] port="18333"
2022-10-31T02:04:42Z Config file arg: [test] rpcport="18332"
2022-10-31T02:04:42Z Config file arg: [test] zmqpubrawblock="tcp://127.0.0.1:38332"
2022-10-31T02:04:42Z Config file arg: [test] zmqpubrawtx="tcp://127.0.0.1:38333"
2022-10-31T02:04:42Z Command-line arg: conf="/home/<USER>/.bitcoin/bitcoin.conf"
2022-10-31T02:04:42Z Using at most 125 automatic connections (2560 file descriptors available)
2022-10-31T02:04:42Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2022-10-31T02:04:42Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2022-10-31T02:04:42Z Script verification uses 11 additional threads
2022-10-31T02:04:42Z scheduler thread start
2022-10-31T02:04:42Z HTTP: creating work queue of depth 16
2022-10-31T02:04:42Z Starting RPC
2022-10-31T02:04:42Z Starting HTTP RPC server
2022-10-31T02:04:42Z Using random cookie authentication.
2022-10-31T02:04:42Z Generated RPC authentication cookie /blockchain/.bitcoin/.cookie
2022-10-31T02:04:42Z Using rpcauth authentication.
2022-10-31T02:04:42Z HTTP: starting 4 worker threads
2022-10-31T02:04:42Z Using wallet directory /blockchain/.bitcoin
2022-10-31T02:04:42Z init message: Verifying wallet(s)…
2022-10-31T02:04:42Z init message: Loading banlist…
2022-10-31T02:04:42Z SetNetworkActive: true
2022-10-31T02:04:42Z Using /16 prefix for IP bucketing
2022-10-31T02:04:42Z Cache configuration:
2022-10-31T02:04:42Z * Using 2.0 MiB for block index database
2022-10-31T02:04:42Z * Using 249.8 MiB for transaction index database
2022-10-31T02:04:42Z * Using 8.0 MiB for chain state database
2022-10-31T02:04:42Z * Using 1740.2 MiB for in-memory UTXO set (plus up to 95.4 MiB of unused mempool space)
2022-10-31T02:04:42Z init message: Loading block index…
2022-10-31T02:04:42Z Switching active chainstate to Chainstate [ibd] @ height -1 (null)
2022-10-31T02:04:42Z Opening LevelDB in /blockchain/.bitcoin/blocks/index
2022-10-31T02:04:42Z Opened LevelDB successfully
2022-10-31T02:04:42Z Using obfuscation key for /blockchain/.bitcoin/blocks/index: 0000000000000000

And output like this for testnet

testnet output
2022-10-31T02:01:49Z Bitcoin Core version v24.0.0 (release build)
2022-10-31T02:01:49Z Validating signatures for all blocks.
2022-10-31T02:01:49Z Setting nMinimumChainWork=0000000000000000000000000000000000000000000005180c3bd8290da33a1a
2022-10-31T02:01:49Z Using the 'sse4(1way),sse41(4way),avx2(8way)' SHA256 implementation
2022-10-31T02:01:49Z Using RdSeed as additional entropy source
2022-10-31T02:01:49Z Using RdRand as an additional entropy source
2022-10-31T02:01:49Z Using data directory /blockchain/.bitcoin/testnet3
2022-10-31T02:01:49Z Config file: /Volumes/BLOCKCHAIN/.bitcoin/bitcoin.conf
2022-10-31T02:01:49Z Config file arg: assumevalid="0"
2022-10-31T02:01:49Z Config file arg: daemon="1"
2022-10-31T02:01:49Z Config file arg: datadir="/blockchain/.bitcoin"
2022-10-31T02:01:49Z Config file arg: dbcache="2000"
2022-10-31T02:01:49Z Config file arg: debug="mempool"
2022-10-31T02:01:49Z Config file arg: debug="rpc"
2022-10-31T02:01:49Z Config file arg: dnsseed="1"
2022-10-31T02:01:49Z Config file arg: listen="1"
2022-10-31T02:01:49Z Config file arg: maxmempool="100"
2022-10-31T02:01:49Z Config file arg: maxuploadtarget="1000"
2022-10-31T02:01:49Z Config file arg: peerbloomfilters=false
2022-10-31T02:01:49Z Config file arg: peerbloomfilters="0"
2022-10-31T02:01:49Z Config file arg: permitbaremultisig="0"
2022-10-31T02:01:49Z Config file arg: rpcauth=****
2022-10-31T02:01:49Z Config file arg: server="1"
2022-10-31T02:01:49Z Config file arg: txindex="1"
2022-10-31T02:01:49Z Config file arg: upnp="0"
2022-10-31T02:01:49Z Config file arg: [main] port="8333"
2022-10-31T02:01:49Z Config file arg: [main] proxy="127.0.0.1:9050"
2022-10-31T02:01:49Z Config file arg: [main] rpcport="8332"
2022-10-31T02:01:49Z Config file arg: [main] zmqpubrawblock="tcp://127.0.0.1:28332"
2022-10-31T02:01:49Z Config file arg: [main] zmqpubrawtx="tcp://127.0.0.1:28333"
2022-10-31T02:01:49Z Config file arg: [regtest] port="68333"
2022-10-31T02:01:49Z Config file arg: [regtest] rpcport="68332"
2022-10-31T02:01:49Z Config file arg: [regtest] zmqpubrawblock="tcp://127.0.0.1:78332"
2022-10-31T02:01:49Z Config file arg: [regtest] zmqpubrawtx="tcp://127.0.0.1:78333\\"
2022-10-31T02:01:49Z Config file arg: [signet] port="48333"
2022-10-31T02:01:49Z Config file arg: [signet] rpcport="48332"
2022-10-31T02:01:49Z Config file arg: [signet] zmqpubrawblock="tcp://127.0.0.1:58332"
2022-10-31T02:01:49Z Config file arg: [signet] zmqpubrawtx="tcp://127.0.0.1:58333"
2022-10-31T02:01:49Z Config file arg: [test] port="18333"
2022-10-31T02:01:49Z Config file arg: [test] rpcport="18332"
2022-10-31T02:01:49Z Config file arg: [test] zmqpubrawblock="tcp://127.0.0.1:38332"
2022-10-31T02:01:49Z Config file arg: [test] zmqpubrawtx="tcp://127.0.0.1:38333"
2022-10-31T02:01:49Z Command-line arg: conf="/home/<USER>/.bitcoin/bitcoin.conf"
2022-10-31T02:01:49Z Command-line arg: testnet=""
2022-10-31T02:01:49Z Using at most 125 automatic connections (2560 file descriptors available)
2022-10-31T02:01:49Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2022-10-31T02:01:49Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2022-10-31T02:01:49Z Script verification uses 11 additional threads
2022-10-31T02:01:49Z scheduler thread start
2022-10-31T02:01:49Z HTTP: creating work queue of depth 16
2022-10-31T02:01:49Z Starting RPC
2022-10-31T02:01:49Z Starting HTTP RPC server
2022-10-31T02:01:49Z Using random cookie authentication.
2022-10-31T02:01:49Z Generated RPC authentication cookie /blockchain/.bitcoin/testnet3/.cookie
2022-10-31T02:01:49Z Using rpcauth authentication.
2022-10-31T02:01:49Z HTTP: starting 4 worker threads
2022-10-31T02:01:49Z Using wallet directory /blockchain/.bitcoin/testnet3/wallets
2022-10-31T02:01:49Z init message: Verifying wallet(s)…
2022-10-31T02:01:49Z init message: Loading banlist…
2022-10-31T02:01:49Z SetNetworkActive: true
2022-10-31T02:01:49Z Using /16 prefix for IP bucketing
2022-10-31T02:01:49Z Cache configuration:
2022-10-31T02:01:49Z * Using 2.0 MiB for block index database
2022-10-31T02:01:49Z * Using 249.8 MiB for transaction index database
2022-10-31T02:01:49Z * Using 8.0 MiB for chain state database
2022-10-31T02:01:49Z * Using 1740.2 MiB for in-memory UTXO set (plus up to 95.4 MiB of unused mempool space)
2022-10-31T02:01:49Z init message: Loading block index…
2022-10-31T02:01:49Z Switching active chainstate to Chainstate [ibd] @ height -1 (null)
2022-10-31T02:01:49Z Opening LevelDB in /blockchain/.bitcoin/testnet3/blocks/index
2022-10-31T02:01:49Z Opened LevelDB successfully
2022-10-31T02:01:49Z Using obfuscation key for /blockchain/.bitcoin/testnet3/blocks/index: 0000000000000000

Create a file to rotate the logs

sudo nano /etc/logrotate.d/bitcoin-debug
  • Add these instructions to this file
/blockchain/.bitcoin/data/debug.log
/blockchain/.bitcoin/data/testnet3/debug.log
{
      rotate 5
      copytruncate
      daily
      missingok
      notifempty
      compress
      delaycompress
      sharedscripts
}

Install Go

Check Go version

# Should see something like this depending on your hardware go version go1.18.6 linux/arm64
# You need to have version 1.18.6 or higher
go version

If you have a version below 1.18.6, delete it

sudo rm -rf /usr/local/go

If installing Go for the first time

sudo apt-get update && sudo apt-get -y upgrade

Download Go v19.2+

# substitute the cpu arch in the command based on your hardware's cpu architecture
# If using raspberry pi, use the links in this guide for armv6l
# Other options are amd64 or arm64
wget https://golang.org/dl/go1.20.4.linux-armv6l.tar.gz

Extract Go download

# substitute the cpu arch in the command based on your hardware's cpu architecture
# If using raspberry pi, use the links in this guide for armv6l
# Other options are amd64 or arm64
sudo tar -xvf go1.20.4.linux-armv6l.tar.gz

Install go and remove the download

# substitute the cpu arch in the command based on your hardware's cpu architecture
# If using raspberry pi, use the links in this guide for armv6l
# Other options are amd64 or arm64
sudo mv go /usr/local && rm go1.20.4.armv6l.tar.gz

Make a directory for go & setup the path to use the Go directory

mkdir ~/go
nano ~/.profile

# Place these lines at the end of the .profile file# Place these lines at the end of the .profile file
export GOPATH=$HOME/go
export PATH="$HOME/bin:$GOPATH/bin:$HOME/.local/bin:/usr/local/go/bin:$PATH"

Save and exit, then source profile

source ~/.profile

Install LND

Get build tools

sudo apt-get install -y build-essential

Clone the LND repo

cd ~/
git clone https://github.com/lightningnetwork/lnd.git
cd lnd && git checkout v0.16.2-beta

Install LND

make && make install tags="autopilotrpc chainrpc invoicesrpc peersrpc routerrpc signrpc walletrpc watchtowerrpc wtclientrpc"
mkdir ~/.lnd
nano ~/.lnd/lnd.conf

Add the following settings to lnd.conf replacing values surrounded by <> with your own data

lnd.conf
[Application Options]
# Allow push payments
accept-keysend=1

# Public network name
# !!NOTE!! replace this
alias=<YOUR ALIAS>

# Allow gift routes
allow-circular-route=1

# Public hex color
# !!NOTE!! replace this
color=<#RRGGBB>

# Reduce the cooperative close chain fee
coop-close-target-confs=1000

# Log levels
debuglevel=CNCT=debug,CRTR=debug,HSWC=debug,NTFN=debug,RPCS=debug

# Public P2P IP
# !!NOTE!! if not using Tunnelsats, and you have an external IP, place that here
# If using tunnelsats, ignore this
# externalip=<YOUR-PUBLIC-IP>

# Mark unpayable, unpaid invoices as deleted
gc-canceled-invoices-on-startup=1
gc-canceled-invoices-on-the-fly=1

# Avoid historical graph data sync
ignore-historical-gossip-filters=1

# Listen
listen=localhost

# Tunnelsats
# externalhosts=<TBD during Install TunnelSats Step>

# Set REST address
restlisten=0.0.0.0:8080

# Set the maximum amount of commit fees in a channel
max-channel-fee-allocation=1.0

# Set the max timeout blocks of a payment
max-cltv-expiry=5000

# Allow commitment fee to rise on anchor channels
max-commit-fee-rate-anchors=100

# Pending channel limit
maxpendingchannels=10

# Min inbound channel limit
minchansize=500000

# gRPC socket binding
rpclisten=0.0.0.0:10009

# Avoid high startup overhead
stagger-initial-reconnect=1

# Delete and recreate RPC TLS certificate when details change or cert expires
tlsautorefresh=1

# Do not include IPs in the RPC TLS certificate
tlsdisableautofill=1

# Uncomment if you want to add DNS to the RPC TLS certificate
# tlsextradomain=<YOUR_DOMAIN_NAME>

# The full path to a file that contains the password for unlocking the wallet
# !!NOTE!! Uncomment this line after you have created a wallet
# wallet-unlock-password-file=/home/<USER>/.lnd/wallet_password

[Bitcoin]
# Turn on Bitcoin mode
bitcoin.active=1

# Set the channel confs to wait for channels
bitcoin.defaultchanconfs=2

# Forward fee rate in parts per million
bitcoin.feerate=1000

# Set bitcoin.testnet=1 or bitcoin.mainnet=1 as appropriate
bitcoin.mainnet=1

# Set the lower bound for HTLCs
bitcoin.minhtlc=1

# Set backing node, bitcoin.node=neutrino or bitcoin.node=bitcoind
bitcoin.node=bitcoind

# Set CLTV forwarding delta time
bitcoin.timelockdelta=144

[bitcoind]
# Configuration for using Bitcoin Core backend
bitcoind.rpchost=127.0.0.1:8332

# Set the password to the rpc-auth command output
bitcoind.rpcpass=B-0-y3ai_R7I4QKWONkU58qcG9tvnr7Y6K5-os2QJZf=

# Set the username from the rpc-auth command output
bitcoind.rpcuser=Satoshi

# Set the ZMQ listeners
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333

[bolt]
# Enable database compaction when restarting
db.bolt.auto-compact=true

[protocol]
# Enable large channels support
protocol.wumbo-channels=1

[routerrpc]
# Set default chance of a hop success
routerrpc.apriorihopprob=0.5

# Start to ignore nodes if they return many failures (set to 1 to turn off)
routerrpc.aprioriweight=0.75

# Set minimum desired savings of trying a cheaper path
routerrpc.attemptcost=10
routerrpc.attemptcostppm=10

# Set the number of historical routing records
routerrpc.maxmchistory=10000

# Set the min confidence in a path worth trying
routerrpc.minrtprob=0.005

# Set the time to forget past routing failures
routerrpc.penaltyhalflife=6h0m0s

[routing]
# Remove channels from graph that have one side that hasn't made announcements
routing.strictgraphpruning=1

[Tor]
# Enable Tor if using
tor.active=1
tor.v3=1
# TunnelSats: uncomment these after the tunnel sats step
# tor.skip-proxy-for-clearnet-targets=true
# tor.streamisolation=false

Create LND auto unlock password file

openssl rand -hex 21 > ~/.lnd/wallet_password

cat ~/.lnd/wallet_password
# Copy the output of the `cat` command and save for later.

Create systemd file lnd.service

sudo nano /etc/systemd/system/lnd.service

Replace with your username, and with your user group in the below file

  • to get your username, run whoami or echo $USER
  • to get your user group, run groups and copy the first in the list

After updating the file, copy/paste it into your lnd.service file opened via nano on your node, and save it using CTRL-O, Enter, CTRL-X.

lnd.service
[Unit]
Description=Lightning Network Daemon
Documentation=https://github.com/lightningnetwork/lnd/blob/master/contrib/init/README.md

Requires=bitcoind.service
After=bitcoind.service

[Service]
ExecStart=/home/<USER>/go/bin/lnd
ExecStop=/home/<USER>/go/bin/lncli --rpcserver=localhost:10009 --macaroonpath=/home/<USER>/.lnd/data/chain/bitcoin/mainnet/admin.macaroon stop

User=<USER>
Group=<GROUP>

Restart=on-failure
RestartSec=60

Type=notify

TimeoutStartSec=1200
TimeoutStopSec=3600

ProtectSystem=full

NoNewPrivileges=true

PrivateDevices=true

MemoryDenyWriteExecute=true

StandardOutput=/home/<USER>/.lnd/logs/bitcoin/mainnet/lnd.log
StandardError=/home/<USER>/.lnd/err.log

SyslogIdentifier=lnd

RuntimeDirectory=lnd
RuntimeDirectoryMode=0710

[Install]
WantedBy=multi-user.target

Start lnd.service

sudo systemctl daemon-reload
sudo systemctl enable lnd
sudo systemctl start lnd

Create mainnet LND wallet

lncli create

Follow the prompts and input the following:

  • password: use the password created above that we placed in /home/<USER>/.lnd/wallet_password (x2)
  • seed: n (create a new seed unless you want to recover using another LND seed phrase)
  • passphrase: leave this blank

Be sure to copy the seed phrase and pw somewhere safe!

Update lnd.conf once the wallet creation is complete and uncomment wallet-unlock-password

# The full path to a file that contains the password for unlocking the wallet
wallet-unlock-password-file=/home/<USER>/.lnd/wallet_password

Repeat this process for lnd.testnet

Create a testnet LND conf & add the following settings

nano ~/.lnd/lnd.testnet.conf
lnd.testnet.conf
[Application Options]
# Allow push payments
accept-keysend=1

# Public network name
# !!NOTE!! replace this with the same name as lnd.conf
alias=<YOUR ALIAS>

# Allow gift routes
allow-circular-route=1

# Public hex color
# !!NOTE!! replace this with the same color as lnd.conf
color=<#RRGGBB>

# Reduce the cooperative close chain fee
coop-close-target-confs=1000

# Log levels
debuglevel=CNCT=debug,CRTR=debug,HSWC=debug,NTFN=debug,RPCS=debug

# Public P2P IP
# Don't need this bc we're using Tunnelsats
# externalip=<YOUR-PUBLIC-IP>

# Mark unpayable, unpaid invoices as deleted
gc-canceled-invoices-on-startup=1
gc-canceled-invoices-on-the-fly=1

# Avoid historical graph data sync
ignore-historical-gossip-filters=1

# Listen
listen=0.0.0.0:9734

# Tunnelsats
# externalhosts=<TBD in Tunnel SATs step>

# Set REST port
restlisten=0.0.0.0:8081

# Set the maximum amount of commit fees in a channel
max-channel-fee-allocation=1.0

# Set the max timeout blocks of a payment
max-cltv-expiry=5000

# Allow commitment fee to rise on anchor channels
max-commit-fee-rate-anchors=100

# Pending channel limit
maxpendingchannels=10

# Min inbound channel limit
minchansize=500000

# gRPC socket binding
rpclisten=0.0.0.0:10010

# Avoid high startup overhead
stagger-initial-reconnect=1

# Delete and recreate RPC TLS certificate when details change or cert expires
tlsautorefresh=1

# Do not include IPs in the RPC TLS certificate
tlsdisableautofill=1

# Add DNS to the RPC TLS certificate
# tlsextradomain=YOUR_DOMAIN_NAME

# The full path to a file that contains the password for unlocking the wallet
# !!NOTE!! Uncomment this line after you have created a testnet wallet
# wallet-unlock-password-file=/home/<USER>/.lnd/wallet_password_testnet

[Bitcoin]
# Turn on Bitcoin mode
bitcoin.active=1

# Set the channel confs to wait for channels
bitcoin.defaultchanconfs=2

# Forward fee rate in parts per million
bitcoin.feerate=1000

# Set bitcoin.testnet=1 or bitcoin.mainnet=1 as appropriate
bitcoin.testnet=1

# Set the lower bound for HTLCs
bitcoin.minhtlc=1

# Set backing node, bitcoin.node=neutrino or bitcoin.node=bitcoind
bitcoin.node=bitcoind

# Set CLTV forwarding delta time
bitcoin.timelockdelta=144

[bitcoind]
# Configuration for using Bitcoin Core backend
bitcoind.dir=/blockchain/.bitcoin/testnet3

# rpc host address
bitcoind.rpchost=localhost:18332

# Set the password to what the auth script said
# Same as mainnet
bitcoind.rpcpass=B-0-y3ai_R7I4QKWONkU58qcG9tvnr7Y6K5-os2QJZf=

# Set the username
# Same as mainnet
bitcoind.rpcuser=Satoshi

# Set the ZMQ listeners
bitcoind.zmqpubrawblock=tcp://127.0.0.1:38332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:38333

[bolt]
# Enable database compaction when restarting
db.bolt.auto-compact=true

[protocol]
# Enable large channels support
protocol.wumbo-channels=1

[routerrpc]
# Set default chance of a hop success
routerrpc.apriorihopprob=0.5

# Start to ignore nodes if they return many failures (set to 1 to turn off)
routerrpc.aprioriweight=0.75

# Set minimum desired savings of trying a cheaper path
routerrpc.attemptcost=10
routerrpc.attemptcostppm=10

# Set the number of historical routing records
routerrpc.maxmchistory=10000

# Set the min confidence in a path worth trying
routerrpc.minrtprob=0.005

# Set the time to forget past routing failures
routerrpc.penaltyhalflife=6h0m0s

[routing]
# Remove channels from graph that have one side that hasn't made announcements
routing.strictgraphpruning=1

[Tor]
# Enable Tor if using
tor.active=1
tor.v3=1
# TunnelSats: uncomment these after the tunnel sats step
# tor.skip-proxy-for-clearnet-targets=true
# tor.streamisolation=false

Create LND auto unlock password file

openssl rand -hex 21 > ~/.lnd/wallet_password_testnet

cat ~/.lnd/wallet_password_testnet
# Copy the output of the `cat` command and save for later.

Create systemd file lnd.testnet.service

sudo nano /etc/systemd/system/lnd.testnet.service

Replace with your username, and with your user group in the below file

  • to get your username, run whoami or echo $USER
  • to get your user group, run groups and copy the first in the list

After updating the file, copy/paste it into your lnd.testnet.service file opened via nano on your node, and save it using CTRL-O, Enter, CTRL-X.

lnd.testnet.service
[Unit]
Description=Lightning Network Daemon Testnet
Documentation=https://github.com/lightningnetwork/lnd/blob/master/contrib/init/README.md

Requires=bitcoind.service
After=bitcoind.service

[Service]
ExecStart=/home/<USER>/go/bin/lnd --configfile=/home/<USER>/.lnd/lnd.testnet.conf
ExecStop=/home/<USER>/go/bin/lncli --rpcserver=localhost:10010 --macaroonpath=/home/<USER>/.lnd/data/chain/bitcoin/testnet/admin.macaroon stop

User=<USER>
Group=<GROUP>

Restart=on-failure
RestartSec=60

Type=notify

TimeoutStartSec=1200
TimeoutStopSec=3600

ProtectSystem=full

NoNewPrivileges=true

PrivateDevices=true

MemoryDenyWriteExecute=true

StandardOutput=/home/<USER>/.lnd/logs/bitcoin/testnet/lnd.log
StandardError=/home/<USER>/.lnd/err.testnet.log

SyslogIdentifier=lnd.testnet

RuntimeDirectory=lnd.testnet
RuntimeDirectoryMode=0710

[Install]
WantedBy=multi-user.target

Start lnd.testnet.service

sudo systemctl daemon-reload
sudo systemctl enable lnd.testnet.service
sudo systemctl start lnd.testnet.service

Update lnd.testnet.conf once the wallet creation is complete and uncomment wallet-unlock-password

...
# The full path to a file that contains the password for unlocking the wallet
wallet-unlock-password-file=/home/<USER>/.lnd/wallet_password_testnet
...

Create symlinks between lnd logs in /blockchain to your local home dir for easier access

# Mainnet:
ln -s ~/.lnd/logs/bitcoin/mainnet/lnd.log ~/lnd.log
# Testnet:
ln -s ~/.lnd/logs/bitcoin/testnet/lnd.log ~/lnd.testnet.log

Edit your shell profile, add the following exports + aliases, save + close .profile & source it Be sure to replace with your username

nano ~/.profile

alias lnd="/home/<USER>/go/bin/lnd"
alias lncli="/home/<USER>/go/bin/lncli --rpcserver=localhost:10009 --macaroonpath=/home/<USER>/.lnd/data/chain/bitcoin/mainnet/admin.macaroon"
alias loglnd="tail -f ~/lnd.log"

alias lndt="/home/<USER>/go/bin/lnd --configfile=/home/<USER>/.lnd/lnd.testnet.conf"
alias lnclit="/home/<USER>/go/bin/lncli --rpcserver=localhost:10010 --macaroonpath=/home/<USER>/.lnd/data/chain/bitcoin/testnet/admin.macaroon" 
alias loglndt="tail -f ~/lnd.testnet.log"

source ~/.profile

Install TunnelSats

Follow the install guide here: https://tunnelsats.github.io/tunnelsats/#install or follow the steps below:

  1. Go to tunnelsats.com, select a country of your choice (ideally close to your real location for faster connection speed) & choose how long you want to use the service (1 to 12 months).
  2. Pay the lightning invoice.
  3. Copy, download or send the wireguard configuration (file: tunnelsatsv2.conf - please do NOT rename this file) to your local computer and transfer it to your node.
  4. Backup tunnelsatsv2.conf to a safe place (to prevent deletion on updates, for example create a new directory called /tunnelsats/ and save the config file in there.

To get the tunnelsatsv2.conf file onto your node from your local machine, use scp. Once you download the .conf, do the following: Be sure to replace anything wrapped in <> with your own data.

cd <folder/containing/>tunnelsatsv2.conf
scp ./tunnelsatsv2.conf <remote-username>@<remote-ip>:/home/<USER>

Once you get the conf file onto your node, create a folder called tunnelsats inside the /blockchain folder and move the .conf file to that folder

mkdir /blockchain/tunnelsats
mv tunnelsatsv2.conf /blockchain/tunnelsats

Download the setup script onto your node

cd /blockchain/tunnelsats
wget -O setupv2.sh https://github.com/tunnelsats/tunnelsats/raw/main/scripts/setupv2.sh

While inside the tunnelsats folder with the tunnelsatsv2.conf and the setupv2.sh files in it, run

sudo bash setupv2.sh

If it worked, VPN credentials & instructions are shown. Copy to a file locally / write them down for later use. Output should look similar to below:

#########################################
[Application Options]
listen=0.0.0.0:9735
externalhosts={vpnDNS}:{vpnPort}

[Tor]
tor.streamisolation=false
tor.skip-proxy-for-clearnet-targets=true
#########################################

Add lines to your lnd.conf and lnd.testnet.conf files

...
# Listen
listen=localhost

# Tunnelsats
# {vpnDNS}:{vpnPort} are output by the tunnel sats setup script
externalhosts={vpnDNS}:{vpnPort}

# Set REST address
restlisten=0.0.0.0:8080
...

[Tor]
# Enable Tor if using
tor.active=1
tor.v3=1
# TunnelSats: uncomment these lines
tor.skip-proxy-for-clearnet-targets=true
tor.streamisolation=false

Restart lnd and lnd.testnet services

sudo systemctl restart lnd
sudo systemctl restart lnd.testnet

Head over to 1ml.com, Amboss, Acinq or any other network explorer you'd like, and start finding large nodes to peer and open channels with. I prefer 1ml for testnet nodes and Amboss or Acinq for mainnet nodes.

Connect to peers using lncli connect (mainnet) and lnclit connect (testnet)

lncli connect <peer-pubkey>@<peer-ip>:9735
lnclit connect <testnet-peer-pubkey>@<testnet-peer-ip>:9735

Generate new addresses using lncli newaddress (mainnet) and lnclit newaddress (testnet)

lncli newaddress p2wkh
# output
{
  "address": "bc1q..."
}
lnclit newaddress p2wkh
# output
{
  "address": "tb1q..."
}

Send funds to that address and wait for it to confirm. If sending on mainnet, always test a small amount first to ensure everything is working correctly. You can then use lncli walletbalance to check the status of the tx.

For testnet funds, checkout these testnet faucets:

You can also find a list of faucets here:

Congrats! If you made it this far, you now have a fully functioning, hybrid (clearnet + tor) bitcoin full node and LND Lighting node running on mainnet and testnet. Have fun with it! Checkout the LND repo for information on its usage or type lncli help into your node terminal. Enjoy the fact that you now have a hybrid Bitcoin Lightning node setup and running on both testnet and mainnet!

Optional: Follow Bosworth's guide for installing his bos tool (Balance of Satoshis).

For bugs, errors, inquiries or questions, feel free to leave comments below or you can please DM me on telegram or twitter. I welcome any and all feedback! You can also clone this gist, make edits, push it to your own github and sned me the link so I can update this gist with your changes!

To clone:

git clone [email protected]:2a46b30fe171bfc8523edd4a835f8644 bnonni-diy-hybrid-lightning-node-mainnet-testnet
cd bnonni-diy-hybrid-lightning-node-mainnet-testnet

Open the folder in your fave editor & make changes at will! To push changes to your github, create a new gist then:

# inside gist folder locally
git remote set-url origin [email protected]:<HASID-OF-NEW-GIST>
git add -A
git commit -m "updating bnonni gist"
git push -u origin master

A pleb, I now dub you.# DIY: Hybrid Lightning Node - Mainnet & Testnet The goal of this gist is to provide the pleb community with an easy to follow guide for how to setup a lightning node that runs on both Mainnet and Testnet at the same time. This guide will also walk you through setting up your node in "hybrid mode" (i.e. clearnet + tor) and installing Tunnel SATS for your static clearnet IP.

Next Steps - Lightning / LND

Go find large, well-connected nodes to opens channels with and start sending payments. For help with interacting with you LN node via LND cli, checkout the LND repo for more information on how to use lnd and lncli or simply type lncli help into your node terminal.

Use Lightning Network explorers like 1ML.com, Amboss.space or acinq.co or mempool.space to find nodes to connect to (peer) and open channels with. For testnet, 1ML has a good list of large capacity nodes to connect to and open channels with.

Lightning Network Explorers:

Connect to peers using lncli connect (mainnet) and lnclit connect (testnet)

lncli connect <peer-pubkey>@<peer-ip>:9735
lnclit connect <testnet-peer-pubkey>@<testnet-peer-ip>:9735

Generate new addresses using lncli newaddress (mainnet) and lnclit newaddress (testnet)

lncli newaddress p2wkh
{
  "address": "bc1q..."
}

lnclit newaddress p2wkh
{
  "address": "tb1q..."
}

Send funds to that address and wait for it to confirm. If sending on mainnet, always test a small amount first to ensure everything is working correctly. You can then use lncli walletbalance to check the status of the tx.

For testnet funds, checkout these testnet faucets:

You can also find a list of faucets at lopp.net...faucets.

Be sure to check out Alex Bosworth's LND cli tool called Balance of Satoshis aka (bos).

For bugs, errors, inquiries or questions, feel free to leave comments below or you can please DM me on telegram or twitter. I welcome any and all feedback!

Feel free to clone this gist to make edits.

git clone [email protected]:2a46b30fe171bfc8523edd4a835f8644 \
        bnonni-diy-hybrid-lightning-node-mainnet-testnet
cd bnonni-diy-hybrid-lightning-node-mainnet-testnet
git remote set-url origin [email protected]:<HASID-OF-NEW-GIST>
git add -A
git commit -m "updating bnonni gist"
git push -u origin master

The End of the Beginning

You did it! Congrats! If you successfully made it here, you now have a fully functioning, hybrid (clearnet + tor) bitcoin full node and LND Lighting node running on mainnet and testnet, but this is not the end! Merely the end of the beginning of your pleb journey into Bitcoin! Best of luck!

image bitcoin_yoda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment