A Lightning penalty transaction
It was a cold day and I remembered that this
lightningd node I was running on my local desktop to work on poncho actually had mainnet channels in it. Two channels, both private, bought on https://lnbig.com/ a while ago when I was trying to conduct an anonymous griefing attack on big nodes of the network just to prove it was possible (the attempts proved unsuccessful after some hours and I gave up).
It is always painful to close channels because paying fees hurts me psychologically, and then it hurts even more to be left with a new small UTXO that will had to be spent to somewhere but that can barely pay for itself, but it also didn’t make sense to just leave the channels there and risk forgetting them and losing them forever, so I had to do something.
One of the channels had 0 satoshis on my side, so that was easy. Mutually closed and I don’t have to think anymore about it.
The other one had 10145 satoshis on my side – out of a total of 100000 satoshis. Why can’t I take my part all over over Lightning and leave the full channel UTXO to LNBIG? I wish I could do that, I don’t want a small UTXO. I was not sure about it, but if the penalty reserve was 1% maybe I could take out abou 9000 satoshis and then close it with 1000 on my side? But then what would I do with this 1000 sat UTXO that would remain? Can’t I donate it to miners or something?
I was in the middle of this thoughts stream when it came to me the idea of causing a penalty transaction to give those abundant 1000 sat to Mr. LNBIG as a donation for his excellent services to the network and the cause of Bitcoin, and for having supported the development of https://sbw.app/ and the hosted channels protocol.
lightningd doesn’t have a command
trytostealusingoldstate, so what I did was:
First I stopped
lightningd then copied the database to elsewhere:
cp ~/.lightningd/bitcoin/lightningd.sqlite3 ~/.lightning/bitcoin/lightningd.sqlite3.bak
then I restarted
lightningd and fighted against the way-too-aggressive MPP splitting algorithm the
pay command uses to pay invoices, but finally managed to pull about 9000 satoshis to my Z Bot that lives on the terrible (but still infinitely better than Twitter DMs) “webk” flavor of the Telegram web application and which is linked to my against-bitcoin-ethos-country-censoring ZEBEDEE Wallet. The operation wasn’t smooth but it didn’t take more than 10 invoices and
With the money out and safe elsewhere, I stopped the node again, moved the database back with a reckless
mv ~/.lightning/bitcoin/lightningd.sqlite3.bak ~/.lightningd/bitcoin/lightningd.sqlite3
and restarted it, but to prevent my
lightningd from being super naïve and telling LNBIG that it had an old state (I don’t know if this would happen) which would cause LNBIG to close the channel in a boring way, I used the
--offline flag which apparently causes the node to not do any external connections.
Finally I checked my balance using
lightning-cli listfunds and there it was, again, the 10145 satoshis I had at the start! A fantastic money creation trick, comparable to the ones central banks execute daily.
I was ready to close the channel now, but the
lightning-cli close command had an option for specifying how many seconds I would wait for a mutual close before proceeding to a unilateral close. There is no
forceclose command like Éclair hasor anything like that. I was afraid that even if I gave LNBIG one second it would try to do boring things, so I paused to consider how could I just broadcast the commitment transaction manually, looked inside the SQLite database and the
channels table with its millions of columns with cryptic names in the unbearable
.schema output, imagined that
lightningd maybe wouldn’t know how to proceed to take the money from the
to-local output if I managed to broadcast it manually (and in the unlikely event that LNBIG wouldn’t broadcast the penalty transaction), so I decided to just accept the risk and call
lightning-cli close 706327x1588x0 1
But it went well. The
--offline flag apparently really works, as it just considered LNBIG to be offline and 1 second later I got the desired result.
My happiness was complete when I saw the commitment transaction with my output for 10145 satoshis published on the central database of Bitcoin, blockstream.info.
Then I went to eat something and it seems LNBIG wasn’t offline or sleeping, he was certainly looking at all the logs from his 274 nodes in a big room full of monitors, very alert and eating an apple while drinking coffee, ready to take action, for when I came back, minutes later, I could see it, again on the single source of truth for the Bitcoin blockchain, the Blockstream explorer. I’ve refreshed the page and there it was, a small blue link right inside the little box that showed my
to-local output, a notice saying it had been spent – not by my
lightningd since that would have to wait 9000 blocks, but by the same transaction that spent the other output, from which I could be very sure it was it, the glorious, mighty, unforgiving penalty transaction, splitting the earth, showing itself in all its power, and taking my 10145 satoshis to their rightful owner.