SatoshiPortal / cyphernode

Modular Bitcoin full-node microservices API server architecture and utilities toolkit to build scalable, secure and featureful apps and services without trusted third parties
MIT License
363 stars 68 forks source link

Disaster recovery: bitcoin core wallet passphrase and seed, and also LN channel state #188

Open ALeschinsky opened 4 years ago

ALeschinsky commented 4 years ago

Hello, I'm trying to figure out how I'd restore Bitcoin funds if the node dies - normally, I would use passphrase + seed, but how do I extract that from my cyphernode installation?

Also, I'd like to be able to backup LN state files with some sort of syncing tool (I like syncthing) - where in the file system can I find this?

In general, once I send BTC to fund node and have some channels going and then my node dies, what are disaster recovery steps?

Kexkey commented 4 years ago

Hi @ALeschinsky! The Bitcoin Core's wallet files should be backed up somewhere if you use Cyphernode on mainnet. It is on the todo list to have a "Wallet backup" button on the Cyphernode admin page. BTW, Bitcoin Core doesn't support backing up with a seed phrase like we are used to see on mobile wallets.

As for LN backups, it's not that simple. Until recently, there was no way to do it safely. But there seems to be a backup plugin for c-lightning that's been merged last month or so. I haven't tested it. https://github.com/lightningd/plugins/tree/master/backup. If it appears to work well, I will try to integrate it by default in the Cyphernode setup.

The questions you are asking apply to everything Bitcoin, not only Cyphernode. They are good questions and one of the problems of Bitcoin is the complexity of securing funds. For now, Cyphernode doesn't particularly help here, but we have plans to do so in the future.

For questions about c-lightning, here is the c-lightning project repo: https://github.com/ElementsProject/lightning.

ALeschinsky commented 4 years ago

Hi @Kexkey , thanks for your answers!

With a wallet file, how do I restore the wallet? And which file would that be, I noticed there was spending1.dat or similarly named file - is that the one?

For lightning, I worked with LND before and what we did for backing up was just to sync channel state files - I know it's not 100% bulletproof, but it's the best we can do at this point without having to used a distributed file system (which would also fine).

Kexkey commented 4 years ago

Hi @ALeschinsky ! Yes, in current Cyphernode setup, spending01.dat is the wallet file that has private keys/spending capability. You can copy that file but if your Bitcoin Core instance is running, you should use something like this:

docker exec -it $(docker ps -q -f "name=cyphernode_bitcoin") bitcoin-cli -rpcwallet=spending01.dat backupwallet /.bitcoin/spending-wallet-backup.dat

...and find the file in your local mounted directory for bitcoin as you specified it during setup (maybe in dist/cyphernode/bitcoin/).

You're right, LND started working on LN wallet/channel state backups a while ago. I haven't followed the dev though and we are currently using C-Lightning in Cyphernode. I personally (recklessly) lost funds a while back because of the lack of LN backups... hoping for something robust to be built-in the wallets/nodes eventually. :-)