6

How do I restore a c-lightning node from a backed up hsm_secret ?

I have tried running lightningd by replacing the generated hsm_secret with the backed-up one. It shows no output and no channel.
How can I retrieve the funds in the node from there ?

2 Answers 2

5

The hsm_secret is used to derive keys for both onchain and offchain (channels commitments) transactions.

On chain

To retrieve on chain funds you can rescan the block chain for your utxos by using the --rescan startup option of lightningd.

Off chain

You can not re create the whole state of your channels just from the hsm_secret, which are stored in the database. Moreover it's very discouraged to restore from a backed up database (penalty transactions...).

Fortunately, with the option_static_remotekey now enabled by default you can now claim your funds onchain after your peer force closed the channel (if the channel was opened when both peers signaled this option).

The process is detailed here as part of the C-lightning FAQ draft.

How do i backup, in practice ?

The different backup solutions currently available are detailed here.

0
2

Hsm secret is only used to derive your keys but you need more than that - which is the state of your channels (meaning the most recent commitment transaction and revocstion secrets). This information can be found in your sql file in the .lightning directory. The problem is that this backup has to be made everytime the state of a channel changes (even failed routing attempts) there is a hook for the plugin api that triggers an event everytime something is written to the database. So I guess it would be best to create a plugin that streams out a replica of your dB writes to a remote backup

0

Your Answer

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

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