Litecoin Lightning with Raspberry Pi 3

Jason Wong
4 min readApr 22, 2018

--

After previous article about setting up Litecoin Lightning with Ubuntu, it is time to try it on Pi 3. This tutorial assumes that readers are using Rasbian and familiar with Pi 3. It is better to have an external HD for storing Litecoin blockchain data and LND data.

To use Litecoin Lightning with Pi 3, we need:

  1. Compile Litecoin Core with Berkeley-db and ZeroMQ
  2. Setup LND

If you have never use Lightning before, you are recommended to read previous article which helps you to understand the big picture.

Compie Litecoin Core

Edit: litecoin Core team provides binary for ARM, which can run on Raspberry Pi 3. The binary can be download at https://download.litecoin.org/litecoin-0.16.3/linux/. You can download the binary litecoin-0.16.3-arm-linux-gnueabihf.tar.gz if compiling litecoincore is too difficult.

S̶i̶n̶c̶e̶ ̶L̶i̶t̶e̶c̶o̶i̶n̶ ̶C̶o̶r̶e̶ ̶t̶e̶a̶m̶ ̶d̶o̶e̶s̶ ̶n̶o̶t̶ ̶r̶e̶l̶e̶a̶s̶e̶ ̶a̶n̶y̶ ̶o̶f̶f̶i̶c̶i̶a̶l̶ ̶L̶i̶t̶e̶c̶o̶i̶n̶ ̶C̶o̶r̶e̶ ̶b̶i̶n̶a̶r̶y̶ ̶f̶o̶r̶ ̶R̶a̶s̶p̶b̶e̶r̶r̶y̶ ̶P̶i̶,̶ ̶w̶e̶ ̶h̶a̶v̶e̶ ̶t̶o̶ ̶c̶o̶m̶p̶i̶l̶e̶ ̶i̶t̶ ̶b̶y̶ ̶o̶u̶r̶s̶e̶l̶v̶e̶s̶. To make litecoind works with LND, we need litecoind compiled with ZeroMQ and Berkeley-db.

  • Installing ZeroMQ is simple as it is already in Rasbian’s package system, all you need is one command to install it:
sudo apt-get install -y libzmq3-dev
  • Install Berkeley-db is not as simple as ZeroMQ, you have to compile it yourself.

Before compiling Berkeley-db, we must first install some packages that we need later:

sudo apt-get install protobuf-compiler libminiupnpc-dev libevent-dev libtool libssl-dev libboost-all-dev qt4-dev-tools libprotobuf-dev libqrencode-dev autoconf libdb++-dev

Then we download and decompress the source tarball:

wget http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gztar zxf db-4.8.30.NC.tar.gzcd db-4.8.30.NC/build_unix/

Lastly, we configure, compile and install Berkeley-db:

../dist/configure --enable-cxxmake -j 4sudo make install

Now it is time for Litecoin core. We will use version “v0.15.0.1rc1”:

wget https://github.com/litecoin-project/litecoin/archive/v0.15.0.1rc1.tar.gztar zxf v0.15.0.1rc1.tar.gzcd litecoin-0.15.0.1rc1/

After downloading and decompressing the Litecoin core source, we’ll configure and compile:

./autogen.sh./configure CPPFLAGS="-I/usr/local/BerkeleyDB.4.8/include -O2" LDFLAGS="-L/usr/local/BerkeleyDB.4.8/lib" CXXFLAGS="--param ggc-min-expand=1 --param ggc-min-heapsize=32768" --enable-cxx --with-gui --disable-shared --with-pic --enable-upnp-defaultsudo make install

WARNING: It takes very long time(several hours) for the compilation.

While Raspberry Pi is busy compiling Litecoin Core, we can prepare the litecoin blockchain. Of course you can download the blockchain by synchronizing with Litecoin network after compilation, but it may take very long time like a few days. I suggest that copy an existing blockchain data from another computer will be faster. If you already have the blockchain data in another computer, you can just copy the litecoin directory to an external HD. The location of litecoin folder is “~/.litecoin” for Linux. Remember to delete “wallet.dat” in litecoin folde of the external HD because the litecoin core for LND does not need to use your wallet.

Use the same litecon.conf from previous article and put it under the litecoin data directory that you copied from another computer, in my Pi the path is “/media/pi/Backup/litecoin/”:

txindex=1
server=1
daemon=1
debug=1
discardfee=0.00000001
mintxfee=0.00000001
minrelaytxfee=0.00000001
rpcuser=jason
rpcpassword=litecoin
zmqpubrawblock=tcp://127.0.0.1:28332
zmqpubrawtx=tcp://127.0.0.1:28333

After compilation successfully finished, we can start Litecoin Core with command:

litecoin-qt -conf=/media/pi/Backup/litecoin/litecoin.conf -datadir=/media/pi/Backup/litecoin/
Litecoin Core starting
Litecoin Core finished syncing

To start litecoin as daemon, use the following command:

litecoind -conf=/media/pi/Backup/litecoin/litecoin.conf -datadir=/media/pi/Backup/litecoin/

Congratulations! You just compiled Litecoin Core and successfully running a litecoin full node on Raspberry Pi 3 !!

Setup LND

It is time for LND.

Because LND binary for Raspberry Pi is provided by LND team, we don’t need to compile it.

wget https://github.com/lightningnetwork/lnd/releases/download/v0.5.1-beta/lnd-linux-armv7-v0.5.1-beta.tar.gztar zxf lnd-linux-armv7-v0.5.1-beta.tar.gzcd lnd-linux-armv7-v0.5.1-beta/

We will put lnd data directory on the external HD, so we create a folder:

mkdir /media/pi/Backup/lnd

and start lnd:

./lnd --lnddir=/media/pi/Backup/lnd/ --litecoin.active --litecoin.mainnet --debuglevel=debug --litecoin.node=litecoind --litecoind.rpcuser=jason --litecoind.rpcpass=litecoin --litecoind.zmqpubrawblock=tcp://127.0.0.1:28332 --litecoind.zmqpubrawtx=tcp://127.0.0.1:28333 --alias=Jason_Pi3

As usual, lnd will ask you to unlock or create wallet, you open another terminal and enter the following command for the first time you start lnd because you don’t have a wallet yet:

./lncli --lnddir=/media/pi/Backup/lnd/ --network mainnet --chain litecoin create

When you already have a wallet, you just need to unlock it:

./lncli --lnddir=/media/pi/Backup/lnd/ --network mainnet --chain litecoin unlock

After creating the wallet, you should see lnd start syncing:

lnd start syncing

When lnd finished syncing, get an address from lnd and send some coins so we can open a channel with other nodes:

./lncli --lnddir=/media/pi/Backup/lnd/ --network mainnet --chain litecoin newaddress p2wkh

lnd generates bech32 addresses and Electrum-LTC is one of the wallets that support bech32.

When waiting for the fund to be confirmed, we can establish connections with other lnd nodes, you can find other nodes from network explorer:

./lncli --lnddir=/media/pi/Backup/lnd/ --network mainnet --chain litecoin connect 03565878dfb4b7b7ee1cf5bd810d8f1d7bc0b85a1f483add581de1d6ec6a118530@52.18.61.50:9735

And let’s open a channel with it:

./lncli --lnddir=/media/pi/Backup/lnd/ --network mainnet --chain litecoin openchannel 03565878dfb4b7b7ee1cf5bd810d8f1d7bc0b85a1f483add581de1d6ec6a118530 200000 0

After the channel is opened, you can find it on the network explorer:

Channel opened

Now you can send and receive payments through the channel. You can read previous article about how to generate invoice and send payments.

In summary, the most difficult part of running lightning node on Raspberry Pi 3 is to compile the Litecoin Core binary and it takes a lot of time. Setting up lnd is easier as we can use official binary.

--

--