Coder Social home page Coder Social logo

rpc: implement backupwallet about btcwallet HOT 7 OPEN

btcsuite avatar btcsuite commented on August 15, 2024
rpc: implement backupwallet

from btcwallet.

Comments (7)

jrick avatar jrick commented on August 15, 2024

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.

from btcwallet.

arnuschky avatar arnuschky commented on August 15, 2024

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:

  • Single non-HD keys that can't be restored with a seed (eg, imported ones).
  • When restoring an HD wallet from the seed, I might not know which wallet chains and addresses have been created and used previously. Searching through this history is very quickly extremely costly (as each new address has to be rescanned).
  • Rescans can take a lot of time.
  • Any other metadata in the db is lost.

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.

from btcwallet.

jrick avatar jrick commented on August 15, 2024

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.

from btcwallet.

arnuschky avatar arnuschky commented on August 15, 2024

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)?

from btcwallet.

jrick avatar jrick commented on August 15, 2024

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.

from btcwallet.

davecgh avatar davecgh commented on August 15, 2024

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.

from btcwallet.

jrick avatar jrick commented on August 15, 2024

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.

from btcwallet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.