lightninglabs / chantools

A loose collection of tools all somehow related to lnd and Lightning Network channels.
MIT License
222 stars 32 forks source link

sweepremoteclosed can't sweep P2WSH #147

Closed jordodev closed 2 months ago

jordodev commented 2 months ago

We have a number of channels that were in an ABANDONED state due to a (since-fixed) bug in LND v18.0 and LiT.

They have been force-closed on the remote side, and the funds were sent to a a P2WSH address.

I have attempted to use sweepremoteclosed with a recovery window as high as 10000, still finding 0 sweep targets with total value of 0 satoshis which is below the dust limit of 600.

Have also tried chantools genimportscript --format electrum --recoverywindow 20000 --lndpaths and imported private keys into electrum, but unfortunately it only finds channel open/close transactions with P2WPKH outputs.

How can I sweep these funds?

guggero commented 2 months ago

Can you DM me some of the close transactions in question? I assume they were of type anchor channel?

guggero commented 2 months ago

Also, what version of chantools did you use? The releases v0.13.1 or latest master? If it was master then you should try again as there was a small bug that might've skipped unspent outputs in some cases (merged now: https://github.com/lightninglabs/chantools/pull/146).

The recovery window highly depends on the number of channels opened over the lifetime of the node. 10k might be enough or it might not be. If you want to get a max number, I'd suggest running lncli wallet accounts list | grep -A8 'default' | grep -A3 1017 and look at the external_key_count, then take one more than that.

jordodev commented 2 months ago

That was it!

Updated to latest master with your merged changes, ran sweepremoteclosed with --recoverywindow 1000 and it found my 5 force-closed channels. Then repeated with --publish and funds have now been recovered.

Huge thanks @guggero

guggero commented 2 months ago

Woohoo, happy to hear. And sorry about that stupid bug :see_no_evil:

guggero commented 2 months ago

Fixed by https://github.com/lightninglabs/chantools/pull/146.