lightningnetwork / lnd

Lightning Network Daemon ⚡️
MIT License
7.67k stars 2.07k forks source link

Cannot close channel with state: ChanStatusLocalDataLoss|ChanStatusRestored #6173

Closed johnd1984 closed 2 years ago

johnd1984 commented 2 years ago

Background

About 2 months ago now, I attempted to close channel with Open Node. It is still in the state "waiting_close_channels", I did not get any refunds.

{ "total_limbo_balance": "0", "pending_open_channels": [ ], "pending_closing_channels": [ ], "pending_force_closing_channels": [ ], "waiting_close_channels": [ { "channel": { "remote_node_pub": "03abf6f44c355dec0d5aa155bdbdd6e0c8fefe318eff402de65c6eb2e1be55dc3e", "channel_point": "d252236c20ee326837203144869cabed7eef0ba515cacf71bd4e78487ad627ce:0", "capacity": "4999000", "local_balance": "0", "remote_balance": "0", "local_chan_reserve_sat": "0", "remote_chan_reserve_sat": "0", "initiator": "INITIATOR_LOCAL", "commitment_type": "ANCHORS", "num_forwarding_packages": "0" }, "limbo_balance": "0", "commitments": { "local_txid": "", "remote_txid": "", "remote_pending_txid": "", "local_commit_fee_sat": "0", "remote_commit_fee_sat": "0", "remote_pending_commit_fee_sat": "0" } } ] }

I get this response after I attempt to force close channel.

[lncli] rpc error: code = Unknown desc = cannot close channel with state: ChanStatusLocalDataLoss|ChanStatusRestored

Your environment

LND v0.14.1 mynode 0.2.50 raspi Bitcoin Core version v0.22.0

Steps to reproduce

lncli closechannel --force d252236c20ee326837203144869cabed7eef0ba515cacf71bd4e78487ad627ce 0

Expected behaviour

expected funds to become available on chain

Actual behaviour

Tell us what happens instead

[lncli] rpc error: code = Unknown desc = cannot close channel with state: ChanStatusLocalDataLoss|ChanStatusRestored

guggero commented 2 years ago

This sounds very similar to a recent case. Did you have an power outages recently? Or do something with your channel.db file (e.g. restore a backup or similar)?

johnd1984 commented 2 years ago

I missed a part, I restored it from a zap wallet (linux desktop wallet didn't have force close)

guggero commented 2 years ago

Something went wrong when you restored the wallet, perhaps you didn't copy the absolutely last state of the channel DB (or did you run them in parallel?). So lnd is preventing you from breaching your channel with an old state, that's why you can't force close (if you did, the other node could take all the funds).

Or, when you say "restored", did you mean you used the channel.backup file?

johnd1984 commented 2 years ago

I see, I do have my channel.db - it's copied from last state. Can i just copy that to HDD of my node?

I did restore using just channel.backup & seed.

No, I didn't run in parallel.

guggero commented 2 years ago

Yes, you can replace the channel.db file of the restored node with the one from Zap, if you are certain that it was the absolutely last state. And you must never start Zap again after copying the DB, otherwise you risk breaching yourself as well.

Going to close the issue as this is how recovery with SCB works. Feel free to comment further though if you're not sure how to proceed.

johnd1984 commented 2 years ago

Just to clarify, when you say last state, do you mean state of transactions/channels? or is a new state created every time you open the application?

guggero commented 2 years ago

Yes I mean the last channel state. It's possible and even likely that a channel update happens every time you start the application (for example for updating the fees on the commitment transactions). So last state really means, where did that node run last (with the full database and not restored from channel.backup which only contains a channel shell/partial state).

johnd1984 commented 2 years ago

Yeah OK, It's only one UTXO, one channel, waiting pending close. There was no option to force close in zap wallet, so I don't think I've made any changes.

I have the channel.db copied from last time I opened the zap wallet.

Hopefully...

Thanks for your time. See how I go.

johnd1984 commented 2 years ago

i can't access the directory where the channel.db file is sitting. What would be the best method to replace channel.db on HDD?

guggero commented 2 years ago

Probably a user permission thing. Try switching users or using sudo (not sure how MyNode is set up exactly).

johnd1984 commented 2 years ago

OK I was able to copy channel.db to HDD and bring my node back online.

Here's what I'm getting now:

admin@myNode:~ $ lncli pendingchannels { "total_limbo_balance": "4997617", "pending_open_channels": [ ], "pending_closing_channels": [ ], "pending_force_closing_channels": [ ], "waiting_close_channels": [ { "channel": { "remote_node_pub": "03abf6f44c355dec0d5aa155bdbdd6e0c8fefe318eff402de65c6eb2e1be55dc3e", "channel_point": "d252236c20ee326837203144869cabed7eef0ba515cacf71bd4e78487ad627ce:0", "capacity": "4999000", "local_balance": "4997617", "remote_balance": "0", "local_chan_reserve_sat": "49990", "remote_chan_reserve_sat": "49990", "initiator": "INITIATOR_LOCAL", "commitment_type": "ANCHORS", "num_forwarding_packages": "0" }, "limbo_balance": "4997617", "commitments": { "local_txid": "355c8293c44ec3a6e9435aee34c28f428e0bca1667f5efb641079afc49744c5f", "remote_txid": "0f3d4b272cd89d9069c9c6b7742c669862401b6b23b2ff4bd9e112154ec5515f", "remote_pending_txid": "", "local_commit_fee_sat": "723", "remote_commit_fee_sat": "723", "remote_pending_commit_fee_sat": "0" } } ] } admin@myNode:~ $ lncli closechannel --force d252236c20ee326837203144869cabed7eef0ba515cacf71bd4e78487ad627ce 0 [lncli] rpc error: code = Unknown desc = server is still in the process of starting

johnd1984 commented 2 years ago

Thanks for your help mate, I logged in as root, then used SCP to replace channel.db. It took as while for the node to properly sync up. I was then able to force close the channel!

Roalkege commented 1 year ago

I haven't quite figured out what to do now. I have the problem with three channels, how can I solve it?

guggero commented 1 year ago

I haven't quite figured out what to do now. I have the problem with three channels, how can I solve it?

Which problem exactly? Can you describe a bit more please?

Roalkege commented 1 year ago

I haven't quite figured out what to do now. I have the problem with three channels, how can I solve it?

Which problem exactly? Can you describe a bit more please?

I have three channels with status ChanStatusLocalDataLoss|ChanStatusRestored and I don't know what to do. I had to use a SCB, all channels were closed except the three. What can I do now?

guggero commented 1 year ago

If you had to use SCB you cannot force close them yourself. The other node needs to do that, the SCB just helps your node to contact them. So what you can do is look up their node on a site like 1ml.com or amboss.space to find out if they might have a different IP address to connect to. If the nodes don't exist anymore, it gets tricky. See www.node-recovery.com.