Skip to content

Commit

Permalink
rusk-wallet: Rename all instances of recov phrase to mnemonic phrase
Browse files Browse the repository at this point in the history
This makes Rusk wallet consistent with the Web wallet.
  • Loading branch information
HDauven committed Nov 4, 2024
1 parent c28687b commit c1acb3c
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 22 deletions.
2 changes: 2 additions & 0 deletions rusk-wallet/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rename `--profile` flag to `--wallet-dir` [#2682]
- Change Rusk wallet name and version information [#2647]
- Update Clap from v3 to workspace v4 [#2489]
- Rename all instances of recovery phrase to mnemonic phrase [#2839]

### Fix

- Fix stake info for inactive stakes with rewards [#2766]
- Fix Moonlight stake reward withdrawal [#2523]

[#2839]: https://github.com/dusk-network/rusk/issues/2839
[#2768]: https://github.com/dusk-network/rusk/issues/2768
[#2766]: https://github.com/dusk-network/rusk/issues/2766
[#2708]: https://github.com/dusk-network/rusk/issues/2708
Expand Down
4 changes: 2 additions & 2 deletions rusk-wallet/src/bin/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ use std::{fmt, path::PathBuf};
pub(crate) enum Command {
/// Create a new wallet
Create {
/// Skip wallet recovery phrase (useful for headless wallet creation)
/// Skip wallet mnemonic phrase (useful for headless wallet creation)
#[arg(long)]
skip_recovery: bool,

/// Save recovery phrase to file (useful for headless wallet creation)
/// Save mnemonic phrase to file (useful for headless wallet creation)
#[arg(long)]
seed_file: Option<PathBuf>,
},
Expand Down
12 changes: 6 additions & 6 deletions rusk-wallet/src/bin/interactive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,17 @@ pub(crate) fn load_wallet(
password,
DatFileVersion::RuskBinaryFileFormat(LATEST_VERSION),
)?;
// display the recovery phrase
prompt::confirm_recovery_phrase(&mnemonic)?;
// display the mnemonic phrase
prompt::confirm_mnemonic_phrase(&mnemonic)?;
// create and store the wallet
let mut w = Wallet::new(mnemonic)?;
let path = wallet_path.clone();
w.save_to(WalletFile { path, pwd })?;
w
}
MainMenu::Recover => {
// ask user for 12-word recovery phrase
let phrase = prompt::request_recovery_phrase()?;
// ask user for 12-word mnemonic phrase
let phrase = prompt::request_mnemonic_phrase()?;
// ask user for a password to secure the wallet, create the latest
// wallet file from the seed
let pwd = prompt::create_password(
Expand Down Expand Up @@ -323,12 +323,12 @@ fn menu_wallet(wallet_found: Option<WalletPath>) -> anyhow::Result<MainMenu> {
.add(MainMenu::Create, "Replace your wallet with a new one")
.add(
MainMenu::Recover,
"Replace your wallet with a lost one using the recovery phrase",
"Replace your wallet with a lost one using the mnemonic phrase",
)
} else {
menu = menu.add(MainMenu::Create, "Create a new wallet").add(
MainMenu::Recover,
"Access a lost wallet using the recovery phrase",
"Access a lost wallet using the mnemonic phrase",
)
}

Expand Down
16 changes: 8 additions & 8 deletions rusk-wallet/src/bin/io/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ pub(crate) fn create_password(
Ok(hash(file_version, &pwd))
}

/// Display the recovery phrase to the user and ask for confirmation
pub(crate) fn confirm_recovery_phrase<S>(phrase: &S) -> anyhow::Result<()>
/// Display the mnemonic phrase to the user and ask for confirmation
pub(crate) fn confirm_mnemonic_phrase<S>(phrase: &S) -> anyhow::Result<()>
where
S: std::fmt::Display,
{
Expand All @@ -107,7 +107,7 @@ where
// let the user confirm they have backed up their phrase
loop {
let q = requestty::Question::confirm("proceed")
.message("Have you backed up your recovery phrase?")
.message("Have you backed up your mnemonic phrase?")
.build();

let a = requestty::prompt_one(q)?;
Expand All @@ -117,13 +117,13 @@ where
}
}

/// Request the user to input the recovery phrase
pub(crate) fn request_recovery_phrase() -> anyhow::Result<String> {
// let the user input the recovery phrase
/// Request the user to input the mnemonic phrase
pub(crate) fn request_mnemonic_phrase() -> anyhow::Result<String> {
// let the user input the mnemonic phrase
let mut attempt = 1;
loop {
let q = Question::input("phrase")
.message("Please enter the recovery phrase:")
.message("Please enter the mnemonic phrase:")
.build();

let a = requestty::prompt_one(q)?;
Expand All @@ -139,7 +139,7 @@ pub(crate) fn request_recovery_phrase() -> anyhow::Result<String> {
_ => return Err(err),
},
Err(_) => {
println!("Invalid recovery phrase, please try again");
println!("Invalid mnemonic phrase, please try again");
attempt += 1;
}
}
Expand Down
8 changes: 4 additions & 4 deletions rusk-wallet/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ where

let msg = match e.kind() {
ErrorKind::InvalidArgument => {
format!("You seem to try access a wallet with a different seed-phrase \n\r\n\r{0: <1} delete the cache? (Alternatively specify the --wallet-dir flag to add a new wallet under the given path)", "[ALERT]")
format!("You seem to try access a wallet with a different mnemonic phrase\n\r\n\r{0: <1} delete the cache? (Alternatively specify the --wallet-dir flag to add a new wallet under the given path)", "[ALERT]")
},
ErrorKind::Corruption => {
format!("The database appears to be corrupted \n\r\n\r{0: <1} delete the cache?", "[ALERT]")
Expand Down Expand Up @@ -231,7 +231,7 @@ async fn exec() -> anyhow::Result<()> {
file.write_all(mnemonic.phrase().as_bytes())?
}
// skip phrase confirmation if explicitly
(false, _) => prompt::confirm_recovery_phrase(&mnemonic)?,
(false, _) => prompt::confirm_mnemonic_phrase(&mnemonic)?,
_ => {}
}

Expand Down Expand Up @@ -269,8 +269,8 @@ async fn exec() -> anyhow::Result<()> {
// Use the latest dat file version when there's no dat file
// provided when restoring the wallet
None => {
// ask user for 12-word recovery phrase
let phrase = prompt::request_recovery_phrase()?;
// ask user for 12-word mnemonic phrase
let phrase = prompt::request_mnemonic_phrase()?;
// ask user for a password to secure the wallet
let pwd = prompt::create_password(
password,
Expand Down
4 changes: 2 additions & 2 deletions rusk-wallet/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ pub enum Error {
/// Address does not belong to this wallet
#[error("Address does not belong to this wallet")]
AddressNotOwned,
/// Recovery phrase is not valid
#[error("Invalid recovery phrase")]
/// Mnemonic phrase is not valid
#[error("Invalid mnemonic phrase")]
InvalidMnemonicPhrase,
/// Path provided is not a directory
#[error("Path provided is not a directory")]
Expand Down

0 comments on commit c1acb3c

Please sign in to comment.