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.