mirror of
https://github.com/mimblewimble/grin-wallet.git
synced 2025-01-21 03:21:08 +03:00
More helpful error message on recover when wallet_data
dir doesn't exist (#134)
* make recover error message when wallet doesn't exist more helpful * rustfmt
This commit is contained in:
parent
03ab8ad8bd
commit
42befd2340
2 changed files with 11 additions and 0 deletions
|
@ -57,6 +57,10 @@ pub enum ErrorKind {
|
||||||
#[fail(display = "Wallet seed doesn't exist error")]
|
#[fail(display = "Wallet seed doesn't exist error")]
|
||||||
WalletSeedDoesntExist,
|
WalletSeedDoesntExist,
|
||||||
|
|
||||||
|
/// Wallet seed doesn't exist
|
||||||
|
#[fail(display = "Wallet doesn't exist at {}. {}", _0, _1)]
|
||||||
|
WalletDoesntExist(String, String),
|
||||||
|
|
||||||
/// Enc/Decryption Error
|
/// Enc/Decryption Error
|
||||||
#[fail(display = "Enc/Decryption error (check password?)")]
|
#[fail(display = "Enc/Decryption error (check password?)")]
|
||||||
Encryption,
|
Encryption,
|
||||||
|
|
|
@ -138,6 +138,13 @@ impl WalletSeed {
|
||||||
if WalletSeed::seed_file_exists(wallet_config).is_err() {
|
if WalletSeed::seed_file_exists(wallet_config).is_err() {
|
||||||
WalletSeed::backup_seed(wallet_config)?;
|
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 seed = WalletSeed::from_mnemonic(word_list)?;
|
||||||
let enc_seed = EncryptedWalletSeed::from_seed(&seed, password)?;
|
let enc_seed = EncryptedWalletSeed::from_seed(&seed, password)?;
|
||||||
let enc_seed_json = serde_json::to_string_pretty(&enc_seed).context(ErrorKind::Format)?;
|
let enc_seed_json = serde_json::to_string_pretty(&enc_seed).context(ErrorKind::Format)?;
|
||||||
|
|
Loading…
Reference in a new issue