unit-e icon indicating copy to clipboard operation
unit-e copied to clipboard

detect empty wallet or create new wallet

Open scravy opened this issue 7 years ago • 3 comments

From a comment in https://github.com/dtr-org/unit-e/pull/37

[We are] trying to use as much bitcoin functionality as possible. Bitcoins CWallet already has methods to set the master key but I do suspect it was not their intention for them to be used /after/ a wallet has been created already. When the node comes up it automatically creates a wallet. Upon creation the wallet is preseeded with a list of reserve keys. It is thus tricky to distinguish a newly created wallet from a wallet which is already in use. Nevertheless you could import a new masterkey into an already used wallet, which is why setting a new masterkey will automatically backup your existing wallet (although in most cases this will be an empty wallet).

Ways to solve this:

  • create and open a completely new wallet
  • detect whether current wallet is used, if used -> fail, of not used -> replace master key

scravy avatar Aug 27 '18 09:08 scravy

I'm in favor of the second solution, with the addition of a "force" argument to importmasterkey which will replace the key unconditionally.

We could detect that a wallet is unused if the mapAddressBook collection is empty, for example.

cmihai avatar Jan 24 '19 16:01 cmihai

Related: https://github.com/bitcoin/bitcoin/pull/15454#

scravy avatar Feb 22 '19 13:02 scravy

Also related: https://github.com/bitcoin/bitcoin/commit/7687f7873b75c3cbdfa15ab570211dc39d24ab80

cmihai avatar Mar 19 '19 13:03 cmihai