Setup The OS
wget https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-04-07/2022-04-04-raspios-bullseye-arm64-lite.img.xz
$ sudo apt install vim tmux $ sudo swapoff –all $ sudo apt-get remove dphys-swapfile
Setup the Bitcoin Daemon
$ wget https://bitcoin.org/bin/bitcoin-core-22.0/bitcoin-22.0-x86_64-linux-gnu.tar.gz $ tar xf bitcoin-22.0-x86_64-linux-gnu.tar.gz
sudo useradd -m bitcoin sudo su bitcoin cd && mkdir .bitcoin
vim /home/bitcoin/.bitcoin/bitcoin.conf.
Set <USER_VALUE> and <PASS_VALUE>
server=1 daemon=1 testnet=0 txindex=1 # Connection Settings rpcuser=<USER_VALUE> rpcpassword=<PASS_VALUE> zmqpubrawblock=tcp://127.0.0.1:18501 zmqpubrawtx=tcp://127.0.0.1:18502 # Raspberry Pi Optimizations #dbcache=100 #maxorphantx=10 #maxmempool=50 #maxconnections=20 #maxuploadtarget=5000
exit sudo vim /etc/systemd/system/bitcoind.service
[Unit] Description=Bitcoin daemon After=network.target [Service] User=bitcoin Group=bitcoin Type=forking PIDFile=/home/bitcoin/.bitcoin/bitcoind.pid ExecStart=/home/timo/bitcoin-22.0/bin/bitcoind -pid=/home/bitcoin/.bitcoin/bitcoind.pid KillMode=process Restart=always TimeoutSec=120 RestartSec=30 [Install] WantedBy=multi-user.target
sudo systemctl enable bitcoind.service
Attach storage
$ sudo lsblk -o UUID,NAME,FSTYPE,SIZE,LABEL,MODEL $ sudo vim /etc/fstab
To mount after reboot
UUID=655e4bf5-ca88-462d-b0c8-d78aed3429d2 /mnt/usbdisk ext4 errors=remount-ro 0 1
Place bitcoind’s directory onto the disk
# mkdir /mnt/usbdisk # mount -a # cp -aR /home/bitcoin/.bitcoin /mnt/usbdisk/ # rm /home/bitcoin/.bitcoin -Rf # ln -s /mnt/usbdisk/.bitcoin /home/bitcoin/.bitcoin # chown -R bitcoin:bitcoin /mnt/usbdisk/
Start bitcoind and sync the blockchain NOTE: To speed things up a LOT(!) sync the blockchain on your desktop PC
# systemctl start bitcoind
Setup and Configure LND
Download the latest release from https://github.com/lightningnetwork/lnd/releases
wget https://github.com/lightningnetwork/lnd/releases/download/v0.14.3-beta/lnd-linux-amd64-v0.14.3-beta.tar.gz tar xf lnd-linux-amd64-v0.14.3-beta.tar.gz
$ sudo su bitcoin $ cd $ mkdir /home/bitcoin/.lnd $ vim /home/bitcoin/.lnd/lnd.conf
The lnd config file. Replace <ALIAS_NAME> with the name of your lighning
node and <COLOR_VALUE> with a hex color. For example lnd_node and #f8f8f8:
[Application Options] #debuglevel=debug #debughtlc=true maxpendingchannels=1 alias=<ALIAS_NAME> color=<COLOR_VALUE> listen=0.0.0.0:9735 listen=[::1]:9736 externalip=2a00:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:cfa3 [Bitcoin] bitcoin.active=1 bitcoin.mainnet=1 bitcoin.node=bitcoind [Bitcoind] bitcoind.rpcuser=<USER_VALUE> bitcoind.rpcpass=<PASS_VALUE> bitcoind.zmqpubrawblock=tcp://127.0.0.1:18501 bitcoind.zmqpubrawtx=tcp://127.0.0.1:18502 [autopilot] #autopilot.active=1 #autopilot.maxchannels=5 #autopilot.allocation=0.6 autopilot.active=true autopilot.allocation=0.9 autopilot.minchansize=182817 autopilot.maxchansize=682819 autopilot.maxchannels=50000
Get your external IP
$ wget -q -O- http://ipinfo.io/ip
The lnd systemd service file:
$ sudo vim /etc/systemd/system/lnd.service
[Unit] Description=Lightning Network daemon Requires=bitcoind.service After=bitcoind.service [Service] PIDFile=/home/bitcoin/.lnd/lnd.pid ExecStart=/home/timo/lnd-linux-amd64-v0.14.3-beta/lnd Restart=always RestartSec=60 User=bitcoin Group=bitcoin Type=simple [Install] WantedBy=multi-user.target
$ sudo systemctl enable lnd.service $ sudo systemctl start lnd.service $ systemctl status lnd.service
Using lnd
$ cd ~/lnd-linux-amd64-v0.14.3-beta $ sudo su bitcoin $ ./lncli --help $ ./lncli create $ ./lncli getinfo $ ./lncli newaddress np2wkh $ ./lncli walletbalance
To unlock the wallet
$ ./lncli unlock $ ./lncli listchannels
Using bitcoind
CPU mine to address (only for fun purposes)
./bitcoin-cli --rpcuser=<USER> --rpcpassword=<PASS> createwallet test ./bitcoin-cli --rpcuser=<USER> --rpcpassword=<PASS> getnewaddress bc1q3hn9yj2vc3c30aqjvjhqenl4dut2az4kqqq5yu ./bitcoin-cli --rpcuser=<USER> --rpcpassword=<PASS> generatetoaddress 1 "bc1q3hn9yj2vc3c30aqjvjhqenl4dut2az4kqqq5yu" ./bitcoin-cli --rpcuser=<USER> --rpcpassword=<PASS>