Closed daira closed 2 years ago
Here's what I'm thinking for the tool:
zcash-cli
is in the same directory (or failing that, the PATH
), and use it in a subprocess. But we design assuming at some point we'll bring its knowledge into the binary directly.gumdrop
or clap
crates, for datadir
at a minimum, perhaps anything else we need to point zcash-cli
at the right RPC. Ideally only datadir
(and if not given to us, we don't set anything on zcash-cli
.eprintln!()
s and the dialoguer
crate.We also need to modify zcash-cli
to not allow calling the RPC methods required for confirmation (and instead report an error saying "use the wallet tool, oh and you probably also leaked the mnemonic into your environment"), unless it's being called as a subprocess of the wallet tool (and once we migrate to interacting directly with zcashd
, that override can also be removed).
@nuttycom, @daira and I talked this over in PR Gardening, and had the following thoughts on UX:
Users can currently only extract the mnemonic via a backup using z_exportwallet
, which forces the user to run zcashd
with -exportdir
and writes to a file (a decision made for security, so the backup couldn't be extracted by someone with RPC access, and couldn't be used to overwrite arbitrary system files).
Tool tells the user what it is going to do, and notes that it requires zcashd
to be running with -exportdir
. User confirms to either continue, or exit (so they can set up zcashd
).
Tool tries to call z_exportwallet NON_ASCII_FILENAME
and looks for the error string Filename is invalid as only alphanumeric characters are allowed.
. If the error is instead Cannot export wallet until the zcashd -exportdir option has been set
then the tool reports to the user "You need to run zcashd
with the -exportdir
flag set to wherever you want the backup file to be created".
Tool prompts user for an alphanumeric backup filename (defaulting to YYYYMMDDsomething
).
Tool tries to call z_exportwallet FILENAME
; if that fails, it reports the error to the user.
Tool reads the backup file; if that fails, it informs the user that it needs read access to -exportdir
.
Tool extracts the mnemonic from the backup file, splits on spaces to obtain words.
Tool starts displaying each word one-by-one to the user, waiting for the user to confirm they have written it down.
Tool then queries several randomly-selected words (or maybe all of them in random order)?
Once the user gets through that, the tool submits the mnemonic to zcashd
to inform it that the backup is complete.
From the pending release notes:
Mnemonic Recovery Phrases
The zcashd wallet has been modified to support BIP 39, which describes how to derive the wallet's HD seed from a mnemonic phrase. The mnemonic phrase will be generated on load of the wallet, or the first time the wallet is unlocked, and is available via the
z_exportwallet
RPC call. All new addresses produced by the wallet are now derived from this seed using the HD wallet functionality described in ZIP 32 and ZIP 316. For users upgrading an existing Zcashd wallet, it is recommended that the wallet be backed up prior to upgrading to the 4.5.2 Zcashd release.Following the upgrade to 4.5.2, Zcashd will require that the user confirm that they have backed up their new emergency recovery phrase, which may be obtained from the output of the
z_exportwallet
RPC call. This confirmation can be performed manually using thezcashd-wallet-tool
utility that is supplied with this release. The wallet will not allow the generation of new addresses until this confirmation has been performed. It is recommended that after this upgrade, that funds tied to preexisting addresses be migrated to newly generated addresses so that all wallet funds are recoverable using the emergency recovery phrase going forward. If you choose not to migrate funds in this fashion, you will continue to need to securely back up the entirewallet.dat
file to ensure that you do not lose access to existing funds; EXISTING FUNDS WILL NOT BE RECOVERABLE USING THE EMERGENCY RECOVERY PHRASE UNLESS THEY HAVE BEEN MOVED TO A NEWLY GENERATED ADDRESS FOLLOWING THE 4.5.2 UPGRADE.This issue is to implement
zcashd-wallet-tool
.