diff --git a/applications/tari_base_node/src/commands/command/ping_peer.rs b/applications/tari_base_node/src/commands/command/ping_peer.rs index 828c78f140..b21f72c803 100644 --- a/applications/tari_base_node/src/commands/command/ping_peer.rs +++ b/applications/tari_base_node/src/commands/command/ping_peer.rs @@ -57,7 +57,7 @@ impl CommandContext { if let LivenessEvent::ReceivedPong(pong) = &*event { if pong.node_id == dest_node_id { println!( - "🏓️ Pong received, latency in is {:.2?}!", + "🏓️ Pong received, round-trip-time is {:.2?}!", pong.latency.unwrap_or_default() ); break; diff --git a/applications/tari_console_wallet/src/automation/commands.rs b/applications/tari_console_wallet/src/automation/commands.rs index d4deddef4f..e9d37ed386 100644 --- a/applications/tari_console_wallet/src/automation/commands.rs +++ b/applications/tari_console_wallet/src/automation/commands.rs @@ -23,6 +23,7 @@ use std::{ fs, fs::File, + io, io::{LineWriter, Write}, path::{Path, PathBuf}, time::{Duration, Instant}, @@ -68,7 +69,7 @@ use tokio::{ use super::error::CommandError; use crate::{ - cli::CliCommands, + cli::{CliCommands, MakeItRainTransactionType}, utils::db::{CUSTOM_BASE_NODE_ADDRESS_KEY, CUSTOM_BASE_NODE_PUBLIC_KEY_KEY}, }; @@ -299,7 +300,7 @@ pub async fn make_it_rain( increase_amount: MicroTari, start_time: DateTime, destination: PublicKey, - negotiated: bool, + transaction_type: MakeItRainTransactionType, message: String, ) -> Result<(), CommandError> { // We are spawning this command in parallel, thus not collecting transaction IDs @@ -331,7 +332,6 @@ pub async fn make_it_rain( delayed_for: Duration, submit_time: Duration, } - let transaction_type = if negotiated { "negotiated" } else { "one-sided" }; println!( "\n`make-it-rain` starting {} {} transactions \"{}\"\n", num_txs, transaction_type, message @@ -367,15 +367,19 @@ pub async fn make_it_rain( tokio::task::spawn(async move { let spawn_start = Instant::now(); // Send transaction - let tx_id = if negotiated { - send_tari(tx_service, fee, amount, pk.clone(), msg.clone()).await - } else { - send_one_sided(tx_service, fee, amount, pk.clone(), msg.clone()).await + let tx_id = match transaction_type { + MakeItRainTransactionType::Interactive => { + send_tari(tx_service, fee, amount, pk.clone(), msg.clone()).await + }, + MakeItRainTransactionType::OneSided => { + send_one_sided(tx_service, fee, amount, pk.clone(), msg.clone()).await + }, + MakeItRainTransactionType::StealthOneSided => { + send_one_sided_to_stealth_address(tx_service, fee, amount, pk.clone(), msg.clone()).await + }, }; let submit_time = Instant::now(); - tokio::task::spawn(async move { - print!("{} ", i + 1); - }); + if let Err(e) = sender_clone .send(TransactionSendStats { i: i + 1, @@ -397,6 +401,8 @@ pub async fn make_it_rain( while let Some(send_stats) = receiver.recv().await { match send_stats.tx_id { Ok(tx_id) => { + print!("{} ", send_stats.i); + io::stdout().flush().unwrap(); debug!( target: LOG_TARGET, "make-it-rain transaction {} ({}) submitted to queue, tx_id: {}, delayed for ({}ms), submit \ @@ -606,6 +612,7 @@ pub async fn command_runner( tx_ids.push(tx_id); }, MakeItRain(args) => { + let transaction_type = args.transaction_type(); make_it_rain( transaction_service.clone(), config.fee_per_gram, @@ -615,7 +622,7 @@ pub async fn command_runner( args.increase_amount, args.start_time.unwrap_or_else(Utc::now), args.destination.into(), - !args.one_sided, + transaction_type, args.message, ) .await?; diff --git a/applications/tari_console_wallet/src/cli.rs b/applications/tari_console_wallet/src/cli.rs index 6de386073f..e81664d4f6 100644 --- a/applications/tari_console_wallet/src/cli.rs +++ b/applications/tari_console_wallet/src/cli.rs @@ -20,7 +20,11 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use std::{path::PathBuf, time::Duration}; +use std::{ + fmt::{Display, Formatter}, + path::PathBuf, + time::Duration, +}; use chrono::{DateTime, Utc}; use clap::{Args, Parser, Subcommand}; @@ -144,10 +148,37 @@ pub struct MakeItRainArgs { pub start_time: Option>, #[clap(short, long)] pub one_sided: bool, + #[clap(short, long, alias = "stealth-one-sided")] + pub stealth: bool, #[clap(short, long, default_value = "Make it rain")] pub message: String, } +impl MakeItRainArgs { + pub fn transaction_type(&self) -> MakeItRainTransactionType { + if self.stealth { + MakeItRainTransactionType::StealthOneSided + } else if self.one_sided { + MakeItRainTransactionType::OneSided + } else { + MakeItRainTransactionType::Interactive + } + } +} + +#[derive(Debug, Clone, Copy)] +pub enum MakeItRainTransactionType { + Interactive, + OneSided, + StealthOneSided, +} + +impl Display for MakeItRainTransactionType { + fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} + fn parse_start_time(arg: &str) -> Result, chrono::ParseError> { let mut start_time = Utc::now(); if !arg.is_empty() && arg.to_uppercase() != "NOW" {