Distinguishing mutual and unilateral channel closing in the Bitcoin blockchain

Ever wonder how can one tell the difference between a mutual and an unilateral Lightning Network channel closing?

Zoltán Gálli
Coinmonks
Published in
3 min readJul 20, 2018

--

Gaurav AgrawalLightning Channels can be ended two different way:

  1. a mutual, cooperative closing simply called Closing Transaction
  2. an unilateral, uncooperative closing called Commitment Transaction

It is easy to make a difference: Lightning Network Specifications say the locktime field of mutual closing is always 0. Let’s see how to check this in practice!

We will find funding transaction for a channel using Lightning Network Explorer 1ml.com. Then we find hash ID of spending transaction using Bitcoin Block Explorer btc.com. Then we get spending transaction using web based interface to the Bitcoin API: chainquery.com. And we compare it’s locktime to zero.

What a Mutual Closing looks like

We can see some closed channels here: https://1ml.com/channel?order=closedchannels

Take this example: https://1ml.com/channel/567676753988747264

The explorer shows its Channel Point is: ea6279771eff21c491f36512be9842bfdc9154e8b1848f4be2896b147d49da70:0
The first part of this is the bitcoin transaction ID of the funding transaction, and the second part after the colon is a zero-based index of the transaction output. Zero-based index means the 0 here points to the first output of the transaction.

We can find the funding transaction on the Bitcoin Block Explorer: https://btc.com/ea6279771eff21c491f36512be9842bfdc9154e8b1848f4be2896b147d49da70

The first output of the transaction is the bitcoin address associated to the Lightning Channel:
bc1qfa5u5vplmn3tx6qvtgvc5ente2hg5wfxa7vf3javw5xsrxml2kssujygpz

We can see the channel ends with this transaction ID: dabcfa44dcfc7beab462757b4bbb081bb992e339acc1cf4c395d1a917e2d1947

So we can query the whole decoded transaction with getrawtransaction on the Bitcoin API, and take a closer look at it:

The important part is the "locktime": 0
This was a mutual, cooperative channel closing.

What an Unilateral Closing looks like

Let’s see another channel, for example this: https://1ml.com/channel/583074314791419905

Its Channel Point is: 9c4f1e1f06a786cf6712c2fc119ed0584fcfa4e2a3d637d66bd89245d9ad852d:1
The 1 at the end means we are looking for the second output of the transaction.

Here is the funding transaction in the Bitcoin Block Explorer: https://btc.com/9c4f1e1f06a786cf6712c2fc119ed0584fcfa4e2a3d637d66bd89245d9ad852d

The bitcoin address associated to the lightning channel is:
bc1q8w9jgsggg8pxy7ztwcdk8l4hnsrwrskp4hw8k4q82pmnjqpp305qjx4dkd

The channel is ended with this transaction ID: 5e504e75581ff501a0c852b4a3107df9c72aed17d11bded784adfa6cb9c78074

So we can query it the same way as above to see the decoded transaction:

The important part is the "locktime": 543621745
This was an unilateral, uncooperative channel closing.

Acknowledgments

Thanks for Mykola Sakhno and the LightningPeach team to help me understand these types of transactions.

--

--

Zoltán Gálli
Coinmonks

Roman Catholic | Husband | Father | Geek | https://zoltan.xyz/ PGP Fingerprint: 116D 19B0 5C58 5B6D