aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/address.rs18
-rw-r--r--src/cmd/new.rs9
2 files changed, 22 insertions, 5 deletions
diff --git a/src/cmd/address.rs b/src/cmd/address.rs
new file mode 100644
index 0000000..b0322b2
--- /dev/null
+++ b/src/cmd/address.rs
@@ -0,0 +1,18 @@
+//! Module implementing the `address` subcommand for displaying the public
+//! address for corresponding account.
+
+use crate::cmd::AccountOptions;
+use anyhow::Result;
+use structopt::StructOpt;
+
+#[derive(Debug, StructOpt)]
+#[structopt(about = "print account public address")]
+pub struct Options {
+ #[structopt(flatten)]
+ account: AccountOptions,
+}
+
+pub fn run(options: Options) -> Result<()> {
+ println!("{}", options.account.private_key()?.address());
+ Ok(())
+}
diff --git a/src/cmd/new.rs b/src/cmd/new.rs
index 9110c34..699b825 100644
--- a/src/cmd/new.rs
+++ b/src/cmd/new.rs
@@ -1,7 +1,7 @@
-//! Module implementing the `new` command for generating a mnemonic for a new
+//! Module implementing the `new` subcommand for generating a mnemonic for a new
//! hierarchical deterministic wallet.
-use crate::mnemonic::{Language, Seed};
+use crate::mnemonic::{Language, Mnemonic};
use anyhow::Result;
use structopt::StructOpt;
@@ -18,8 +18,7 @@ pub struct Options {
}
pub fn run(options: Options) -> Result<()> {
- let seed = Seed::random(options.length)?;
- println!("{}", seed.to_mnemonic(options.language));
-
+ let mnemonic = Mnemonic::random(options.language, options.length)?;
+ println!("{}", mnemonic);
Ok(())
}