aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/new.rs
blob: 9110c34ef4bf689768660af9e067d6d49bb25d1b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! Module implementing the `new` command for generating a mnemonic for a new
//! hierarchical deterministic wallet.

use crate::mnemonic::{Language, Seed};
use anyhow::Result;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
#[structopt(about = "generate a new HD wallet mnemonic")]
pub struct Options {
    /// The number of words for the mnemonic phrase.
    #[structopt(short = "n", long, default_value = "12")]
    length: usize,

    /// The language to generate the mnemonic for.
    #[structopt(short, long, default_value)]
    language: Language,
}

pub fn run(options: Options) -> Result<()> {
    let seed = Seed::random(options.length)?;
    println!("{}", seed.to_mnemonic(options.language));

    Ok(())
}