diff --git a/common/client-libs/validator-client/src/signing/direct_wallet.rs b/common/client-libs/validator-client/src/signing/direct_wallet.rs index 12af8b485f..9d44255129 100644 --- a/common/client-libs/validator-client/src/signing/direct_wallet.rs +++ b/common/client-libs/validator-client/src/signing/direct_wallet.rs @@ -10,7 +10,7 @@ use cosmrs::tx; use cosmrs::tx::SignDoc; use nym_config::defaults; use thiserror::Error; -use zeroize::{Zeroize, ZeroizeOnDrop}; +use zeroize::{Zeroize, ZeroizeOnDrop, Zeroizing}; type Secp256k1Keypair = (SigningKey, PublicKey); @@ -128,9 +128,20 @@ impl DirectSecp256k1HdWallet { Ok(accounts) } + pub fn secret(&self) -> &bip39::Mnemonic { + &self.secret + } + + #[deprecated( + note = "use either .secret() for obtaining &bip39::Mnemonic or .mnemonic_string() for Zeroizing wrapper around the String" + )] pub fn mnemonic(&self) -> String { self.secret.to_string() } + + pub fn mnemonic_string(&self) -> Zeroizing { + Zeroizing::new(self.secret.to_string()) + } } #[must_use] diff --git a/common/commands/src/validator/account/create.rs b/common/commands/src/validator/account/create.rs index 1149bc07d9..f2cd4eb336 100644 --- a/common/commands/src/validator/account/create.rs +++ b/common/commands/src/validator/account/create.rs @@ -18,6 +18,6 @@ pub fn create_account(args: Args, prefix: &str) { let wallet = DirectSecp256k1HdWallet::from_mnemonic(prefix, mnemonic); // Output address and mnemonics into separate lines for easier parsing - println!("{}", wallet.mnemonic()); + println!("{}", wallet.mnemonic_string().as_str()); println!("{}", wallet.try_derive_accounts().unwrap()[0].address()); }