From 00a1af525fd2fd71ffeeb175530f0829416066de Mon Sep 17 00:00:00 2001 From: lucretius Date: Mon, 29 Jan 2024 18:07:42 +0100 Subject: [PATCH] hide sensitive data in STDOUT --- cli/src/lib.rs | 2 +- lib/src/grpcconnector.rs | 18 ++++++++---------- lib/src/lightclient.rs | 16 ++++++++-------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/cli/src/lib.rs b/cli/src/lib.rs index 2c08641..21dd67f 100644 --- a/cli/src/lib.rs +++ b/cli/src/lib.rs @@ -256,7 +256,7 @@ pub fn attempt_recover_seed(password: Option) { }; match LightClient::attempt_recover_seed(&config, password) { - Ok(seed) => println!("Recovered seed: '{}'", seed), + Ok(_seed) => println!("Recovered seed "), Err(e) => eprintln!("Failed to recover seed. Error: {}", e) }; } diff --git a/lib/src/grpcconnector.rs b/lib/src/grpcconnector.rs index f7d9894..8ade8f0 100644 --- a/lib/src/grpcconnector.rs +++ b/lib/src/grpcconnector.rs @@ -35,10 +35,8 @@ mod danger { async fn get_client(uri: &http::Uri, no_cert: bool) -> Result, Box> { let channel = if uri.scheme_str() == Some("http") { - //println!("http"); Channel::builder(uri.clone()).connect().await? } else { - //println!("https"); let mut config = ClientConfig::new(); config.alpn_protocols.push(b"h2".to_vec()); @@ -124,7 +122,7 @@ where F : Fn(&[u8], u64) { let mut encoded_buf = vec![]; if let Err(e) = block.encode(&mut encoded_buf) { - eprintln!("Error encoding block: {:?}", e); + error!("Error encoding block: {:?}", e); break; } @@ -132,7 +130,7 @@ where F : Fn(&[u8], u64) { } if let Err(e) = ftx.send(Ok(())) { - eprintln!("Error sending completion signal: {:?}", e); + error!("Error sending completion signal: {:?}", e); } }); @@ -140,13 +138,13 @@ where F : Fn(&[u8], u64) { while let Some(block) = response.message().await? { if let Err(e) = tx.send(Some(block)) { - eprintln!("Error sending block to channel: {:?}", e); + error!("Error sending block to channel: {:?}", e); break; } } if let Err(e) = tx.send(None) { - eprintln!("Error sending end signal to channel: {:?}", e); + error!("Error sending end signal to channel: {:?}", e); } frx.iter().take(1).collect::, String>>()?; @@ -191,7 +189,7 @@ where F : Fn(&[u8], u64) { let mut client = match get_client(uri, no_cert).await { Ok(client) => client, Err(e) => { - eprintln!("Error creating client: {:?}", e); + error!("Error creating client: {:?}", e); return Err(e.into()); } }; @@ -204,7 +202,7 @@ where F : Fn(&[u8], u64) { let maybe_response = match client.get_address_txids(request).await { Ok(response) => response, Err(e) => { - eprintln!("Error getting address txids: {:?}", e); + error!("Error getting address txids: {:?}", e); return Err(e.into()); } }; @@ -355,14 +353,14 @@ pub fn fetch_latest_block(uri: &http::Uri, no_cert: bool) -> Result r, Err(e) => { let errstr = format!("Error creating runtime {}", e.to_string()); - eprintln!("{}", errstr); + error!("{}", errstr); return Err(errstr); } }; rt.block_on(get_latest_block(uri, no_cert)).map_err(|e| { let errstr = format!("Error getting latest block {}", e.to_string()); - eprintln!("{}", errstr); + error!("{}", errstr); errstr }) } diff --git a/lib/src/lightclient.rs b/lib/src/lightclient.rs index 06f004e..b66e013 100644 --- a/lib/src/lightclient.rs +++ b/lib/src/lightclient.rs @@ -449,11 +449,11 @@ impl LightClient { sync_status : Arc::new(RwLock::new(WalletStatus::new())), }; - println!("Setting birthday to {}", birthday); + l.set_wallet_initial_state(birthday); #[cfg(feature = "embed_params")] l.read_sapling_params(); - println!("Setting Number to {}", number); + info!("Created new wallet!"); info!("Created LightClient to {}", &config.server); @@ -1233,7 +1233,7 @@ pub fn start_mempool_monitor(lc: Arc) -> Result<(), String> { } // Sleep exponentially backing off std::thread::sleep(std::time::Duration::from_secs((2 as u64).pow(retry_count))); - // println!("Sync error {}\nRetry count {}", e, retry_count); + } } } @@ -1393,7 +1393,7 @@ pub fn start_mempool_monitor(lc: Arc) -> Result<(), String> { { - // println!("Total scan duration: {:?}", self.wallet.read().unwrap().total_scan_duration.read().unwrap().get(0).unwrap().as_millis()); + let t = self.wallet.read().unwrap(); let mut d = t.total_scan_duration.write().unwrap(); @@ -1529,17 +1529,17 @@ pub fn start_mempool_monitor(lc: Arc) -> Result<(), String> { w.scan_full_tx(&tx, height as i32, datetime as u64); }, Err(e) => { - println!("Error reading wallet: {}", e); + error!("Error reading wallet: {}", e); }, } }, Err(e) => { - println!("Error processing transaction: {}", e); + error!("Error processing transaction: {}", e); }, } }, Err(e) => { - println!("Error reading transaction: {}", e); + error!("Error reading transaction: {}", e); }, } } @@ -1547,7 +1547,7 @@ pub fn start_mempool_monitor(lc: Arc) -> Result<(), String> { match ctx.send(r) { Ok(_) => info!("Successfully sent data for address: {}", address_clone), - Err(e) => println!("Failed to send data for address: {}: {:?}", address_clone, e), + Err(e) => error!("Failed to send data for address: {}: {:?}", address_clone, e), } }); }