Skip to main content

A Lightning Node Is A Constantly-Running Application

In the prerequisites, I suggested that you should have some experience running a web service before running a Lightning Node.

One reason for this is, just like web server, a Lightning Node needs to respond quickly to all requests.

But there is another, slightly nastier issue, too: If your node is off or disconnected from the internet, you can't receive any payments! Yikes!

Why is that?

It's because Lightning is am "active receive" system.

Passive receive vs active receive

Passive ReceiveActive Receive
BitcoinBitcoin Lightning
Postal LettersTelephone Call
Newspaper DeliveryVideoconference

Passive Receive: Postal Letters

You send a letter, and a postal carrier will put that letter physically into the recipients's mailbox, or apartment, or house. The recipient might be away from her house. But she'll pick it up when she gets back. She receives it "passively".

Passive Receive: Bitcoin

Bitcoin "on-chain" (not Lightning) payments are passive, because you can do this:

  1. Receiver plugs in her hardware wallet, and generates a BTC address, like bc1p933lgtfcmz5sdyy6pq9kmcs2jpm3hrcuejc3zg2jrd07e7w2xswsn8j3kf
  2. Receiver unplugs her BTC wallet, and puts it in a safe location.
  3. Receiver gives Sender the BTC address
  4. Sender makes payment to BTC address
  5. Receiver waits 5 years.
  6. Receiver takes BTC wallet out of safe location and plugs it in.
  7. Receiver checks balance and confirms receipt of 5-year-old payment.

So Bitcoin payments are received in a "passive" manner. You can send the payment to an address and the recipient, who has the keys to that address, doesn't need to do anything involving electricity or the Internet to receive the payment.

Active Receive: Telephone & Videoconference

Active receive is trickier.

To receive a Telephone Call, you need to pick up the phone when it rings. If you don't answer the phone, the communication fails.

To engage in a Videoconference, you need to turn on your camera. If you don't turn on the camera, the communication fails.

And to receive a payment via Bitcoin Lightning, your node must be online and running.

That's because, as you might remember, Lightning payments are not immediately written to the blockchain. They're just a (highly secure) "shared balance" that is written to the disk of each node. Your node has to be online to receive a payment because only your node, and the sending node, are recording the payment balances.

Also, there is a lot of shared "state"

This is another important difference between a Lightning Node and a web server.

Here is a (simplified) diagram, showing how a web server responds to a request for a web page:

I did tell you it was simplified. Basically, the client (often, your web browser), requests a web page, and the server sends the web page back to you.

Nice and simple.

Now let's compare that to the chatter between two Lightning nodes when a channel is opened:

More complicated, right? And that's just to open the channel! When payments start moving between channels, the chatter gets even more involved.

You don't need to memorize this, and you don't need to know all the details. You DO need to understand that there is significant back-and-forth communication between nodes, and for that reason, YOUR NODE NEEDS TO BE ONLINE 24/7.

If your node goes offline, you'll miss communication, and things can go bad.

But also, you need to run a Bitcoin Core node

If you've done a bit of learning about Bitcoin, you'll know about Bitcoin Core nodes.

These have been running constantly since 2009, and they store the Bitcoin blockchain data in a distributed and extremely secure way. Tens of thousands of people, all over the world, are running Bitcoin Core nodes, and helping to secure this network against censorship.

So, we'll remember that your Lightning Node uses the Bitcoin blockchain for security.

When opening and closing channels, your Lightning Node needs to make transactions on the Bitcoin ledger. It also needs to closely "watch" the Bitcoin ledger, because this is how it will find out if one of your channel partners has closed a shared channel.

How would you guess this happens?

If you've got experience with web or app development, maybe you're thinking: "OK, my Lightning node will make requests to some Bitcoin API."

But remember: Bitcoin is security software. It's designed to work while it is under attack, while big, powerful companies and governments are trying to censor it, and more.

For this reason, you're not going to use an API.

Instead, you are going to personally run the world's most powerful security software ALONGSIDE your Lightning Node. You will have Bitcoin Core running on the same computer as your Lightning node.

And, of course, this is yet another reason why your computer needs to be online 24/7: Just like your Lightning node, Bitcoin Core needs to be always online so it can learn about new confirmed Bitcoin blocks as they appear.

Ok, we're getting close now to being able to start setting up your node, but first let's take a detour to discuss some important security issues.