I have LN node running on c-lightning. I am performing ~/.lightning dir backups time-to-time.

Let's say after backup i open few new channels and withdraw rest of onchain funds to my electrum. Then i restore a backup.

What will happen to my node and its channels?

P.S. i have tried such scenario once. Onchain funds status after backup restore become 'spent'. i had to launch 'lightning-cli dev-rescan-outputs' to refresh onchain funds and get actual status. While my node lists channels in 'listfunds', i see that those channels become inactive. What is happening under the hood? what is the correct way of making and restoring node backups?

1 Answer 1


As pointed out in similar questions backups are tricky with lightning. In the case of lightning each payment channel is a 2 of 2 multisig wallet. One of the keys is in your possession and it differs for each channel but in generally is derived from your master key.

The masterkey in c Lightning is 32 byte and stored in binary in ./lightning/hsm_secret

Unluckily it is not sufficient to backup your masterkey. Every channel has a so called state and an old state of the channel will yield problems (potentially a forceful close of the channel partner and them being able to claim your funds.)

So here is what should happen : If you turn off your node and make a backup of your lightning dir you will be able to restore that backup on this or a different machine and after turning on your lightning node everything should work as before.

If however you change channel state before restori g your backup your channel partner and you will most likely see a mismatch and fail the channel which means they publish their latest state. If you are lucky it is your partner and you can claim your outputs. If not it is your node and your partner will probably throw in their penalty tx to claim all coins of the channel due to the channel breach.

Generally under the hood after restart of a lightning node all peers are being connected again. If that does not work (because the other node might be offline) there will be inactive channels.

  • 2
    It's worth pointing out that state changes happen automatically, e.g., fee changes and HTLC forwarding, so it should never be considered safe to restore if the node had been running inbetween. Shutting down, migrating, the restarting is ok, put one must be absolutely sure the node hadn't been running in the interim. With option_dataloss_protection, now enabled with all up to date implementations, no node should ever inadvertently cheat, but at that point you're at the mercy of the counterparty (see criticism of LNDs SCB scheme).
    – cdecker
    Apr 29, 2019 at 13:16
  • After restore i have now about 20 inactive channels. I can connect to almost every node (some nodes went offline) but this doesnt restore channel state to active even after 15 minutes. i have a bunch of inactive channels but what to do now? i cannot close these channels, i am getting "this channel is inactive". Both sides are online. as i understand there is some timeout which will be reached and then channel will auto-close? am i right?
    – baysx
    Apr 29, 2019 at 15:46
  • It seems that i got expensive lesson about backups :) channels now are closing, i see that onchain funds appear, but it looks that i loosed already about 15% of funds that was on channels. We'll see what happens next, i have still about 50% offchain on inactive channels. What keywords should be searched in logs to see was there claim for all funds on other side or not?
    – baysx
    Apr 29, 2019 at 16:08
  • Interesting fact, but almost all my funds appeared few days later after running dev-rescan-outputs (lasted quite long). Anyway, i think this is lucky case and you should not run 'old backup' version in online mode if you have chances to recover the last one node state. In my case i was doing exactly wrong way and ran 'last_state" then 'prev_state' then again 'last_stait'. On second step i had many messages in logfile about 'Recovering funds!' events, so you should not allow to happen this for best experience. anyway, i am happy that protocol itself is pretty fail-proof.
    – baysx
    May 2, 2019 at 11:05
  • Could be that your node detected problems, failed the channel with force closing newest state. In that case there was a timelock on your funds. Your lightning node keeps track of them and redeems them after the timelock this could be the reason why funds did not appear directly May 2, 2019 at 13:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.