New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lightning linked channel forensics #2683
Conversation
FYI here is an example of dual funded channels |
interesting! I saw this one from CLN, but didn't realize there were tools for multi-funded channels on LND already. https://mempool.space/tx/91538cbc4aca767cb77aa0690c2a6e710e095c8eb6d8f73d53a3a29682cb7581 |
d181a4f
to
22fa63f
Compare
99abf59
to
d95ce5e
Compare
88b61bf
to
1733894
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
channels_forensics
columns can be merged into the channels
table
8a9488e
to
b5a16c5
Compare
merged |
9bcbb42
to
4abccb2
Compare
please rebase and fix DB migration conflict |
4abccb2
to
ba10df6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tested ACK @ ba10df6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested ACK @ v2.5.0-dev [ba10df69]
(builds on PR #2638)
This PR uses on-chain links between channels to deduce ownership of transaction inputs and outputs, together with some other inferences, and surfaces all of this on the channels page.
The resulting data could be useful for tracing how liquidity flows across the network, or simply to highlight this potential privacy leak.
Specifically, we look for the following cases:
If there is a single party in common between these two channels, we can conclude that they owned the connecting txos.
From there, we can fully or partially deduce closing balances of each node in any closed channels, as well as funding contributions to the new channel. In the case of a force close, we can sometimes also infer which node initiated the close.
Implementation
Implemented as another step in the regular lightning network sync tasks, when using an esplora backend (like the existing
runClosedChannelsForensics
task).The analysis consists of checking each input of the channel open transaction to see if it spends a known channel close output (or spends the result of sweeping such an output, where that step is required by the protocol).
When a matching channel close is found, we deduce what we can using the heuristics described above, and save the data to a new
channels_forensics
db table.The first run will take several hours, since it involves fetching and examining transactions one or two steps back from every input of every channel open. However, we only analyse each channel once, so subsequent runs should be fast. To avoid stalling other network sync tasks, we break after
GRAPH_REFRESH_INTERVAL
and resume on the next sync.Limitations
Complete liquidity flows are only revealed when nodes fully recycle funds on both the opening and closing side of a channel. In other cases, we may only be able to deduce the funding contributions, or the closing balances, or nothing at all.
Dual-funded channels
For a channel known to be funded by a single party, discovering the owner of any input to the channel open transaction tells us who contributed all of the capacity.
However, if a channel open uses multiple inputs, (as far as I'm aware) we can't rule out the possiblity that it's actually dual-funded. In that case, the amount contributed by each party is ambiguous, (especially if the transaction generates a lot of change).