I'm a software engineer, Open source & Bitcoin supporter. I spend my time contributing to open source Bitcoin and Ligthning Network related projects, I want to help make Bitcoin better money and be easy to use for non technical people. I've been working on Lightning Network projects since Q1 2018, currently I'm an independent consultant on Bitcoin/Lightning Network related projects, if you want to talk just DM me.
Raspberry Pi Configuration with LND
1. Download Raspberry Pi OS Lite
2. Format the SD Card
$ is used as a prompt and allows the user to enter commands into the computer, the commands will be interpreted by bash in Linux. The symbol # at the beginning of a line indicates that the following text is a comment.3. Enable SSH
touch command, we create an empty file in the /boot partition, enabling SSH connection on the first boot of the freshly formatted SD card.# NOTE: If the microSD card has been mounted at /media/microSD, the command # should be $ sudo touch /media/microSD/boot/ssh $ touch /boot/ssh
4. Create file for Wi-Fi connection
wpa_supplicant.conf file and directly start editing it. In this file, we need to copy the wifi configuration, copying the text between START and END, and modifying the SSID and password of the wifi you want to connect to.$ nano /boot/wpa_supplicant.conf ------ START ------- country=ar update_config=1 ctrl_interface=/var/run/wpa_supplicant network={ ssid="MyNetworkSSID" psk="password" } ------ END -------
5. Connection
$ ssh [email protected] password: raspberry
$ ifconfig
nmap -v 192.168.0.0/24
$ ssh [email protected] password: raspberry
6. Configure the Pi
$ sudo raspi-config
- Select option (1) and change the password for the user pi.
- We select option (8) to update the configuration tool to the latest version
- We select option (4) to select our time zone
- We select option (7) and then Expand filesystem
- Finish
7. Now update the OS
$ sudo apt update && sudo apt upgrade -y $ sudo apt install htop git curl bash-completion jq qrencode dphys-swapfile vim --install-recommends -y
8. Add the bitcoin user
$ sudo adduser bitcoin
9. Secure the rpi
$ sudo apt install ufw $ sudo ufw default deny incoming $ sudo ufw default allow outgoing $ sudo ufw allow 22 comment 'allow SSH from LAN' $ sudo ufw allow 9735 comment 'allow Lightning' $ sudo ufw allow 10009 comment 'Lightning gRPC' $ sudo ufw enable $ sudo systemctl enable ufw $ sudo ufw status $ sudo apt install fail2ban
10. Install Go
$ wget https://golang.org/dl/go1.15.linux-armv6l.tar.gz $ sudo tar -C /usr/local -xzf go1.15.linux-armv6l.tar.gz $ echo "export PATH=$PATH:/usr/local/go/bin" >> ~/.bashrc $ echo "export GOPATH=$HOME/go" >> ~/.bashrc $ echo "export PATH=$PATH:$GOPATH/bin" >> ~/.bashrc $ source ~/.bashrc $ go version # should display the following message 'go version go1.13.5 linux/arm'
11. Compile and install LND
$ git clone https://github.com/lightningnetwork/lnd.git $ cd lnd $ make $ make install tags="autopilotrpc chainrpc experimental invoicesrpc routerrpc signrpc walletrpc watchtowerrpc wtclientrpc" $ sudo cp $GOPATH/bin/lnd /usr/local/bin/ $ sudo cp $GOPATH/bin/lncli /usr/local/bin/ $ lncli --version lncli version 0.11.0-beta commit=v0.11.0-beta-61-g6055b00dbbcedf45cd60f12e57dc5c1a7b97746f
12. Create lnd conf file
$ sudo su - bitcoin $ mkdir .lnd $ nano .lnd/lnd.conf
[Application Options] # enable spontaneous payments accept-keysend=1 # Public name of the node alias=YOUR_ALIAS # Public color in hexadecimal color=#000000 debuglevel=info maxpendingchannels=5 listen=localhost # gRPC socket rpclisten=0.0.0.0:10009 [Bitcoin] bitcoin.active=1 bitcoin.mainnet=1 bitcoin.node=neutrino [neutrino] neutrino.connect=bb2.breez.technology
13. LND service autostart
$ exit $ sudo nano /etc/systemd/system/lnd.service
[Unit] Description=LND Lightning Network Daemon After=network.target [Service] # Service execution ################### ExecStart=/usr/local/bin/lnd # Process management #################### Type=simple Restart=always RestartSec=30 TimeoutSec=240 LimitNOFILE=128000 # Directory creation and permissions #################################### # Run as bitcoin:bitcoin User=bitcoin Group=bitcoin # /run/lightningd RuntimeDirectory=lightningd RuntimeDirectoryMode=0710 # Hardening measures #################### # Provide a private /tmp and /var/tmp. PrivateTmp=true # Mount /usr, /boot/ and /etc read-only for the process. ProtectSystem=full # Disallow the process and all of its children to gain # new privileges through execve(). NoNewPrivileges=true # Use a new /dev namespace only populated with API pseudo devices # such as /dev/null, /dev/zero and /dev/random. PrivateDevices=true # Deny the creation of writable and executable memory mappings. MemoryDenyWriteExecute=true [Install] WantedBy=multi-user.target
$ sudo systemctl enable lnd $ sudo systemctl start lnd $ systemctl status lnd
$ sudo journalctl -f -u lnd
14. Now we start LND
$ sudo su - bitcoin $ lncli create
15. Add funds to the node
$ lncli newaddress p2wkh
$ lncli walletbalance { "total_balance": "500000", "confirmed_balance": "0", "unconfirmed_balance": "500000" }
$ lncli connect 031015a7839468a3c266d662d5bb21ea4cea24226936e2864a7ca4f2c3939836e0@212.129.58.219:9735
$ lncli openchannel 031015a7839468a3c266d662d5bb21ea4cea24226936e2864a7ca4f2c3939836e0 1000000 0
$ lncli walletbalance $ lncli channelbalance
$ lncli pendingchannels $ lncli listchannels
$ lncli payinvoice lnbc1p0kkhgwpp5sn9y6xe9hx7swrjj4057674vh73nwk6rxg8j8zedztkn3vdzgjafacqmud86h
$ lncli addinvoice --memo 'my first payment on LN' --amt 100
$ lncli getinfo
$ lncli
$ MACAROON_HEADER="Grpc-Metadata-macaroon: $(xxd -ps -u -c 1000 .lnd/data/chain/bitcoin/mainnet/admin.macaroon)" $ curl -X GET --cacert .lnd/tls.cert --header "$MACAROON_HEADER" https://localhost:8080/v1/getinfo |jq
Author
This tutorial has been written by Francisco Calderón
You can say thanks by tipping the professor.
Credits
This tutorial has been proofread by LoicPandul
Even if this content is in its original language, human review is necessary to ensure its accuracy.
LoicPandul800 sats400 satsEvery content on the platform is the result of a collaborative effort: each lesson, translation, and revision is made possible by the work of contributors. For this reason, we are always looking for proofreaders who can review our content in many languages. If you want to participate in the proofreading process, please reach out in our Telegram group and read our tutorial. We remind you that this content is open-source - licensed under CC BY-SA - so it can be freely shared and used, as long as the original source is credited.
