Skip to content

Commit

Permalink
More helpful error message on recover when wallet_data dir doesn't …
Browse files Browse the repository at this point in the history
…exist (mimblewimble#134)

* make recover error message when wallet doesn't exist more helpful

* rustfmt
  • Loading branch information
yeastplume authored Jun 4, 2019
1 parent 03ab8ad commit 42befd2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions impls/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ pub enum ErrorKind {
#[fail(display = "Wallet seed doesn't exist error")]
WalletSeedDoesntExist,

/// Wallet seed doesn't exist
#[fail(display = "Wallet doesn't exist at {}. {}", _0, _1)]
WalletDoesntExist(String, String),

/// Enc/Decryption Error
#[fail(display = "Enc/Decryption error (check password?)")]
Encryption,
Expand Down
7 changes: 7 additions & 0 deletions impls/src/seed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ impl WalletSeed {
if WalletSeed::seed_file_exists(wallet_config).is_err() {
WalletSeed::backup_seed(wallet_config)?;
}
if !Path::new(&wallet_config.data_file_dir).exists() {
return Err(ErrorKind::WalletDoesntExist(
wallet_config.data_file_dir.clone(),
"To create a new wallet from a recovery phrase, use 'grin-wallet init -r'"
.to_owned(),
))?;
}
let seed = WalletSeed::from_mnemonic(word_list)?;
let enc_seed = EncryptedWalletSeed::from_seed(&seed, password)?;
let enc_seed_json = serde_json::to_string_pretty(&enc_seed).context(ErrorKind::Format)?;
Expand Down

0 comments on commit 42befd2

Please sign in to comment.