diff --git a/applications/tari_app_utilities/src/identity_management.rs b/applications/tari_app_utilities/src/identity_management.rs index df42bbe6cc..f526ecc75d 100644 --- a/applications/tari_app_utilities/src/identity_management.rs +++ b/applications/tari_app_utilities/src/identity_management.rs @@ -24,12 +24,14 @@ use crate::utilities::ExitCodes; use log::*; use rand::rngs::OsRng; use std::{clone::Clone, fs, path::Path, string::ToString, sync::Arc}; +use tari_common::configuration::bootstrap::prompt; use tari_comms::{multiaddr::Multiaddr, peer_manager::PeerFeatures, NodeIdentity}; use tari_core::transactions::types::PrivateKey; use tari_crypto::{ keys::SecretKey, tari_utilities::{hex::Hex, message_format::MessageFormat}, }; + pub const LOG_TARGET: &str = "tari_application"; /// Loads the node identity, or creates a new one if the --create-id flag was specified @@ -51,17 +53,22 @@ pub fn setup_node_identity>( Ok(id) => Ok(Arc::new(id)), Err(e) => { if !create_id { - error!( - target: LOG_TARGET, - "Node identity information not found. {}. You can update the configuration file to point to a \ - valid node identity file, or re-run the node with the --create-id flag to create a new identity.", - e - ); - return Err(ExitCodes::ConfigError(format!( - "Node identity information not found. {}. You can update the configuration file to point to a \ - valid node identity file, or re-run the node with the --create-id flag to create a new identity.", - e - ))); + let prompt = prompt("Node identity does not exist.\nWould you like to to create one (Y/n)?"); + if !prompt { + error!( + target: LOG_TARGET, + "Node identity information not found. {}. You can update the configuration file to point to a \ + valid node identity file, or re-run the node with the --create-id flag to create a new \ + identity.", + e + ); + return Err(ExitCodes::ConfigError(format!( + "Node identity information not found. {}. You can update the configuration file to point to a \ + valid node identity file, or re-run the node with the --create-id flag to create a new \ + identity.", + e + ))); + }; } debug!(target: LOG_TARGET, "Node id not found. {}. Creating new ID", e); diff --git a/common/src/configuration/bootstrap.rs b/common/src/configuration/bootstrap.rs index aee62a9cae..22c801b9fd 100644 --- a/common/src/configuration/bootstrap.rs +++ b/common/src/configuration/bootstrap.rs @@ -315,7 +315,7 @@ impl ConfigBootstrap { } } -fn prompt(question: &str) -> bool { +pub fn prompt(question: &str) -> bool { println!("{}", question); let mut input = "".to_string(); io::stdin().read_line(&mut input).unwrap();