Distinguishing Lightning channels on-chain Is there a way to tell (probabilistically, maybe) by looking at an on-chain transaction that it is related to Lightning (is [likely to be] a channel opening or closure)?
A lightning funding transaction is a P2WSH transaction, which appears on chain as paying to some random-looking script hash, but the redeemScript which can unlock and spend the money is not revealed on chain until the transaction gets spent (which is when the channel gets closed in Lightning's case).

You can recreate the redeemScript if you know the funding public keys used for it, which are broadcast over Lightning's gossip network as part of a channel_announcement message. If you take the two funding public keys, where the first key is the lexicographically lesser of the two, the redeemScript is simply:

OP_2 &lt;pubKey1&gt; &lt;pubKey2&gt; OP_2 OP_CHECKMULTISIG


By hashing this and comparing it to the hash the unspent P2WSH transaction spends to, you can verify that the transaction is a Lightning channel.

But without knowledge of those funding public keys (private channels or non-lightning txs), you cannot know the content of the redeemScript until the transaction is spent.