Closed starius closed 12 months ago
IIUC, we're tracking this here: https://github.com/lightningnetwork/lnd/issues/4778.
Perhaps port this OP comment into that issue so we can track in a single place?
@Roasbeef Done
This issue can be closed then?
Problem
If remote party broadcasts a force close transaction, local funds are sent to an intermediate output, which then is swept to the wallet.
If the local node has lost everything but seed, it won't be able to recover funds through remote force close transactions. Otherwise it could find the other node and ask to force close the channel.
If the local node doesn't have channel.backup, but has channel.db, it may use chantools rescueclosed and recover funds. But still getting funds directly would be more convenient and more reliable.
Also the additional sweep transaction means more fees. Even if a node works well, it still has to pay this fee every time another node broadcasts a force close transaction.
Solution
I propose to use an address from the wallet directly instead of creating an intermediate output. If this is implemented, then only the party initiated the force closing will have to make a sweep transaction, while the passive party will receive its funds in the wallet directly. This will save fees and prevent loss of funds if only seed is available.
Anchors
I found this discussion https://github.com/lightningnetwork/lnd/issues/6855#issuecomment-1241655409
So, my proposal depends on fixing the wallet scanner to detect extra HD wallet derivation paths. Then such a path can be used for direct outputs of force close channels (one address per channel).
If a channel has anchor outputs, all non-anchor outputs must have 1 OP_CHECKSEQUENCEVERIFY (CSV). The wallet can have a path with such addresses! It is a normal P2WSH address, except it has
1 OP_CHECKSEQUENCEVERIFY (CSV)
in the script. P2WSH witness scripts of such outputs currently look like this:The public key is the only variable part. Private keys can be "stored" in seed using a separate HD wallet derivation path. If a channel is force closed by remote party, the local party doesn't have to do anything with these funds until it wants to spend them (e.g. open another channel).