From cc6f7998fd200369d9eeb48e6540e2a89725f930 Mon Sep 17 00:00:00 2001 From: Paul Hauner Date: Tue, 2 Mar 2021 05:59:47 +0000 Subject: [PATCH] Improve error when user doesn't have a wallet (#2231) ## Issue Addressed NA ## Proposed Changes I was doing some testing and noticed that this error could be a bit nicer. It helps users understand that they need to create a wallet before a validator. ## Additional Info NA --- account_manager/src/validator/create.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/account_manager/src/validator/create.rs b/account_manager/src/validator/create.rs index 8e96a0040..7d4340774 100644 --- a/account_manager/src/validator/create.rs +++ b/account_manager/src/validator/create.rs @@ -137,6 +137,18 @@ pub fn cli_run( let count: Option = clap_utils::parse_optional(matches, COUNT_FLAG)?; let at_most: Option = clap_utils::parse_optional(matches, AT_MOST_FLAG)?; + // The command will always fail if the wallet dir does not exist. + if !wallet_base_dir.exists() { + return Err(format!( + "No wallet directory at {:?}. Use the `lighthouse --network {} {} {} {}` command to create a wallet", + wallet_base_dir, + matches.value_of("network").unwrap_or(""), + crate::CMD, + crate::wallet::CMD, + crate::wallet::create::CMD + )); + } + ensure_dir_exists(&validator_dir)?; ensure_dir_exists(&secrets_dir)?;