How do I restore a c-lightning node from hsm_scret? I have tried running lightningd having the backed up hsm_secret. It shows no outputs and no channels. How can I retrieve the funds in the node
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
hsm_secret is used to derive keys for both onchain and offchain (channels commitments) transactions.
To retrieve on chain funds you can rescan the block chain for your utxos by using the
--rescan startup option of
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.