Browse Source

hide sensitive data in STDOUT

pull/30/head
lucretius 3 months ago
parent
commit
00a1af525f
  1. 2
      cli/src/lib.rs
  2. 18
      lib/src/grpcconnector.rs
  3. 16
      lib/src/lightclient.rs

2
cli/src/lib.rs

@ -256,7 +256,7 @@ pub fn attempt_recover_seed(password: Option<String>) {
};
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)
};
}

18
lib/src/grpcconnector.rs

@ -35,10 +35,8 @@ mod danger {
async fn get_client(uri: &http::Uri, no_cert: bool) -> Result<CompactTxStreamerClient<Channel>, Box<dyn std::error::Error>> {
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::<Result<Vec<()>, 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<BlockId, Str
Ok(r) => 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
})
}

16
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<LightClient>) -> 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<LightClient>) -> 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<LightClient>) -> 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<LightClient>) -> 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),
}
});
}

Loading…
Cancel
Save