Bitcoin Atom’s Lightning Network (LN) has been running for a while now, and currently has capacity to transfer up to 1,000 BCA in a single off-chain payment executed almost instantly.

As we are moving closer to adding LN support with instant swaps to the Tritium app, it is crucial to strengthen the BCA LN on the mainnet, making it less dependent on the nodes maintained by the core team.

In this publication, we will have a quick recap on what Lightning Network is, the current LN implementation in use on BCA Lightning, and a how-to, to quickly set up your own LN node and help the network grow.

Lightning: Quick Intro

Lightning Network (or LN for short) is a so called “Layer 2” payment protocol technology, originally proposed in 2016 by Joseph Poon and Thaddeus Dryja in a whitepaper “The Bitcoin Lightning Network: Scalable Off-Chain Instant Payments”.

“Layer 2” here means that that this technology does not operate within the blockchain itself (which is “Layer 1”), but rather creates a new layer of interaction between the network participants, payers and payees, wishing to exchange funds instantly with negligible transaction fees, regardless of the network load, while still keeping the system decentralized and censorship-resistant.

Back in 2016, LN had been proposed as a scaling solution to address the limited throughput and congestion issues of the world’s largest public blockchain, Bitcoin. As three independent LN implementations subsequently emerged, it has become clear that Lightning can not just enable public blockchains scalability, allow for instantaneous micropayments with almost zero fees, but also reclaim privacy on public chains. The latter is achieved due to the fact that lightning transactions are only visible by their respective peers, propagated throughout the network via onion routing and are never published on the underlying public blockchain.

Today, the world’s most established and trusted Bitcoin blockchain has three independent Lightning Network implementations developed by different teams:

lnd by Lightning Labs, written in Golang

by Lightning Labs, written in Golang c-lightning by Blockstream (Elements project), written in C

by Blockstream (Elements project), written in C eclair by ACINQ, written in Scala

It’s also worth noting that:

All three implementations conform to the Lightning Network Specifications (BOLTs) devised in late 2016 to create an industry standard for off-chain payments.

All three implementations have been successfully applied to Bitcoin forks, including Litecoin and enhanced forks such as Bitcoin Atom.

As of today, all three implementations are in Beta, meaning that Lightning technology continues to mature, reaching a more stable state.

lnd implementation seem to be the most popular now, judging by its GitHub activity (3.6k stars, ~1k forks).

implementation seem to be the most popular now, judging by its GitHub activity (3.6k stars, ~1k forks). Another implementation by Bitfury Group has just emerged, dubbed Lightning Peach or lpd (Lightning Peach Daemon) for short. Written in Rust, it is still a work-in-progress, and not ready for production.

At the time of writing, there are ~3,600 active nodes on the world’s largest Bitcoin Lightning Network, meaning nodes that have at least one active channel, with an overall network capacity of over 730 BTC or $2.8m at the time of writing. These figures continue to grow on a daily basis, clearly indicating increasing level of interest of users and developers in Lightning technology.

Grand Challenge

The Bitcoin Atom team believes that Lightning Network technology will not only transform the way crypto payments are used today, but also subvert the paradigm of both centralized and decentralized exchanges, dominating the crypto value exchange currently.

Recently, we have observed a large wave of new market players dubbed DEXes, entering the crypto exchange market taking the view that industry will shift to decentralized exchanges of value. Most ambitious of these projects are developing solutions to facilitate purely peer-to-peer trustless cross-chain swaps, meaning that one can exchange Bitcoin for Ether or ERC20 tokens directly, in a completely trustless manner, without the need for arbiters or trusted entities (which are a potential points of failure).

We at Bitcoin Atom believe that this is a very important goal to pursue, however a significant impediment in this model are the on-chain limitations, hindering DEX’s ability to catch up and outperform existing centralized exchanges in terms of user experience and customer expectations. Traders expect exchanges to execute orders instantly, settle positions in seconds, impose almost negligible fees and preserve customer privacy — we also see these as most important aspects to consider.

Having said that, it is clear that LN technology is not quite mature yet to go mainstream, though, it is apparent to us that the industry should start working to address these issues, mainly because crypto markets need such a solution to become more sustainable and garner wider global adoption.

In 2018 alone, more than $865m had been stolen from cryptocurrency exchanges — a terrifying amount for any industry, and the totals are growing with an all-time theft due to hacking approaching $1.5 billion. What scares us most, is that these stats only consider reported hacks from centralized exchanges, not taking into account a number of concealed hacks, inside job pilfering and financial fraud committed by insiders, and phishing attempts exploiting centralized exchange infrastructure.

Noting these statistics brings us to immediately think twice about trading crypto on centralized exchanges. Given the high rate of failure, even the most credible and trusted centralized exchanges have a substantial risk of being compromised, either from internal or external actors, leaving one without funds and in many cases even a clear explanation as to what transpired.

To addressing this issue, the Bitcoin Atom team has decided to design and integrate LN-based swaps into the Tritium app, to benefit users by eliminating confirmation times and blockchain fees. Our ultimate goal involves offering a completely trustless P2P exchange to customers, allowing for instant cross-chain swaps without exchange custody, but ultimately reaching user-friendliness of centralized exchanges and eventually surpassing it.

What’s the current BCA LN implementation?

Bitcoin Atom’s current LN implementation is Eclair Atom, a fork from ACINQ Eclair node, made by our community contributor.

Its source code is available for review on our GitHub:

https://github.com/bitcoin-atom/eclair-atom

Release builds are available here:

https://github.com/bitcoin-atom/eclair-atom/releases/latest

Some screens from the LN node GUI:

We are considering building another Atom Lightning node based on lnd, with discussions currently ongoing within the team.

How to setup your own BCA LN node?

As of today, the only working implementation on BCA is Eclair Atom.

It is quite user-friendly to setup and run, in just a few easy steps:

Step 1. Install Java 8:

http://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

Note: Skip this step if you have Java 8 installed.

Step 2. Download Eclair Atom, the BCA LN node:

https://github.com/bitcoin-atom/eclair-atom/releases/latest

Elair Atom supports all major OS — Windows, macOS & Linux, thanks to Java Runtime Environment running Java / Scala apps.

For additional security, please verify checksums and signatures of app downloads before launching.

Checksums of downloads are GPG signed by rootSig (Bitcoin Atom core developer):

RSA key 3A029F07490F995FC637839968085EC8EF77E9D7

Elair Atom comes in the form of a GUI app (eclair-node-gui-***.jar) and a headless daemon (eclair-node-***.jar).

Pick the one you are comfortable with, but please keep in mind that both require configuration before launching (see below).

Step 3. Grab and sync the BCA full node (Atom Core):

https://github.com/bitcoin-atom/bitcoin-atom/releases/latest

Note: Eclair Atom will use any BCA it finds in the Atom Core wallet to fund any channels you choose to open. Eclair Atom will return BCA from closed channels to this wallet.

Note: For now, you cannot use a local dedicated-for-Lightning BCA wallet while connecting to a remote BCA full node. It’s possible to use Eclair Atom with just a remote node, however this entails serious security implications, namely MitM attack scenarios, thus we strongly discourage doing this on the mainnet. This issue is going to be addressed in future releases.

Note: To run Eclair Atom, you should have a fully-synced, segwit-ready, zeromq-enabled, wallet-enabled, non-pruning, tx-indexing Atom Core node.

BCA full node has tx-indexing enabled by default however this requires at least 220 GB of free disk space.

It’s recommended to run the BCA full node on a VPS or a dedicated server, though it’s also possible to run it locally.

We recommend using the following full node configuration (atom.conf):

rpcuser=USERNAME rpcpassword=PASSWORD server=1 daemon=1 listen=1 zmqpubrawblock=tcp://127.0.0.1:29001 zmqpubrawtx=tcp://127.0.0.1:29001 addresstype=bech32

Place this configuration into a text file named ‘atom.conf’ and save it in the Bitcoin Atom datadir:

C:\Users\YOUR_NAME\AppData\Roaming\BitcoinAtom on Windows

~/Library/Application Support/BitcoinAtom/ on macOS

~/.bitcoinatom/ on Linux

Note: As already mentioned, it is not required to specify tx-index option in the config, as it is always on by default in the BCA full node, as required by the Atom’s PoS staking mechanism.

Once you have this config in your Bitcoin Atom datadir, launch the full node and wait for it to fully sync. You can check the progress via the atom-cli tool or in the QT GUI.

Feel free to use any of the BCA Block Explorers to check for the last block number:

https://bitcoinatom.net

https://mainnet.bitcoinatom.io

https://testnet.bitcoinatom.net

https://testnet.bitcoinatom.io

Note: If you already have a fully synced BCA full node, there is no need to do anything except changing the config file and restarting the node. For example, reindex of the chain is not required, as tx-index is always on by default in the Atom Core.

Step 4. Configure Eclair Atom as outlined here:

https://github.com/bitcoin-atom/eclair-atom

By default, datadir is ~/.eclair (On Windows, that means C:\Users\YOUR_NAME\.eclair).

We recommend to use the following Eclair Atom configuration (eclair.conf):

eclair.chain=mainnet eclair.node-alias=MyLightningNode eclair.node-color=00ff00 eclair.bitcoind.rpcport=7332 eclair.bitcoind.rpcuser=USERNAME eclair.bitcoind.rpcpassword=PASSWORD eclair.api.enabled=true eclair.api.password=API_PASSWORD eclair.server.public-ips=[“PUBLIC_IP_ADDRESS”]

Place this configuration into a text file named ‘eclair.conf’ and save it in the Eclair Atom datadir (path stated above).

Next, make sure that you have a TCP port 9835 opened. This is a lightning protocol port, over which the lightning nodes normally communicate on the BCA LN.

In case you want to use a remote node (not recommended), you have to add a new line into the config file:

eclair.bitcoind.host=NODE_IP eclair.bitcoind.zmqblock=”tcp://NODE_IP:29001" eclair.bitcoind.zmqtx=”tcp://NODE_IP:29001"

Correct the configuration of the full node, as you want to allow incoming connections from your local Eclair Atom node and start listening for ZeroMQ connections on all local addresses:

rpcallowip=ECLAIR_IP zmqpubrawblock=tcp://0.0.0.0:29001 zmqpubrawtx=tcp://0.0.0.0:29001

Restart your full node after changing the ‘atom.conf’ config file.

Step 5. Launch and test Eclair Atom

Verify that your Atom Core full node is caught up with the latest block and launch your Eclair Atom node, which was configured in the previous step.

As already noted, you can select either a GUI version (eclair-node-gui-***.jar) or a headless daemon (eclair-node-***.jar), depending on whether you have a desktop environment installed on your system.

Launch your version of choice by either double-clicking (in Windows) or executing the following command:

java -jar eclair-node-***.jar

In case you are using a headless daemon, you would need a command-line client to interact with your Lightning node. Grab it from here:

https://github.com/bitcoin-atom/eclair-atom/blob/master/eclair-core/eclair-cli

This is simply a bash script, so it can be launched straight away. Just ensure that you have a jq package installed, otherwise install it:

https://stedolan.github.io/jq/

Once you have a GUI or a headless Eclair Atom node up & running, you can interact with its API via eclair-cli.

To begin with, edit the eclair-cli, which is essentially a text file (bash script). Edit the following parameter values:

URL=’http://localhost:8180' PASSWORD=’API_PASSWORD’

Please note that HTTP API port should be set to 8180, and an API_PASSWORD from the previous step has to be provided here as well.

Save the eclair-cli file. Now you can issue commands to your Eclair Atom node as follows:

./eclair-cli help

./eclair-cli peers

./eclair-cli channels

By now, you should see the empty responses from your running Lightning node.

The full list of API methods and their arguments can be found here:

https://github.com/bitcoin-atom/eclair-atom/blob/master/README.md#json-rpc-api

A test scenario:

1. Connect to one of the public nodes, e.g.

./eclair-cli connect 03c456e1d1461f1d8f825e196b84221f6981f3dd5171af11215083cbea0b126774@94.130.57.86:9835

2. Now it should be listed when you execute

./eclair-cli peers

3. Open a channel with the public node by committing a small amount of BCA to the Lightning Network:

./eclair-cli open 03c456e1d1461f1d8f825e196b84221f6981f3dd5171af11215083cbea0b126774 15000000

Please note that the amounts are set in satoshis, not BCA.

For instance, in this sample we have provided a value of 0.15 BCA or 15000000 satoshis.

We recommend to use an online converter:

http://satoshitobitcoin.co

It converts satoshis to bitcoins and vice versa.

Note: Your on-chain wallet (the full node) should contain enough funds in BCA, so that you can open channels on the Lightning Network. Please replenish your Atom Core node with BCA if it lacks funds you want to commit to the Lightning Network.

Note: Your full node should be either not encrypted or unlocked while the Eclair Atom node is running, otherwise it won’t be able to access on-chain funds to open lightning channels. While this poses security implications (major amounts of BCA in unlocked hot wallets), the LN community is working on solving this issue.

Note: Opening a channel requires a few confirmations (usually 3) before it’s treated as a “normal” one, meaning that you can use it to send and receive funds over the Lightning Network.

Now list your channels by issuing

./eclair-cli channels

You should see your newly created channel with the WAIT_FOR_FUNDING_CONFIRMED status.

After 3 transaction confirmations, you should see that your channel has changed its state to NORMAL, meaning you can send and receive lightning funds over it, e.g.

{ “nodeId”: “0227a29bc79b47aeb92bbf17e42b213c0ab60b7d5586ba7b0f0313d32c73713a84”, “shortChannelId”: “9ce8c0000040001”, “channelId”: “7dbb2e95b2a94c4d254653d51c9b1e244d935042d310a0fb9441ab9002e95186”, “state”: “NORMAL”, “balanceSat”: 0, “capacitySat”: 500000000, “channelPoint”: “8751e90290ab4194fba010d34250934d241e9b1cd55346254d4ca9b2952ebb7d:1” }

Tip: You can also use the following custom command to list only NORMAL channels, ignoring channels not suitable for sending and receiving funds:

./eclair-cli channels | jq ‘.[] | select(.state == “NORMAL”)’

In the current example, this command should display the same channel you just opened.

Tip: You can always check your Lightning Network balance across all channels by issuing the following command:

./eclair-cli channels | jq ‘.[] | .channelId’ | xargs -L 1 ./eclair-cli channel | jq -s ‘map(.balanceSat) | add’

All values provided and returned in satoshis — use a converter for your convenience.

4. Now generate a lightning payment request to receive an arbitrary amount of BCA:

./eclair-cli receive “test”

You should see a long string of characters, representing you lightning payment request, e.g.

lnbca1pw8nx83pp5tm8msdf0h3039unl378mk55p6r8g0ln5qaleh97grpjrhn258haqdqsu2qfcar9wd6w9qyaxqrrsspxxf2ccglxus5fh4fm3hc0k47wzhmss9g3lnjeeqmc6d6s57k3jkd5alxktqw02ar2mwu2hv0asyjn6lrv93u2vuuvy23hzmjjkfjygqnpzyx3

Copy it to the clipboard.

5. Try paying yourself by sending 0.1 BCA to yourself over Lightning:

./eclair-cli send lnbca1pw8nx83pp5tm8msdf0h3039unl378mk55p6r8g0ln5qaleh97grpjrhn258haqdqsu2qfcar9wd6w9qyaxqrrsspxxf2ccglxus5fh4fm3hc0k47wzhmss9g3lnjeeqmc6d6s57k3jkd5alxktqw02ar2mwu2hv0asyjn6lrv93u2vuuvy23hzmjjkfjygqnpzyx3 10000000

You should see the following output:

{ “paymentHash”: “5ecfb8352fbc5f12f27f8f8fbb5281d0ce87fe74077f9b97c818643bcd543dfa”, “failures”: [ { “t”: “cannot route to self” } ] }

If you get this, everything works as expected — you have just tested your BCA Lightning Node.

In case you are using a GUI client, everything should go much smoother — as there’s no need for the command-line client, just look through it and try to repeat the steps we just conducted via the console client.

List of mainnet LN nodes maintained by the team (as of 03–01–2019):

0227a29bc79b47aeb92bbf17e42b213c0ab60b7d5586ba7b0f0313d32c73713a84@78.47.153.240:9835 “mesa”

03c456e1d1461f1d8f825e196b84221f6981f3dd5171af11215083cbea0b126774@94.130.57.86:9835 “starburst”

03b2ad627f55b855a953c70f6019252179ca70694da23ca55d3c7a4e806d6cb073@94.130.56.119:9835 “nova”

020b8ef46da72936db661d7bf00a8c1c4f563bd6c91a3109bf94f00221bdeea0b3@94.130.173.189:9835 “onyx”

Top active channels by capacity:

1. 1000 BCA: “mesa” <-> “starburst” (channelId ec86dbd8153d906b07448c5490e7985e82e8237403d5125899be46912ce79404)

2. 1000 BCA: “starburst” <-> “nova” (channelId e4400fd16d28621c45098e4952e656a0213447c60c9031dd78a58407d0f394c7)

3. 500 BCA: “mesa” <-> “nova” (channelId 23bf67f59bd72e15623b7a64c435c1205067a2957077dcf1607c366980b67d8c)

4. 500 BCA: “nova” <-> “onyx” (channelId f49a7623810708aa989e0607d272667b648879d8aa4c4f89de66d2248f06e008)

I’ve got a few good ideas about this / I want to contribute! What should I do?

We welcome all community contributors — just drop us a message on Telegram: https://t.me/bitcoinatom or you can send us an email: hello@bitcoinatom.io.

About Bitcoin Atom

Bitcoin Atom (BCA) is a SegWit enabled Bitcoin fork with on-chain atomic swaps on board and hybrid consensus. Bitcoin Atom enables truly decentralized digital asset exchange by utilizing hash time-locked contracts (HTLCs) and its own HTLC API, giving independence from intermediaries and any centralized entities.

Bitcoin Atom’s development team is working on a special embedded toolkit for both on-chain and off-chain atomic swaps, allowing for exchanging any cryptocurrencies in a hassle-free way across different blockchains.

Our aim involves introducing support for both on-chain and off-chain decentralized trades in a single trading app, available on all major platforms.

For additional information, please visit Bitcoin Atom’s website at https://bitcoinatom.io

Inquiries: hello@bitcoinatom.io