ElementsProject / lightning

Core Lightning — Lightning Network implementation focusing on spec compliance and performance
Other
2.84k stars 901 forks source link

backup seed, private key, channels #5318

Open stn021 opened 2 years ago

stn021 commented 2 years ago

Hello,

I would like to make some kind of backup, in case the node crashes.

So I was wondering:

TIA, stn

vincenzopalazzo commented 2 years ago

This will answer your question? https://lightning.readthedocs.io/BACKUP.html ? otherwise, can you point out some of the think that is not clear, so in this way we can improve the docs?

How can I export the information about the channels that would be necessary to close the channels and recover the funds in case the node crashes?

I think this is a work in progress https://github.com/ElementsProject/lightning/pull/5288, but with the backup, you should be able to fully recover your node

stn021 commented 2 years ago

OK, so far I have checked and reproduced the backup of the on-chain-funds, meaning the file hsm_secret.

Hexdump with xxd and the reverse process with xxd -r seem to work, I expect but have not checked that the software will accept this file after the appropriate chmod and placement of the file in the correct directory.

There is one unclear thing which would IMO help understanding and one thing I really miss.

1) an hsm_secret can be created from a BIP39 seed. That is helpful. Next time I will start there. I wondered about BIP39 because other LN-implementations like umbrel or raspiblitz also use seeds, 24 words, but not BIP39. Instead they use aezeed. For the docs I would like to suggest a mention or this fact and a short explanation as to why lightning-core uses BIP39 and not aezeed.

2) How can I convert my existing hsm_secret into a BIP39-seed? This question I would consider important because right now I can only access my on-chain-funds with lightning-core. With the BIP39-seed-phrase it would be possible to access the on-chain-funds with any bitcoin-wallet. That would be helpful not only for getting the funds back after a crash of the node but also I would use some other bitcoin-wallet in parallel, so access to the on-chain-funds would be possible without necessarily having to access the node. For example while travelling with only a smartphone.

stn021 commented 2 years ago

So I tried the second part of https://lightning.readthedocs.io/BACKUP.html, on how to backup channels, lightning-database etc. Specifically I looked at the plugin "backup"

That proved quite difficult, there are some unclear items in the docs.

1) It says "You can get the backup plugin here: https://github.com/lightningd/plugins/tree/master/backup" Sure, that path exists, obviously, but it is quite unclear what "get it at..." means at this point. "git clone ..." does not work. Quite a while later I guessed that I have to clone the parent-directory. That at least seemed to work.

2) Then it says "pip3 install -r requirements.txt". But, sadly the folder "backup" does not contain a file 'requirements.txt'. Most other plugin-folders do, but not this one

3) Then it says "Add these settings to your lightningd configuration: important-plugin=/path/to/backup.py". I found elsewhere that "lightningd configuration" may or my not refer to a file "config" in the "$LIGHTNINGDIR". I created that file. I did not exist previously. No idea if I created the correct file and if the location (path) is correct.

So now maybe (or not) I have correctly installed the backup-plugin. The docs do NOT say how can I verify that it is really working. So far the backup-file was correctly created (512 bytes) and after that absolutely nothing happened

overcoin commented 2 years ago

This is not a support forum. Please, ask questions about technicalities only!

Hope this will help you: https://www.youtube.com/watch?v=fvB1SmY-y98

stn021 commented 2 years ago

Yes, that is what I thought.

This thread is about a technicality. With lightning the security of funds after node-crashes is a highly sensitive technical issue. Also I was not asking for support, even if it may have sounded like that.

First let me clarify that I think core lightning is an excellent project. I read that it has some advantages over other node-software. Also I find lightning-cli very useful for exploring the lightning network.

The only real and absolutely prohibitive problem that I found is the absence of a reliable channel-backup and restore. My question in this thread was actually : is there some robust and tested way to backup and restore channels?

Robust and tested means:

I was not asking for support. I was pointing out that on core lightning backup of channels is complicated, error-prone and insufficiently documented. That means that me and anyone else who likes to keep his funds can at present not use core lightning.

I do understand that backup is work in progress. So I will check back regularly to see if backup+restore of channel works reliably.

50egtftz commented 5 months ago

2. How can I convert my existing hsm_secret into a BIP39-seed?

Hope this will help you: https://www.youtube.com/watch?v=fvB1SmY-y98

Does anyone know what is the derivation path that CLN's hsm_secret uses?

In following the excellent video tutorial, I was able to setup a BIP39 seed, and import that seed into hsm_secret. But I can't get the derivation path right.

Per @402PaymentReq's suggestion in the YT video comments, where another person had the same issue, it was suggested to try m/84'|141'/0'/0'/ (https://walletsrecovery.org/). But none of these worked.

Thank you!