Now you may think that this sounds scary. What if we couldn’t route through honest Bob but had to use malicious Mallory instead? Could Mallory steal our money? In short: no.

Warning: The next paragraph is a bit technical, so don’t panic if it doesn’t make sense at first.

All payments on the Lightning Network requires the recipient (Alice) to generate a random secret. All transactions on the Lightning Network are set up in such a way that if the secret is revealed, money is being transferred. In our example, Carol wants to route 1000 satoshis through Bob to Alice. Alice generates a secret. Carol tells Bob that if he can tell her that secret, she will pay him 1001 satoshis. Bob then goes to Alice, buying the secret from her for 1000 satoshis. He reveals the secret to Carol, gaining him 1001 satoshis. He has successfully been a middleman between Alice and Carol, and also made a profit of 1 satoshi.

Keep in mind that everything that’s described in the above paragraph is done automatically by Lightning nodes creating, executing and verifying smart contracts. This ensure that all actors along the way must act according to the established rules. If anyone tries to steal money along the way, the smart contracts have built in punishment mechanics, as mentioned in our blog post on Lightning Channels.

For routing to work properly on the Lightning Network, it’s necessary that we find channels with enough liquidity. What’s meant by this? Going back to our example: If Carol wants to pay Alice through Bob, it’s obviously a requirement that Carol has enough money in her wallet. Something that’s less obvious is that Bob also has to have a certain amount of money, in this case in his channel with Alice. To be specific: Bob has to have some money on his side of the channel with Alice. If he didn’t, he wouldn’t be able to forward the payment to Alice. All transactions on the Lightning Network need paths of channels with enough money in them to complete the payment.

As compensation for providing liquidity, nodes can require a fee for routing payments. These fees are typically very small, on the order of single digit satoshis. Recall that 1 bitcoin is divided into 100 million satoshis. So if a node requires a 5 satoshi routing fee, that’s less than 0.02 cents. However, if a node is well connected and routes a lot of payments, the node operator can potentially earn some money on hosting a node. This is something we will cover in more detail in a later blog post, as it is a very interesting topic.

Routing is really one of the core features of the Lightning Network. The concept of payment channels had been around for a long while, but being able to route through multiple parties in a decentralized and safe manner is a breakthrough compared to previous technological iterations.

If you’re interested in chatting more about Lightning Network technology or crypto tech in general, you can find us on Twitter @Suredbits or join our Suredbits Slack community.

In December of last year Suredbits released the first ever cryptocurrency market data API where you could stream data and pay for it on the Lightning Network. Here’s some additional reading on that topic you may find interesting: