Aleksa Jovanovic
Jan 11 · 5 min read

Getting Started

In part two of our lightning network series we will be detailing our experience with the lightning network and some of the pitfalls we’ve discovered along the way. In the third part of our series we will begin our tutorial on how to run your own local nodes, a Lightning node from the Android phone and making a payment channel between the mobile and local node.

Overview

We embarked on the task of establishing a bitcoin node and lightning node in the AWS cloud, a lightning node running from an android phone, and finally establishing a payment channel between the two lightning nodes. To start, we wanted to get everything working locally on the Bitcoin testnet before trying to have the nodes running from the cloud. For the Android portion, we used ACINQ's Scala implementation of the lightning network. We would like to give a big thanks to them for open sourcing their project and to the LND team for providing endless support on their slack channel!

Toolchain Used

  • Android Java with a Scala implementation of the Lightning Network
  • LND’s implementation of the Lightning Network
  • btcsuite’s implementation of the bitcoin protocol
  • Docker for containerizing our nodes
  • serveo for exposing my local lightning node to the world

We intended to use AWS for cloud capabilities, but we encountered more than a fair share of issues preventing us from reaching that point in development.


Getting it Running Locally

Local Nodes

Getting the Bitcoin and Lightning nodes up and running wasn’t too tricky and mostly involved getting all the right dependencies installed and downloading the Bitcoin blockchain. Since we were using the testnet, it only took about 4 hours to download. Aside from that, it was also important to make sure we had the correct flags and configurations for the nodes.

Android

Getting the Lightning Network running on the Android phone took significantly more effort. First off, we had to take a look at ACINQ’s eclair wallet to understand how to use their Scala implementation of the Lightning Network. At first glance it seemed quite complicated, but piece by piece we broke it down and isolated the components we needed for basic boiler plate code.

Additional Setup

The last step necessary to facilitate communication between my local nodes and the outside world was to expose them through an SSH server for port forwarding. We used serveo for this, but ngrok works just as well too.

Initial Challenges

Testing was the most tedious aspect about getting the nodes up and running and making a payment channel. Since we were using the testnet we still had to wait for 6 confirmations from miners and they could take up to 30 minutes to complete. Whenever we would create a funding transaction for off-chain transactions, or close and settle a payment channel, we were waiting upwards of half and hour.

😞

Another inconvenience we encountered was that we couldn’t fund the payment channel after it was opened. Essentially, the funds you opened the payment channel with are all the funds you have to spend before the state has to be broadcast on the main chain. Contrary to the payment channels we implemented on the Ethereum network, the payment channels on the Lightning Network do not have addresses, or at least exposed addresses that can have funds sent to them.

General unpredictability of the network was a salient theme throughout our research of the Lightning Network. A number of times we would try to open a payment channel with a random node we’ve connected to and we would be greeted with the following error:

The error is telling us that we don’t have enough satoshis in our wallet to fund the opening transaction.¹ We tried to fund the channel with 20000 satoshis, if the fee is 485281 satoshis, like it says in the error, then that’s a total 505281 satoshis. In our wallet we have 41173093, more than enough to fund the transaction.

Lastly, when you make off-chain transactions on the Lightning Network you still pay a fee if your transaction has to travel through more than one node! The creators of the Lightning Network estimate that the fee should be 1 satoshi per node or smaller. The fee is nominal, but nonetheless you still have to pay a fee to the nodes you pass through, unlike Ethereum payment channels where there is no fee at all.


  1. A satoshi is the lowest denomination of a Bitcoin. Its value is one hundred millionth of a Bitcoin. Simply put, 1BTC = 10⁸ satoshis.

Nodes in Clouds

Dockerizing Our Nodes

Docker is software that enables you to containerize your servers and create images from which many of your servers can be instantiated from. It’s often used in junction with AWS so that your servers are encapsulated and easy to spin up.

Sifting through LND’s github we found Docker images and start scripts already built by the LND team, so we decided to give them a try. We quickly ran into multiple errors while trying to build the images and we also noticed that the images were connected through Docker links.¹ Docker links are deprecated so our next move was to build our own images and connect them using a Docker network. Building the images was straightforward enough, now all we had to do was share the rpc certificate using a volume between the Bitcoin node and Lightning node… Or so we thought.

Despite sharing the rpc certificate between the nodes and verifying that they are present in both containers, the Lightning node was unable to make a connection with the Bitcoin node. We made sure to double check that all the right ports were exposed on both containers, however we still had no luck with it.


  1. Docker links are a way of linking containers through a secure channel to enable communication between them. When using a Docker network instead, Docker creates a virtual network where containers have their own subnet ip addresses.

In Conclusion

Our experience with the Lightning Network was interesting, fun and informative. We’ve learned a lot about the Lightning protocol and the potential that the technology holds. Unfortunately, the technology still seems too unstable and underdeveloped to be used in a scalable production level solution. We will definitely keep our eyes peeled to see where the tech goes.

Thanks for reading our blog, we hope you learned a little bit from our experience with the Lightning Network. Be sure to stay tuned for Part 3 where we show you how to spin up your own nodes, a node on the Android phone, and make a payment channel between them!

STK Token

A new cryptocurrency for instant payments at point of sale.

Thanks to Nat Chin

Aleksa Jovanovic

Written by

I’m a blockchain developer and I love building cool things and tinkering with new tech.

STK Token

STK Token

A new cryptocurrency for instant payments at point of sale.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade