I lost my Lnd channel backup in a boating accident, but I still have the mnemonic. I had one freshly opened channel to my own c-lightning node which has never been used. I force closed the channel from the c-lightning side.
The funds are now in a P2WPKH address which I've imported into Bitcoin Core. Now I need to figure out the private key in order to sweep it. This requires knowing how to derive it, and then how to dump it.
There is wallet utility pull request that I could tweak in order to dump the key I need once I know how to derive it.
I also know the funding transaction id, the channel id and all the other channel details c-lightning spits out with
Key derivation is explained in derivation.go:
The coinType for Bitcoin is 0, and I believe the key family is 3: "used in scripts that pay directly to us without any delay"
My guess is that the index is 0 since it was the first channel.
BOLT 3 then explains how to do tweak this key for a commitment transaction. Because the other side closed this channel, I need the
to_remote output, which requires the
pubkey = basepoint + SHA256(per_commitment_point || basepoint) * G privkey = basepoint_secret + SHA256(per_commitment_point || basepoint)
The spec says "the remotepubkey uses the remote node's payment_basepoint". Is that the key we just derived?
So that leaves the
per_commitment_point to be figured out, derived from
per_commitment_secret. I'm confused where that comes from.
What Go incantation should I use to dump the private key I'm looking for?