June 20, 2019

Getting LND running on an old Android Phone

UPDATE: 07/09/2019: Upon trying to go through this process on another Android phone, I found I wasn’t able to get passed the go installation process, after much troubleshooting, I haven’t been able to figure it out. For now, I’m declaring this project a bit of a failure, but will continue to attempt to figure out the issue or otherwise find another way around.

In 2018, the Lightning Network hit mainnet. I spent the majority of the year wanting to get involved but wasn’t sure how to do it. I was able to buy a Casa node but I had to wait three months for it to ship. I wanted to get started right away so I decided that I would try to figure out how to setup a BTCPay server. Shortly thereafter I had a LN node running and I was able to do some transactions. Later on, I received my Casa node and realized how closed the interface was. This fueled my desire to have more direct control over my LND node.

To better understand what was going on under the hood” I had to learn the scary command line side of things. This started by SSHing into my BTCPay server. Later on, I was able to use Pierre’s Node Launcher to have LND running in Windows. This allowed me to learn some of the basics of the config side of things.

Sometime in 2019 I was on Twitter reading about Lawrence Nahum’s ABCore. ABCore is an Android app that allowed someone to run a Bitcoin full node on their phone. My first thought was: Could I run LND on an Android phone? Having used something called Termux before, I knew you could have a Linux running on top of Android. It seemed like running on LND in Termux was at least possible.

After some encouragement from Larry himself, I decided to see if I could get LND running on an old Samsung Note 5. This article is the manifestation of that encouragement and the desire to write out this idea so others can get inspired.

Installing Bitcoin

The first step is to get ABCore installed on your Android device:

Install ABCore

Once installed it will present you with an option to download the latest version of Bitcoind.

Please proceed to Settings-> Daemon Configuration-> Manually edit bitcoin.conf to edit your bitcoin.conf file.

Edit bitcoin.conf to include:

disablewallet=1
prune=10000
rpcuser=[choose_username] 
rpcpassword=[choose_password] 
server=1
deamon=1

Go back to the opening screen of ABCore to begin syncing the blockchain to your phone. This process took me several days on my Note 5 and might take longer on older devices. In the meantime, let’s go ahead and get LND setup.

Installing LND

To get started in that process you’ll need to install Termux.

Termux has limits, so we’ll need a version of Linux running in Termux that would allow more flexibility.

In my case, I found a script that allows you to use a version of Ubuntu along with proot to get LND installed within Termux.

The script is found here. Security tip: Double check that everything in the script is doing what you expect it to do or else you’re trusting some random code on the internet. Don’t trust, verify.

Run the following commands to get a Ubuntu shell running:

apt-get update && apt-get upgrade -y
apt-get install wget -y
apt-get install proot -y
apt-get install git -y
apt-get install coreutils -y
cd ~
git clone https://github.com/MFDGaming/ubuntu-in-termux.git
cd ubuntu-in-termux
chmod +x ubuntu.sh
./ubuntu.sh
cp ~/ubuntu-in-termux/resolv.conf ~/ubuntu-in-termux/ubuntu-fs/etc/

Ubuntu is now installed on Termux, all you have to do now is to start Ubuntu:

./start.sh

Make sure to update your repos/packages:

apt-get update && apt-get upgrade -y
apt-get install wget -y
apt-get install nano -y

Next up is getting GO installed and ready for our LND installation:

wget https://dl.google.com/go/go1.12.3.linux-amd64.tar.gz
sha256sum go1.12.3.linux-amd64.tar.gz | awk -F " " '{ print $1 }'

The final output of the command above should be 3924819eed16e55114f02d25d03e77c916ec40b7fd15c8acb5838b63135b03df. If it’s not, the file has been modified.

tar -C /usr/local -xzf go1.12.3.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
export GOPATH=~/gocode
export PATH=$PATH:$GOPATH/bin

Now that GO is installed, we are ready to install LND:

go get -d github.com/lightningnetwork/lnd
cd $GOPATH/src/github.com/lightningnetwork/lnd
make && make install

In my case, it took quite a while for LND to build, so go do something else for a bit and come back later. We’ll now need to create and set the configuration options using your lnd.conf.

Please navigate to the LND directory and create a text file using nano:

cd ~/.lnd/
nano lnd.conf

Input the following into the lnd.conf file:

[Applications Options]
externalip=[Input your external IP]:9735
alias=[Name of your Node]
color=[Choose a color for your node]
listen=0.0.0.0:9735

[Bitcoin]
bitcoin.active=1
bitcoin.mainnet=1
bitcoin.node=bitcoind

[Bitcoind]
bitcoind.rpcuser=[use the username that you input above for bitcoin.conf]
bitcoind.rpcpass=[use the pass that you input above for bitcoin.conf]
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333

One of the final steps is to configure your hosts file because it doesn’t map localhost by default:

cd /etc/
nano hosts

Add the following line to your hosts file:

127.0.0.1 localhost

Finishing Up

After these steps, all you have to do is wait for your Bitcoin node to finish syncing. Once that is complete, you’ll type LND into your ubuntu command line. You’ll select a password and write down your seed for your LND node.

You’ll then need to open up another session, swipe from the left of your screen to do so. You’ll need to run your Ubuntu shell again:

cd /ubuntu-in-termux/
./start.sh

Then you’ll need to unlock LND:

lncli unlock

You’ll be asked to enter your password and you should now be able to start using your LND node on your Android phone!

Some limitations:

  • It has been more challenging to figure out how to use an external GUI interface with this implementation. This is a work in progress and it is my hope that I can figure this out because right now, using command line only on Android is a huge pain.
  • On my old Samsung Note 5, I’ve noticed that after a few days of not touching the phone, I’d return to see that both Bitcoind and LND not running any longer. This is likely due to Samsung phones being aggressive with putting these apps to sleep. Future testing might include using a stripped down non-Samsung ROM.

Thank you to https://twitter.com/p_miller_ and https://twitter.com/mrcoolbp for their help in making this post even better.

Let me know if you found this guide useful and if you think there’s anything I can improve!


bitcoin crypto writing Lightning Network LND android phone


Previous post
Adventures in the Lightning Network One of my favorite Andreas Antonopoulos videos is where he introduces the Lightning Network and the concept of ‘streaming money’ in his highly