Open dajohi opened 10 years ago
The seed should be backed up when the wallet is created, and is used to recreate a new wallet with the same keys. Since the seed is not saved, it cannot be exported at a later time.
I would like to reopen this. The backupwallet
RPC call on bitcoin core writes the wallet in a consistent state so that it can be backed up and be used on a future restart.
This is very useful beyond backing up HD keys:
Many of these things are not super critical for the average home user, but remember that down-times over a few seconds/minutes are not acceptable in a professional production environment.
For these reasons I think that a functionality as provided by backupwallet
is very much needed.
For us, this is as easy as copying the wallet.db
file while wallet is closed. Bitcoin Core Wallet needs an RPC for this since it's not as simple as copying the wallet file since it references the blockchain data as well.
No need to go over RPC to export everything in the wallet.
So how do I copy this file while running? Do you mean that I have to shut down btcwallet every time I backup (thereby losing all rpc client connections etc)?
Copying a file isn't an atomic operation on any filesystem that I know of. While the entire original file should always be in some kind of consistent state, the copy might not be.
I'd suggest having the RPC work similar to the existing export watching wallet RPC function. That is to say, have it create a read transaction and use WriteTo
to write the full contents to a separate file. That will provide a safe method for requesting a backup to be made while the wallet process is operational.
This also means you won't be trying to copy all of the data over the RPC connection, which I don't so much benefit to. I would expect having a second file that contains a consistent backup which the user can then use rsync, or whatever their preferred method is, to copy the file to offline storage is preferable.
I still believe that recreating the wallet via the seed is the best method of recovering a wallet. I'm not a fan of using an RPC to write local files which the client then has to fetch off of the server's filesystem.
implement backupwallet