Sunday, January 27, 2019

⚡Lightning Network⚡

Simplifying as much as I can:

The lightning network ("LN") lets us use software to keep track of who owes whom, and how much, and in a way that allows the one owed to claim their money whenever they want.  Since it's safe, and it's fast, we can let the software update who owes whom in a way that implements a payment from any one of us to any one else.  This tracking of who owes whom how much is done without the blockchain and nearly immediately, which is what makes it so great.  The next few paragraphs will get into more complicated details, so consider skipping ahead if the mechanics of the LN don't interest you.


Details for nerds like me

These debts are represented by "channels." For example, I can open a "channel" to you and put as much money into it as I want.  I admit that opening a channel does use the blockchain.  The software will show that the channel owes ME all the money, but (without using the blockchain), the software can (very quickly) update the channel to show that some of the money in it belongs to you instead.  And if I had a channel open with someone else (E) into which they deposited some money, the software could updated that channel to show that the same amount of that money belongs to me, which makes it okay that some of the money in our channel now belongs to you.  Effectively, E would have paid you, by paying me.

That might seem trivial, but you could be Starbucks, and if my channel to you has enough money in it, E would be able to buy several coffees without filling up the blockchain, or having to wait ten minutes.  Furthermore, if you (Starbucks) pay your webmaster through lightning, and the webmaster has a channel open with me that I funded, you could pay him through me, and that would bring a lot of the money in our channel back to me.  It could cycle thousands of times without ever adding to the blockchain.

In the situations I've described, where I'm being a middleman, I will make (very tiny amounts of) bitcoin, a little for each payment that goes through me.  In fact I've earned about seven satoshi (a satoshi is 0.00000001 BTC) at this point, which covers a tiny fraction of the fees I paid to open my lightning channels.  The first five or ten channels I opened were set to charge fees that were kind of large.  The settings are in the eclair.conf file.  I adjusted the settings as shown at the bottom of this email in my eclair.conf file to lower my fees and attract what's called "relays," which is what it's called when you're the middleman.  "fee-base-msat" is the thousandths of a satoshi that you charge to relay a payment, and "fee-proportional-millionths" is the portion of the payment you're relaying that you charge to relay it.  Since they're millionths, 10000 (don't use commas in numbers in the conf file) would be 1%, which is VERY large.  Most people charge 0.0001% (1 millionth).  It may pay in these early days to charge high fees, but that's not a game I'm interested in exploring.

What if the other guy disappears?

If you have a channel open with someone and you want to take all your money out and he's not around, you can "force close" the channel.  This takes some time.  The time it takes is useful to prevent people from cheating.  If our channel NOW owes me less than it did before, I might try to force close it using an earlier balance.  If so, I'd have to wait, and while I'm waiting, your software would see that I'm trying to cheat and be able to take the full balance, thus punishing me for trying to cheat.

This is because there are two ways to empty the channel, and one of them has a waiting period for whoever is trying to close it unilaterally.  The other way is if we agree on the balance, and we both sign the closing transaction.  If I do try to close the channel unilaterally using an earlier balance, the resulting output allows your software to take all the money in the channel with no waiting period using an "anti-cheat" transaction.  With every balance update, one of these "anti-cheat" transactions is created for each of us, and our lightning software will watch for the unilateral close operation that allows it to take all the money.

How I set up my Lightning node:

I followed these instructions from Johnny Pham.  If you do that too, I invite you to open a channel to me (and let me know; I'll open one to you as well, for the same amount, up to $100).  You will need to know my "node URI" which is:

My custom setting from eclair.conf:
eclair.node-alias="Scotese Lightning node"

The last three settings here are in bold to indicate that I added them.  I added them so that my node is publicly available and I'm using non-default fees to attract business.

In my next newsletter, I'll be explaining what I know about BitcoinHEX, which looks like a really great idea to me.