Why Nostr? What is Njump?
2024-10-28 13:31:15

Râu Cao ⚡ on Nostr: This week, it finally happened: I still had a Lightning channel open with a node that ...

This is a long form article, you can read it in https://habla.news/a/naddr1qvzqqqr4gupzq8meqkx80g3yuklzymy0qfx2ekk56aqc2ht4ak03z3em4r4cdcwtqqxnzdejxcenjd3hx5urgwp4676hkz

This week, it finally happened: I still had a Lightning channel open with a node that hadn’t been online for the better part of a year now, so I decided to close the channel unilaterally. But force-closing a channel means you have to broadcast the latest commitment transaction, the pre-set fee of which was only ~1 sat/vB for this one.

With LND, if the channel is created as an anchor channel (by default only since version 0.12), then the commitment transaction contains small extra outputs (currently 330 sats), which let either channel partner spend one of them into a child transaction that can be created with higher fees to pay for the parent transaction (CPFP). LND even has a built-in command for that: lncli wallet bumpclosefee

However, this channel was created in the old-school way, and was thus stuck with its low fee. In fact, even the local bitcoin node refused to accept the transaction into its own mempool, so the bitcoin p2p network didn’t even know it existed. So how do we get out of this pickle?

The solution

Enter the mempool.space Accelerator. It is essentially an automated way to create agreements with various mining pools to mine your low-fee transaction in exchange for an out-of-band payment. Mempool.space coordinates these agreements and out-of-band payments with miners and gets a share from the overall fee for that.

Now, if you’re in the same situation as I was, you might search for the ID of your closing transaction and find that mempool.space cannot find it. Remember how the local bitcoin node (with mostly default settings) didn’t accept it in the first place?

1. Get the transaction to be broadcast

In your bitcoin.conf, add the following line:

minrelaytxfee=0

This sets the minimum fee to 0, meaning it will accept and broadcast your transactions, no matter how low the fee is. Restart bitcoind and wait a little bit. LND will retry broadcasting the closing transaction every minute or so until it succeeds. At some point you should be able to find it on mempool.space.

2. Use the Accelerator to confirm it

Once you can see the transaction on mempool.space, you can just click the “Accelerate” button next to the ETA. This will bring you to a page that shows you the estimated share of miners that will include your transaction in their blocks, as well as some acceleration fee options for various transaction fee levels, which you can pay for via the Lightning Network, of course.

If you haven’t looked into this service before (which I had), then the fees might be a bit of a surprise to you. This thing is not cheap! Bumping my fee from 1 sat/vB to ~9 sats/vB cost a whopping 51,500 sats (31 USD that day). Bumping it higher only seemed to add the difference in the transaction fee itself, so the service seems to have cost a flat 50K sats at the time.

Unfortunately, this channel wasn’t particularly large, so the acceleration fee amounted to ~9% of my remaining channel balance. But 91% of something is better than 100% of nothing, so I actually felt pretty good about it.

Next, you will see something like this:

Screenshot of an accelerated transaction on mempool.space

Time to lean back and let the miners work for you. In my case, the ETA was eerily precise. It told me that it would take ~56 minutes to confirm the transaction, and almost exactly an hour later it was mined.

3. Wait

Now that our transaction is confirmed, our channel is not closed immediately, of course. The time lock of the HTLC protects our channel partner from us broadcasting an old channel state in which our balance might be higher than in the latest state.

In my case, it was set to 144 blocks, i.e. ~24 hours. So I checked back the next day, et voilá: channel closed and balance restored. 🥳

Author Public Key
npub1raustrrh5gjwt03zdj8syn9vmt2dwsv9t467m8c3gua636uxu89svgdees